Video decoders always consume full packets.
---
 libavcodec/h264dec.c | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 6ce0287..a68a9ad 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -628,19 +628,6 @@ end:
     return (ret < 0) ? ret : buf_size;
 }
 
-/**
- * Return the number of bytes consumed for building the current frame.
- */
-static int get_consumed_bytes(int pos, int buf_size)
-{
-    if (pos == 0)
-        pos = 1;        // avoid infinite loops (I doubt that is needed but...)
-    if (pos + 10 > buf_size)
-        pos = buf_size; // oops ;)
-
-    return pos;
-}
-
 static int h264_decode_frame(AVCodecContext *avctx, void *data,
                              int *got_frame, AVPacket *avpkt)
 {
@@ -648,7 +635,6 @@ static int h264_decode_frame(AVCodecContext *avctx, void 
*data,
     int buf_size       = avpkt->size;
     H264Context *h     = avctx->priv_data;
     AVFrame *pict      = data;
-    int buf_index      = 0;
     int ret;
     const uint8_t *new_extradata;
     int new_extradata_size;
@@ -681,8 +667,8 @@ static int h264_decode_frame(AVCodecContext *avctx, void 
*data,
             return ret;
     }
 
-    buf_index = decode_nal_units(h, buf, buf_size);
-    if (buf_index < 0)
+    ret = decode_nal_units(h, buf, buf_size);
+    if (ret < 0)
         return AVERROR_INVALIDDATA;
 
     if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS) && !h->cur_pic_ptr) {
@@ -706,7 +692,7 @@ static int h264_decode_frame(AVCodecContext *avctx, void 
*data,
 
     assert(pict->buf[0] || !*got_frame);
 
-    return get_consumed_bytes(buf_index, buf_size);
+    return buf_size;
 }
 
 #define OFFSET(x) offsetof(H264Context, x)
-- 
2.0.0

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to