Browse code

avcodec/mpegvideo: Factor ff_mpv_decode_init() out

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

Michael Niedermayer authored on 2014/09/05 23:57:57
Showing 7 changed files
... ...
@@ -76,14 +76,11 @@ static av_cold int h261_decode_init(AVCodecContext *avctx)
76 76
 
77 77
     // set defaults
78 78
     ff_mpv_decode_defaults(s);
79
-    s->avctx       = avctx;
80
-    s->width       = s->avctx->coded_width;
81
-    s->height      = s->avctx->coded_height;
82
-    s->codec_id    = s->avctx->codec->id;
79
+    ff_mpv_decode_init(s, avctx);
80
+
83 81
     s->out_format  = FMT_H261;
84 82
     s->low_delay   = 1;
85 83
     avctx->pix_fmt = AV_PIX_FMT_YUV420P;
86
-    s->codec_id    = avctx->codec->id;
87 84
 
88 85
     ff_h261_common_init();
89 86
     h261_decode_init_vlc(h);
... ...
@@ -48,14 +48,12 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
48 48
     MpegEncContext *s = avctx->priv_data;
49 49
     int ret;
50 50
 
51
-    s->avctx           = avctx;
52 51
     s->out_format      = FMT_H263;
53
-    s->width           = avctx->coded_width;
54
-    s->height          = avctx->coded_height;
55
-    s->workaround_bugs = avctx->workaround_bugs;
56 52
 
57 53
     // set defaults
58 54
     ff_mpv_decode_defaults(s);
55
+    ff_mpv_decode_init(s, avctx);
56
+
59 57
     s->quant_precision = 5;
60 58
     s->decode_mb       = ff_h263_decode_mb;
61 59
     s->low_delay       = 1;
... ...
@@ -1120,10 +1120,9 @@ static av_cold int mpeg_decode_init(AVCodecContext *avctx)
1120 1120
     MpegEncContext *s2 = &s->mpeg_enc_ctx;
1121 1121
 
1122 1122
     ff_mpv_decode_defaults(s2);
1123
+    ff_mpv_decode_init(s2, avctx);
1123 1124
 
1124 1125
     s->mpeg_enc_ctx.avctx  = avctx;
1125
-    s->mpeg_enc_ctx.flags  = avctx->flags;
1126
-    s->mpeg_enc_ctx.flags2 = avctx->flags2;
1127 1126
 
1128 1127
     /* we need some permutation to store matrices,
1129 1128
      * until the decoder sets the real permutation. */
... ...
@@ -1109,6 +1109,18 @@ void ff_mpv_decode_defaults(MpegEncContext *s)
1109 1109
     ff_mpv_common_defaults(s);
1110 1110
 }
1111 1111
 
1112
+void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx)
1113
+{
1114
+    s->avctx           = avctx;
1115
+    s->width           = avctx->coded_width;
1116
+    s->height          = avctx->coded_height;
1117
+    s->codec_id        = avctx->codec->id;
1118
+    s->workaround_bugs = avctx->workaround_bugs;
1119
+    s->flags           = avctx->flags;
1120
+    s->flags2          = avctx->flags2;
1121
+
1122
+}
1123
+
1112 1124
 static int init_er(MpegEncContext *s)
1113 1125
 {
1114 1126
     ERContext *er = &s->er;
... ...
@@ -726,6 +726,7 @@ int ff_mpv_common_frame_size_change(MpegEncContext *s);
726 726
 void ff_mpv_common_end(MpegEncContext *s);
727 727
 
728 728
 void ff_mpv_decode_defaults(MpegEncContext *s);
729
+void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx);
729 730
 void ff_mpv_decode_mb(MpegEncContext *s, int16_t block[12][64]);
730 731
 void ff_mpv_report_decode_progress(MpegEncContext *s);
731 732
 
... ...
@@ -475,10 +475,9 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
475 475
         return ret;
476 476
 
477 477
     ff_mpv_decode_defaults(s);
478
+    ff_mpv_decode_init(s, avctx);
478 479
 
479
-    s->avctx       = avctx;
480 480
     s->out_format  = FMT_H263;
481
-    s->codec_id    = avctx->codec_id;
482 481
 
483 482
     rv->orig_width  =
484 483
     s->width        = avctx->coded_width;
... ...
@@ -1490,14 +1490,9 @@ av_cold int ff_rv34_decode_init(AVCodecContext *avctx)
1490 1490
     int ret;
1491 1491
 
1492 1492
     ff_mpv_decode_defaults(s);
1493
-    s->avctx      = avctx;
1493
+    ff_mpv_decode_init(s, avctx);
1494 1494
     s->out_format = FMT_H263;
1495
-    s->codec_id   = avctx->codec_id;
1496 1495
 
1497
-    s->width  = avctx->width;
1498
-    s->height = avctx->height;
1499
-
1500
-    r->s.avctx = avctx;
1501 1496
     avctx->pix_fmt = AV_PIX_FMT_YUV420P;
1502 1497
     avctx->has_b_frames = 1;
1503 1498
     s->low_delay = 0;