---
 libavcodec/mpegvideo.c |   24 ++++++++++++++++++++++++
 libavcodec/mpegvideo.h |    1 +
 2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 9280ab8..9e68022 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -398,6 +398,30 @@ void MPV_update_picture_pointers(MpegEncContext *dst, MpegEncContext *src){
     }
 }
 
+int ff_mpeg_update_context(AVCodecContext *dst, AVCodecContext *src)
+{
+    MpegEncContext *s = dst->priv_data, *s1 = src->priv_data;
+
+    if (!s1->context_initialized) return 0;
+
+    //FIXME can parameters change on I-frames? in that case dst may need a reinit
+    if (!s->context_initialized) {
+        memcpy(s, s1, sizeof(MpegEncContext));
+
+        s->avctx = dst;
+        s->picture_range_start  += MAX_PICTURE_COUNT;
+        s->picture_range_end    += MAX_PICTURE_COUNT;
+        s->bitstream_buffer      = NULL;
+        s->bitstream_buffer_size = s->allocated_bitstream_buffer_size = 0;
+
+        MPV_common_init(s);
+    }
+
+    MPV_update_picture_pointers(s, s1);
+
+    return 0;
+}
+
 /**
  * sets the given MpegEncContext to common defaults (same for encoding and decoding).
  * the changed fields will not depend upon the prior state of the MpegEncContext.
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index b9b258d..497a6fa 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -695,6 +695,7 @@ void ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src);
 void MPV_update_picture_pointers(MpegEncContext *dst, MpegEncContext *src);
 int MPV_lowest_referenced_row(MpegEncContext *s, int dir);
 void MPV_report_decode_progress(MpegEncContext *s);
+int ff_mpeg_update_context(AVCodecContext *dst, AVCodecContext *src);
 const uint8_t *ff_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state);
 
 void ff_er_frame_start(MpegEncContext *s);
_______________________________________________
FFmpeg-soc mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc

Reply via email to