static void lock_command(ostream &out, istream &in) { int choice ; FrSymbol *name ; do { choice = display_menu(out,in,true,2, "FrFrame Locking", "\t1. Lock FrFrame\n" "\t2. Unlock FrFrame\n" ) ; if (choice != 0) name = get_symbol(out,in,"FrFrame name:") ; else name = 0 ; // avoid "uninit var" warning switch (choice) { case 0: // do nothing break ; case 1: if (name->isLocked()) out << "The frame was already locked." << endl ; else { name->lockFrame() ; out << "The frame was not yet locked, and is " ; if (name->isLocked()) out << "now locked." << endl ; else out << "STILL NOT locked." << endl ; } break ; case 2: if (!frame_locked(name)) out << "The frame was not locked." << endl ; else { unlock_frame(name) ; out << "The frame was locked, and is " ; if (frame_locked(name)) out << "STILL locked." << endl ; else out << "now unlocked." << endl ; } break ; default: FrMissedCase("lock_command") ; break ; } } while (choice != 0) ; return ; }
int process_filter(qsv_filter_task_t* task, void* params){ mfxStatus sts = MFX_ERR_NONE; if (MFX_ERR_NONE != (sts = lock_frame(task->processor.alloc,task->in)))return sts; if (MFX_ERR_NONE != (sts = lock_frame(task->processor.alloc,task->out))) { unlock_frame(task->processor.alloc,task->in); return sts; } qsv_nv12_to_yuv420(task->pv->sws_context_from_nv12,task->pv->pre.out, task->in, task->processor.core); // signal: input is prepared, converted from pipeline into internal buffer hb_lock(task->pv->pre.frame_completed_lock); task->pv->pre.frame_go = 1; hb_cond_broadcast(task->pv->pre.frame_completed); hb_unlock(task->pv->pre.frame_completed_lock); // wait: input is prepared, converted from pipeline into internal buffer hb_lock(task->pv->post.frame_completed_lock); while(!task->pv->post.frame_go){ hb_cond_timedwait(task->pv->post.frame_completed,task->pv->post.frame_completed_lock,1000); if(*task->pv->job->die) break; } task->pv->post.frame_go = 0; hb_unlock(task->pv->post.frame_completed_lock); // this is just a simple fun/test case #if 0 { int i = 0; char *cur_line; char* luma = task->pv->post.in->plane[0].data; int pitch = task->pv->post.in->plane[0].stride; int h = task->pv->post.in->plane[0].height; int w = task->pv->post.in->plane[0].width; for (i = 0; i < h; i++){ cur_line = luma + i * pitch; if(i>h/4 && i < 3*h/4 && i % 5 == 0 ) memset(cur_line, 0 , w ); } } #endif if(task->pv->post.in) { qsv_yuv420_to_nv12(task->pv->sws_context_to_nv12, task->out, task->pv->post.in); } // signal: output is prepared, converted from internal buffer into pipeline hb_lock(task->pv->post_busy.frame_completed_lock); task->pv->post_busy.frame_go = 1; hb_cond_broadcast(task->pv->post_busy.frame_completed); hb_unlock(task->pv->post_busy.frame_completed_lock); unlock_frame(task->processor.alloc,task->in); unlock_frame(task->processor.alloc,task->out); return sts; }