Merge commit '759001c534287a96dc96d1e274665feb7059145d'
[ffmpeg.git] / libavcodec / rv10.c
index 1528780..e2ccee7 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "libavutil/imgutils.h"
 #include "avcodec.h"
+#include "error_resilience.h"
 #include "mpegvideo.h"
 #include "mpeg4video.h"
 #include "h263.h"
@@ -419,7 +420,8 @@ static int rv20_decode_picture_header(RVDecContext *rv)
     if (s->pict_type==AV_PICTURE_TYPE_B) {
         if(s->pp_time <=s->pb_time || s->pp_time <= s->pp_time - s->pb_time || s->pp_time<=0){
             av_log(s->avctx, AV_LOG_DEBUG, "messed up order, possible from seeking? skipping current b frame\n");
-            return FRAME_SKIPPED;
+#define ERROR_SKIP_FRAME -123
+            return ERROR_SKIP_FRAME;
         }
         ff_mpeg4_init_direct_mv(s);
     }
@@ -542,7 +544,8 @@ static int rv10_decode_packet(AVCodecContext *avctx,
     else
         mb_count = rv20_decode_picture_header(rv);
     if (mb_count < 0) {
-        av_log(s->avctx, AV_LOG_ERROR, "HEADER ERROR\n");
+        if (mb_count != ERROR_SKIP_FRAME)
+            av_log(s->avctx, AV_LOG_ERROR, "HEADER ERROR\n");
         return -1;
     }
 
@@ -677,7 +680,7 @@ static int rv10_decode_frame(AVCodecContext *avctx,
     const uint8_t *buf = avpkt->data;
     int buf_size = avpkt->size;
     MpegEncContext *s = avctx->priv_data;
-    int i;
+    int i, ret;
     AVFrame *pict = data;
     int slice_count;
     const uint8_t *slices_hdr = NULL;
@@ -736,14 +739,17 @@ static int rv10_decode_frame(AVCodecContext *avctx,
         ff_MPV_frame_end(s);
 
         if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
-            *pict = s->current_picture_ptr->f;
+            if ((ret = av_frame_ref(pict, &s->current_picture_ptr->f)) < 0)
+                return ret;
+            ff_print_debug_info(s, s->current_picture_ptr);
         } else if (s->last_picture_ptr != NULL) {
-            *pict = s->last_picture_ptr->f;
+            if ((ret = av_frame_ref(pict, &s->last_picture_ptr->f)) < 0)
+                return ret;
+            ff_print_debug_info(s, s->last_picture_ptr);
         }
 
         if(s->last_picture_ptr || s->low_delay){
             *got_frame = 1;
-            ff_print_debug_info(s, pict);
         }
         s->current_picture_ptr= NULL; // so we can detect if frame_end was not called (find some nicer solution...)
     }