A new function is introuduced to keep compatibility across the code.
---
 libavcodec/error_resilience.c |  6 +++---
 libavcodec/error_resilience.h | 21 ++++++++++++++++++---
 libavcodec/h264.c             |  6 +++---
 libavcodec/mpegvideo.c        | 35 ++++++++++++++++++++++++++++++++---
 libavcodec/mpegvideo.h        |  2 ++
 5 files changed, 58 insertions(+), 12 deletions(-)

diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
index 51ebc04..0707368 100644
--- a/libavcodec/error_resilience.c
+++ b/libavcodec/error_resilience.c
@@ -1223,7 +1223,7 @@ ec_clean:
         }
         s->mbintra_table[mb_xy] = 1;
     }
-    s->cur_pic = NULL;
-    s->next_pic    = NULL;
-    s->last_pic    = NULL;
+    av_freep(&s->cur_pic);
+    av_freep(&s->next_pic);
+    av_freep(&s->last_pic);
 }
diff --git a/libavcodec/error_resilience.h b/libavcodec/error_resilience.h
index f979656..265d3dd 100644
--- a/libavcodec/error_resilience.h
+++ b/libavcodec/error_resilience.h
@@ -24,6 +24,7 @@
 
 #include "avcodec.h"
 #include "dsputil.h"
+#include "thread.h"
 
 ///< current MB is the first after a resync marker
 #define VP_START               1
@@ -37,6 +38,20 @@
 #define ER_MB_ERROR (ER_AC_ERROR|ER_DC_ERROR|ER_MV_ERROR)
 #define ER_MB_END   (ER_AC_END|ER_DC_END|ER_MV_END)
 
+typedef struct ERPicture {
+    struct AVFrame f;
+    ThreadFrame tf;
+
+    AVBufferRef *motion_val_buf[2];
+    int16_t (*motion_val[2])[2];
+
+    AVBufferRef *ref_index_buf[2];
+    int8_t *ref_index[2];
+
+    uint32_t *mb_type;
+    int field_picture;
+} ERPicture;
+
 typedef struct ERContext {
     AVCodecContext *avctx;
     DSPContext *dsp;
@@ -55,9 +70,9 @@ typedef struct ERContext {
     uint8_t *mbintra_table;
     int mv[2][4][2];
 
-    struct Picture *cur_pic;
-    struct Picture *last_pic;
-    struct Picture *next_pic;
+    struct ERPicture *cur_pic;
+    struct ERPicture *last_pic;
+    struct ERPicture *next_pic;
 
     uint16_t pp_time;
     uint16_t pb_time;
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index c76abf7..e72b76e 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -2974,9 +2974,9 @@ static int field_end(H264Context *h, int in_setup)
      * causes problems for the first MB line, too.
      */
     if (CONFIG_ERROR_RESILIENCE && !FIELD_PICTURE(h)) {
-        h->er.cur_pic  = h->cur_pic_ptr;
-        h->er.last_pic = h->ref_count[0] ? &h->ref_list[0][0] : NULL;
-        h->er.next_pic = h->ref_count[1] ? &h->ref_list[1][0] : NULL;
+        h->er.cur_pic  = ff_erpicture_from_picture(h->cur_pic_ptr);
+        h->er.last_pic = ff_erpicture_from_picture(h->ref_count[0] ? 
&h->ref_list[0][0] : NULL);
+        h->er.next_pic = ff_erpicture_from_picture(h->ref_count[1] ? 
&h->ref_list[1][0] : NULL);
         ff_er_frame_end(&h->er);
     }
     emms_c();
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 73778f5..329a001 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -2481,13 +2481,42 @@ void ff_MPV_report_decode_progress(MpegEncContext *s)
 }
 
 #if CONFIG_ERROR_RESILIENCE
+ERPicture *ff_erpicture_from_picture(Picture *src)
+{
+    int i;
+    ERPicture *dst;
+
+    if (!src)
+        return NULL;
+
+    dst = av_malloc(sizeof(ERPicture));
+    if (!dst)
+        return NULL;
+
+    dst->f = src->f;
+    dst->tf = src->tf;
+
+    for (i = 0; i < 2; i++) {
+        dst->motion_val_buf[i] = src->motion_val_buf[i];
+        dst->motion_val[i] = src->motion_val[i];
+
+        dst->ref_index_buf[i] = src->ref_index_buf[i];
+        dst->ref_index[i] = src->ref_index[i];
+    }
+
+    dst->mb_type = src->mb_type;
+    dst->field_picture = src->field_picture;
+
+    return dst;
+}
+
 void ff_mpeg_er_frame_start(MpegEncContext *s)
 {
     ERContext *er = &s->er;
 
-    er->cur_pic  = s->current_picture_ptr;
-    er->last_pic = s->last_picture_ptr;
-    er->next_pic = s->next_picture_ptr;
+    er->cur_pic  = ff_erpicture_from_picture(s->current_picture_ptr);
+    er->next_pic = ff_erpicture_from_picture(s->next_picture_ptr);
+    er->last_pic = ff_erpicture_from_picture(s->last_picture_ptr);
 
     er->pp_time           = s->pp_time;
     er->pb_time           = s->pb_time;
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index f888700..568429a 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -799,7 +799,9 @@ void ff_MPV_report_decode_progress(MpegEncContext *s);
 int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext 
*src);
 void ff_set_qscale(MpegEncContext * s, int qscale);
 
+/* Error resilience */
 void ff_mpeg_er_frame_start(MpegEncContext *s);
+ERPicture *ff_erpicture_from_picture(Picture *src);
 
 int ff_dct_common_init(MpegEncContext *s);
 void ff_convert_matrix(DSPContext *dsp, int (*qmat)[64], uint16_t 
(*qmat16)[2][64],
-- 
1.8.3.4 (Apple Git-47)

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

Reply via email to