[FFmpeg-cvslog] mpeg12: move current_picture_ptr reset to the end of decode_frame.

Michael Niedermayer git at videolan.org
Sun Dec 9 19:57:28 CET 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Dec  9 19:49:51 2012 +0100| [0af7ccd9e2689e5ae1a4532907b6d7c2e169ebb9] | committer: Michael Niedermayer

mpeg12: move current_picture_ptr reset to the end of decode_frame.

This fixes passing fields instead of frames into the decoder.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavcodec/mpeg12.c |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index c40af2b..e32cce0 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -2522,14 +2522,13 @@ static int mpeg_decode_frame(AVCodecContext *avctx,
                              AVPacket *avpkt)
 {
     const uint8_t *buf = avpkt->data;
+    int ret;
     int buf_size = avpkt->size;
     Mpeg1Context *s = avctx->priv_data;
     AVFrame *picture = data;
     MpegEncContext *s2 = &s->mpeg_enc_ctx;
     av_dlog(avctx, "fill_buffer\n");
 
-    s2->current_picture_ptr = NULL;
-
     if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == SEQ_END_CODE)) {
         /* special case for last picture */
         if (s2->low_delay == 0 && s2->next_picture_ptr) {
@@ -2557,17 +2556,23 @@ static int mpeg_decode_frame(AVCodecContext *avctx,
     s->slice_count = 0;
 
     if (avctx->extradata && !s->parsed_extra) {
-        int ret = decode_chunks(avctx, picture, got_output, avctx->extradata, avctx->extradata_size);
+        ret = decode_chunks(avctx, picture, got_output, avctx->extradata, avctx->extradata_size);
         if(*got_output) {
             av_log(avctx, AV_LOG_ERROR, "picture in extradata\n");
             *got_output = 0;
         }
         s->parsed_extra = 1;
-        if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE))
+        if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE)) {
+            s2->current_picture_ptr = NULL;
             return ret;
+        }
     }
 
-    return decode_chunks(avctx, picture, got_output, buf, buf_size);
+    ret = decode_chunks(avctx, picture, got_output, buf, buf_size);
+    if (ret<0 || *got_output)
+        s2->current_picture_ptr = NULL;
+
+    return ret;
 }
 
 



More information about the ffmpeg-cvslog mailing list