This is required to fulfill avcodec_decode_video2() promise to return
the number of consumed bytes on success.
---
 libavcodec/avcodec.h |    3 ++-
 libavcodec/pthread.c |    5 +++--
 libavcodec/thread.h  |    3 +++
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index dc794b0..b7f5960 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3927,7 +3927,8 @@ int avcodec_decode_audio3(AVCodecContext *avctx, int16_t 
*samples,
 /**
  * Decode the video frame of size avpkt->size from avpkt->data into picture.
  * Some decoders may support multiple frames in a single AVPacket, such
- * decoders would then just decode the first frame.
+ * decoders would then just decode the first frame. Multiple frames in a single
+ * AVPacket are not supported with frame level multithreading.
  *
  * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
  * the actual read bytes because some optimized bitstream readers read 32 or 64
diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
index 9c3453f..3364376 100644
--- a/libavcodec/pthread.c
+++ b/libavcodec/pthread.c
@@ -522,7 +522,7 @@ int ff_thread_decode_frame(AVCodecContext *avctx,
         if (fctx->next_decoding >= (avctx->thread_count-1)) fctx->delaying = 0;
 
         *got_picture_ptr=0;
-        return 0;
+        return avpkt->size;
     }
 
     /*
@@ -563,7 +563,8 @@ int ff_thread_decode_frame(AVCodecContext *avctx,
 
     fctx->next_finished = finished;
 
-    return p->result;
+    /* return the size of the consumed packet if no error occurred */
+    return (p->result >= 0) ? avpkt->size : p->result;
 }
 
 void ff_thread_report_progress(AVFrame *f, int n, int field)
diff --git a/libavcodec/thread.h b/libavcodec/thread.h
index 401c4d2..dfd261d 100644
--- a/libavcodec/thread.h
+++ b/libavcodec/thread.h
@@ -42,6 +42,9 @@ void ff_thread_flush(AVCodecContext *avctx);
  * Submits a new frame to a decoding thread.
  * Returns the next available frame in picture. *got_picture_ptr
  * will be 0 if none is available.
+ * The return value on success is the size of the consumed packet for
+ * compatiblity with avcodec_decode_video2(). This means the decoder
+ * has to consume the full packet.
  *
  * Parameters are the same as avcodec_decode_video2().
  */
-- 
1.7.8.rc3

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to