[FFmpeg-cvslog] avcodec/vc1dec: Remove VC-1 decoders->H.263 decoder dependency
Andreas Rheinhardt
git at videolan.org
Sun Nov 6 18:51:07 EET 2022
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Tue Nov 1 21:03:40 2022 +0100| [496b3c6987cfb4dfde6f59fa5da12be8c82c13ab] | committer: Andreas Rheinhardt
avcodec/vc1dec: Remove VC-1 decoders->H.263 decoder dependency
The only thing from the H.263 decoder that is reachable
by the VC-1 decoder is ff_h263_decode_init(); but it does
not even use all of it; e.g. h263dsp is unused and so are
the VLCs initialized in ff_h263_decode_init() (they amount
to about 77KB which are now no longer touched).
Notice that one could also call ff_idctdsp_init()
directly instead of ff_mpv_idct_init(); one could even
do so in ff_vc1_init_common().
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=496b3c6987cfb4dfde6f59fa5da12be8c82c13ab
---
configure | 2 +-
libavcodec/h263dec.c | 12 ------------
libavcodec/vc1dec.c | 32 ++++++++++++++++++++++++++++++--
3 files changed, 31 insertions(+), 15 deletions(-)
diff --git a/configure b/configure
index 28066b710c..c54dd2dda5 100755
--- a/configure
+++ b/configure
@@ -2970,7 +2970,7 @@ utvideo_encoder_select="bswapdsp huffman llvidencdsp"
vble_decoder_select="llviddsp"
vbn_decoder_select="texturedsp"
vbn_encoder_select="texturedspenc"
-vc1_decoder_select="blockdsp h263_decoder h264qpel intrax8 mpegvideodec vc1dsp"
+vc1_decoder_select="blockdsp h264qpel intrax8 mpegvideodec qpeldsp vc1dsp"
vc1image_decoder_select="vc1_decoder"
vorbis_encoder_select="audio_frame_queue"
vp3_decoder_select="hpeldsp vp3dsp videodsp"
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 5f5ecfdddc..da3c9899e3 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -63,9 +63,6 @@ static enum AVPixelFormat h263_get_format(AVCodecContext *avctx)
return avctx->pix_fmt;
}
- if (avctx->codec->id == AV_CODEC_ID_MSS2)
- return AV_PIX_FMT_YUV420P;
-
if (CONFIG_GRAY && (avctx->flags & AV_CODEC_FLAG_GRAY)) {
if (avctx->color_range == AVCOL_RANGE_UNSPECIFIED)
avctx->color_range = AVCOL_RANGE_MPEG;
@@ -117,15 +114,6 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
s->h263_pred = 1;
s->msmpeg4_version = 5;
break;
- case AV_CODEC_ID_VC1:
- case AV_CODEC_ID_WMV3:
- case AV_CODEC_ID_VC1IMAGE:
- case AV_CODEC_ID_WMV3IMAGE:
- case AV_CODEC_ID_MSS2:
- s->h263_pred = 1;
- s->msmpeg4_version = 6;
- avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
- break;
case AV_CODEC_ID_H263I:
break;
case AV_CODEC_ID_FLV1:
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index e7ad540d84..5cb4c544c9 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -405,6 +405,20 @@ static av_cold int vc1_decode_init_alloc_tables(VC1Context *v)
return 0;
}
+static enum AVPixelFormat vc1_get_format(AVCodecContext *avctx)
+{
+ if (avctx->codec_id == AV_CODEC_ID_MSS2)
+ return AV_PIX_FMT_YUV420P;
+
+ if (CONFIG_GRAY && (avctx->flags & AV_CODEC_FLAG_GRAY)) {
+ if (avctx->color_range == AVCOL_RANGE_UNSPECIFIED)
+ avctx->color_range = AVCOL_RANGE_MPEG;
+ return AV_PIX_FMT_GRAY8;
+ }
+
+ return ff_get_format(avctx, avctx->codec->pix_fmts);
+}
+
av_cold int ff_vc1_decode_init(AVCodecContext *avctx)
{
VC1Context *const v = avctx->priv_data;
@@ -415,7 +429,12 @@ av_cold int ff_vc1_decode_init(AVCodecContext *avctx)
if (ret < 0)
return ret;
- ret = ff_h263_decode_init(avctx);
+ ff_mpv_decode_init(s, avctx);
+ ff_mpv_idct_init(s);
+
+ avctx->pix_fmt = vc1_get_format(avctx);
+
+ ret = ff_mpv_common_init(s);
if (ret < 0)
return ret;
@@ -578,13 +597,23 @@ static av_cold void vc1_init_static(void)
av_cold void ff_vc1_init_common(VC1Context *v)
{
static AVOnce init_static_once = AV_ONCE_INIT;
+ MpegEncContext *const s = &v->s;
/* defaults */
v->pq = -1;
v->mvrange = 0; /* 7.1.1.18, p80 */
+ s->avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
+ s->out_format = FMT_H263;
+
+ s->h263_pred = 1;
+ s->msmpeg4_version = 6;
+
ff_vc1dsp_init(&v->vc1dsp);
+ /* For error resilience */
+ ff_qpeldsp_init(&s->qdsp);
+
/* VLC tables */
ff_thread_once(&init_static_once, vc1_init_static);
}
@@ -702,7 +731,6 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
ff_blockdsp_init(&s->bdsp);
ff_h264chroma_init(&v->h264chroma, 8);
- ff_qpeldsp_init(&s->qdsp);
avctx->has_b_frames = !!avctx->max_b_frames;
More information about the ffmpeg-cvslog
mailing list