sort_one(ref, j+1, right, list1_ascending, frame_idx);
}
-static int update_ReferenceFrames(int frame_type)
+static void update_ReferenceFrames(int frame_type)
{
int i;
if (frame_type == FRAME_B)
- return 0;
+ return;
CurrentCurrPic.flags = VA_PICTURE_H264_SHORT_TERM_REFERENCE;
numShortTerm++;
current_frame_num++;
if (current_frame_num > MaxFrameNum)
current_frame_num = 0;
-
- return 0;
}
vector<float> audio;
{
unique_lock<mutex> lock(frame_queue_mutex);
- frame_queue_nonempty.wait(lock, [this]{ return copy_thread_should_quit || !pending_audio_frames.empty(); });
- if (copy_thread_should_quit) return;
+ frame_queue_nonempty.wait(lock, [this]{ return encode_thread_should_quit || !pending_audio_frames.empty(); });
+ if (encode_thread_should_quit && pending_audio_frames.empty()) return;
auto it = pending_audio_frames.begin();
if (it->first > task.pts) break;
audio_pts = it->first;
storage_thread = thread(&H264Encoder::storage_task_thread, this);
- copy_thread = thread([this]{
+ encode_thread = thread([this]{
//SDL_GL_MakeCurrent(window, context);
QOpenGLContext *context = create_context(this->surface);
eglBindAPI(EGL_OPENGL_API);
eglGetError());
exit(1);
}
- copy_thread_func();
+ encode_thread_func();
});
}
H264Encoder::~H264Encoder()
{
+ {
+ unique_lock<mutex> lock(frame_queue_mutex);
+ encode_thread_should_quit = true;
+ frame_queue_nonempty.notify_all();
+ }
+ encode_thread.join();
{
unique_lock<mutex> lock(storage_task_queue_mutex);
storage_thread_should_quit = true;
storage_task_queue_changed.notify_all();
}
- {
- unique_lock<mutex> lock(frame_queue_mutex);
- copy_thread_should_quit = true;
- frame_queue_nonempty.notify_all();
- }
storage_thread.join();
- copy_thread.join();
release_encode();
deinit_va();
frame_queue_nonempty.notify_all();
}
-void H264Encoder::copy_thread_func()
+void H264Encoder::encode_thread_func()
{
int64_t last_dts = -1;
int gop_start_display_frame_num = 0;
{
unique_lock<mutex> lock(frame_queue_mutex);
frame_queue_nonempty.wait(lock, [this, display_frame_num]{
- return copy_thread_should_quit || pending_video_frames.count(display_frame_num) != 0;
+ return encode_thread_should_quit || pending_video_frames.count(display_frame_num) != 0;
});
- if (copy_thread_should_quit) {
+ if (encode_thread_should_quit) {
return;
} else {
frame = move(pending_video_frames[display_frame_num]);