diff mbox series

[FFmpeg-devel,15/39] avcodec/mpegvideo: Merge ff_mpv_decode_defaults into ff_mpv_decode_init

Message ID 20201210111657.2276739-16-andreas.rheinhardt@gmail.com
State Accepted
Commit 8af82be946186921d8391eff3a82815d75b44b99
Headers show
Series Make mpegvideo encoders init-threadsafe
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Dec. 10, 2020, 11:16 a.m. UTC
These two are always called directly after each other (with the
exception of the calls in mpeg_decode_init() where some irrelevant
modifications of the avctx (which could just as well be done before
ff_mpv_decode_defaults(), because it doesn't have a pointer to the
AVCodecContext at all and therefore can't see these modifications at
all) are performed in between), so merge ff_mpv_decode() in
ff_mpv_decode_init().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/h261dec.c   | 1 -
 libavcodec/h263dec.c   | 1 -
 libavcodec/mpeg12dec.c | 3 ---
 libavcodec/mpegvideo.c | 7 ++-----
 libavcodec/mpegvideo.h | 1 -
 libavcodec/rv10.c      | 1 -
 libavcodec/rv34.c      | 1 -
 7 files changed, 2 insertions(+), 13 deletions(-)

Comments

Anton Khirnov Dec. 30, 2020, 6:04 p.m. UTC | #1
Quoting Andreas Rheinhardt (2020-12-10 12:16:33)
> These two are always called directly after each other (with the
> exception of the calls in mpeg_decode_init() where some irrelevant
> modifications of the avctx (which could just as well be done before
> ff_mpv_decode_defaults(), because it doesn't have a pointer to the
> AVCodecContext at all and therefore can't see these modifications at
> all) are performed in between), so merge ff_mpv_decode() in
                                                        _defaults
> ff_mpv_decode_init().
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---

Otherwise looks very good
diff mbox series

Patch

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 374d17dfba..2dc2fb30f2 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -75,7 +75,6 @@  static av_cold int h261_decode_init(AVCodecContext *avctx)
     MpegEncContext *const s = &h->s;
 
     // set defaults
-    ff_mpv_decode_defaults(s);
     ff_mpv_decode_init(s, avctx);
 
     s->out_format  = FMT_H261;
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 32e26a57de..8b441b2951 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -73,7 +73,6 @@  av_cold int ff_h263_decode_init(AVCodecContext *avctx)
     s->out_format      = FMT_H263;
 
     // set defaults
-    ff_mpv_decode_defaults(s);
     ff_mpv_decode_init(s, avctx);
 
     s->quant_precision = 5;
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 7d797c259a..123ede4704 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1050,8 +1050,6 @@  static av_cold int mpeg_decode_init(AVCodecContext *avctx)
     Mpeg1Context *s    = avctx->priv_data;
     MpegEncContext *s2 = &s->mpeg_enc_ctx;
 
-    ff_mpv_decode_defaults(s2);
-
     if (   avctx->codec_tag != AV_RL32("VCR2")
         && avctx->codec_tag != AV_RL32("BW10"))
         avctx->coded_width = avctx->coded_height = 0; // do not trust dimensions from input
@@ -3099,7 +3097,6 @@  static av_cold int ipu_decode_init(AVCodecContext *avctx)
 
     avctx->pix_fmt = AV_PIX_FMT_YUV420P;
 
-    ff_mpv_decode_defaults(m);
     ff_mpv_decode_init(m, avctx);
     s->m.avctx = avctx;
     ff_mpv_idct_init(m);
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index c28d1adef7..f92792ae98 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -660,17 +660,14 @@  void ff_mpv_common_defaults(MpegEncContext *s)
 }
 
 /**
- * Set the given MpegEncContext to defaults for decoding.
+ * Initialize the given MpegEncContext for decoding.
  * the changed fields will not depend upon
  * the prior state of the MpegEncContext.
  */
-void ff_mpv_decode_defaults(MpegEncContext *s)
+void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx)
 {
     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;
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 974c71b6bd..aa84449c2d 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -694,7 +694,6 @@  void ff_mpv_common_init_mips(MpegEncContext *s);
 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_reconstruct_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 d118515c3b..d5c7480611 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -374,7 +374,6 @@  static av_cold int rv10_decode_init(AVCodecContext *avctx)
                                    avctx->coded_height, 0, avctx)) < 0)
         return ret;
 
-    ff_mpv_decode_defaults(s);
     ff_mpv_decode_init(s, avctx);
 
     s->out_format  = FMT_H263;
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index 13f9b609e2..f8cc837985 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -1487,7 +1487,6 @@  av_cold int ff_rv34_decode_init(AVCodecContext *avctx)
     MpegEncContext *s = &r->s;
     int ret;
 
-    ff_mpv_decode_defaults(s);
     ff_mpv_decode_init(s, avctx);
     s->out_format = FMT_H263;