[FFmpeg-cvslog] avcodec/mpegvideo: Factor ff_mpv_decode_init() out

Michael Niedermayer git at videolan.org
Fri Sep 5 20:57:12 CEST 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Sep  5 16:57:57 2014 +0200| [4dee4a4470cd28132cc9c96e00a6cc1080a4b27f] | committer: Michael Niedermayer

avcodec/mpegvideo: Factor ff_mpv_decode_init() out

Reviewed-by: Benoit Fouet <benoit.fouet at free.fr>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavcodec/h261dec.c   |    7 ++-----
 libavcodec/h263dec.c   |    6 ++----
 libavcodec/mpeg12dec.c |    3 +--
 libavcodec/mpegvideo.c |   12 ++++++++++++
 libavcodec/mpegvideo.h |    1 +
 libavcodec/rv10.c      |    3 +--
 libavcodec/rv34.c      |    7 +------
 7 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index a8aae6e..ead81fc 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -76,14 +76,11 @@ static av_cold int h261_decode_init(AVCodecContext *avctx)
 
     // set defaults
     ff_mpv_decode_defaults(s);
-    s->avctx       = avctx;
-    s->width       = s->avctx->coded_width;
-    s->height      = s->avctx->coded_height;
-    s->codec_id    = s->avctx->codec->id;
+    ff_mpv_decode_init(s, avctx);
+
     s->out_format  = FMT_H261;
     s->low_delay   = 1;
     avctx->pix_fmt = AV_PIX_FMT_YUV420P;
-    s->codec_id    = avctx->codec->id;
 
     ff_h261_common_init();
     h261_decode_init_vlc(h);
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 9f5500d..b39a63b 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -48,14 +48,12 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
     MpegEncContext *s = avctx->priv_data;
     int ret;
 
-    s->avctx           = avctx;
     s->out_format      = FMT_H263;
-    s->width           = avctx->coded_width;
-    s->height          = avctx->coded_height;
-    s->workaround_bugs = avctx->workaround_bugs;
 
     // set defaults
     ff_mpv_decode_defaults(s);
+    ff_mpv_decode_init(s, avctx);
+
     s->quant_precision = 5;
     s->decode_mb       = ff_h263_decode_mb;
     s->low_delay       = 1;
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 40aad16..ed3490b 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1120,10 +1120,9 @@ static av_cold int mpeg_decode_init(AVCodecContext *avctx)
     MpegEncContext *s2 = &s->mpeg_enc_ctx;
 
     ff_mpv_decode_defaults(s2);
+    ff_mpv_decode_init(s2, avctx);
 
     s->mpeg_enc_ctx.avctx  = avctx;
-    s->mpeg_enc_ctx.flags  = avctx->flags;
-    s->mpeg_enc_ctx.flags2 = avctx->flags2;
 
     /* we need some permutation to store matrices,
      * until the decoder sets the real permutation. */
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 85cb41d..f5306cb 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1109,6 +1109,18 @@ void ff_mpv_decode_defaults(MpegEncContext *s)
     ff_mpv_common_defaults(s);
 }
 
+void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx)
+{
+    s->avctx           = avctx;
+    s->width           = avctx->coded_width;
+    s->height          = avctx->coded_height;
+    s->codec_id        = avctx->codec->id;
+    s->workaround_bugs = avctx->workaround_bugs;
+    s->flags           = avctx->flags;
+    s->flags2          = avctx->flags2;
+
+}
+
 static int init_er(MpegEncContext *s)
 {
     ERContext *er = &s->er;
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index fa20665..87fe87f 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -726,6 +726,7 @@ int ff_mpv_common_frame_size_change(MpegEncContext *s);
 void ff_mpv_common_end(MpegEncContext *s);
 
 void ff_mpv_decode_defaults(MpegEncContext *s);
+void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx);
 void ff_mpv_decode_mb(MpegEncContext *s, int16_t block[12][64]);
 void ff_mpv_report_decode_progress(MpegEncContext *s);
 
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index 4a5cf41..7097b29 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -475,10 +475,9 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
         return ret;
 
     ff_mpv_decode_defaults(s);
+    ff_mpv_decode_init(s, avctx);
 
-    s->avctx       = avctx;
     s->out_format  = FMT_H263;
-    s->codec_id    = avctx->codec_id;
 
     rv->orig_width  =
     s->width        = avctx->coded_width;
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index c8aa6b6..a232ab2 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -1490,14 +1490,9 @@ av_cold int ff_rv34_decode_init(AVCodecContext *avctx)
     int ret;
 
     ff_mpv_decode_defaults(s);
-    s->avctx      = avctx;
+    ff_mpv_decode_init(s, avctx);
     s->out_format = FMT_H263;
-    s->codec_id   = avctx->codec_id;
 
-    s->width  = avctx->width;
-    s->height = avctx->height;
-
-    r->s.avctx = avctx;
     avctx->pix_fmt = AV_PIX_FMT_YUV420P;
     avctx->has_b_frames = 1;
     s->low_delay = 0;



More information about the ffmpeg-cvslog mailing list