void QueueEncodeTask(mfxFrameSurface1& pic) { encode_task& task = encode_tasks[idle_tasks[0]]; queued_tasks << idle_tasks[0]; idle_tasks.Remove(0); task.keyframe = bRequestKeyframe; bRequestKeyframe = false; mfxBitstream& bs = task.bs; mfxFrameSurface1& surf = task.surf; mfxFrameData& frame = frames[pic.Data.FrameOrder-1]; mfxSyncPoint& sp = task.sp; frame.Locked = true; task.frame = &frame; bs.DataLength = 0; bs.DataOffset = 0; surf.Data.Y = frame.Y; surf.Data.UV = frame.UV; surf.Data.V = frame.V; surf.Data.Pitch = frame.Pitch; surf.Data.TimeStamp = timestampFromMS(pic.Data.TimeStamp); pic.Data.Y = nullptr; pic.Data.UV = nullptr; pic.Data.FrameOrder = 0; }
void QueueEncodeTask(mfxFrameSurface1& pic) { encode_task& task = encode_tasks[idle_tasks[0]]; auto lock_queue = lock_mutex(frame_queue); for(unsigned i = 0; i < frame_queue.size; i++) { queued_frame &info = frame_queue[i]; if(info.is_new) continue; queued_tasks << idle_tasks[0]; idle_tasks.Remove(0); info.is_new = true; info.request_keyframe = bRequestKeyframe; bRequestKeyframe = false; info.timestamp = task.surf.Data.TimeStamp = timestampFromMS(pic.Data.TimeStamp); info.frame_index = (uint32_t)pic.Data.MemId-1; auto lock_status = lock_mutex(frame_buff_status); frame_buff_status[info.frame_index] += 1; frame_queue.signal(); return; } CrashError(TEXT("QSV encoder is too slow")); }