[FFmpeg-devel] [PATCH 05/11] avcodec/frame_thread_encoder: Forward got_packet directly

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Wed Aug 24 04:40:00 EEST 2022


Instead of indicating whether we got a packet by setting
pkt->data and pkt->size to zero.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/frame_thread_encoder.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/libavcodec/frame_thread_encoder.c b/libavcodec/frame_thread_encoder.c
index 07d310a986..b5765b6343 100644
--- a/libavcodec/frame_thread_encoder.c
+++ b/libavcodec/frame_thread_encoder.c
@@ -45,6 +45,7 @@ typedef struct{
     AVPacket *outdata;
     int       return_code;
     int       finished;
+    int       got_packet;
 } Task;
 
 typedef struct{
@@ -110,10 +111,8 @@ static void * attribute_align_arg worker(void *v){
             if (ret >= 0 && ret2 < 0)
                 ret = ret2;
             pkt->pts = pkt->dts = frame->pts;
-        } else {
-            pkt->data = NULL;
-            pkt->size = 0;
         }
+        task->got_packet = got_packet;
         pthread_mutex_lock(&c->buffer_mutex);
         av_frame_unref(frame);
         pthread_mutex_unlock(&c->buffer_mutex);
@@ -315,8 +314,7 @@ int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
      * because there is no outstanding task with this index. */
     outtask->finished = 0;
     av_packet_move_ref(pkt, outtask->outdata);
-    if(pkt->data)
-        *got_packet_ptr = 1;
+    *got_packet_ptr = outtask->got_packet;
     c->finished_task_index = (c->finished_task_index + 1) % c->max_tasks;
 
     return outtask->return_code;
-- 
2.34.1



More information about the ffmpeg-devel mailing list