[FFmpeg-cvslog] avcodec/frame_thread_encoder: Reduce amount of code guarded by mutex

Andreas Rheinhardt git at videolan.org
Tue Feb 16 23:43:43 EET 2021


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Sun Feb  7 19:59:11 2021 +0100| [739175bfe5b9b6ec0e3ab62a2363c4e8d5761c40] | committer: Andreas Rheinhardt

avcodec/frame_thread_encoder: Reduce amount of code guarded by mutex

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=739175bfe5b9b6ec0e3ab62a2363c4e8d5761c40
---

 libavcodec/frame_thread_encoder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/frame_thread_encoder.c b/libavcodec/frame_thread_encoder.c
index c6323b6246..f1f4fcb490 100644
--- a/libavcodec/frame_thread_encoder.c
+++ b/libavcodec/frame_thread_encoder.c
@@ -305,6 +305,7 @@ int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     while (!outtask->finished) {
         pthread_cond_wait(&c->finished_task_cond, &c->finished_task_mutex);
     }
+    pthread_mutex_unlock(&c->finished_task_mutex);
     /* We now own outtask completely: No worker thread touches it any more,
      * because there is no outstanding task with this index. */
     outtask->finished = 0;
@@ -312,7 +313,6 @@ int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     if(pkt->data)
         *got_packet_ptr = 1;
     c->finished_task_index = (c->finished_task_index + 1) % c->max_tasks;
-    pthread_mutex_unlock(&c->finished_task_mutex);
 
     return outtask->return_code;
 }



More information about the ffmpeg-cvslog mailing list