diff mbox series

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

Message ID DB6PR0101MB2214C6024398AF84438EA68C8F739@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com
State Accepted
Commit 4dddcd08c47850fbf3cef2ff6b31f65133856e0f
Headers show
Series [FFmpeg-devel,01/11] avcodec/tests/avcodec: Mark frame-thrd encoder incompatible with delay | expand

Commit Message

Andreas Rheinhardt Aug. 24, 2022, 1:40 a.m. UTC
Instead of indicating whether we got a packet by setting
pkt->data and pkt->size to zero.

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

Patch

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;