aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mpegvideo_enc.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2024-05-12 21:05:58 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2024-06-20 18:58:38 +0200
commitb1a31b32abc19df329cf61fa23febd8252978fd3 (patch)
tree07244fcca00e9d7b2045c90993510c6a5bd62673 /libavcodec/mpegvideo_enc.c
parentcd2e46a3508d123db9d235b71dd06d495d1eecde (diff)
downloadffmpeg-b1a31b32abc19df329cf61fa23febd8252978fd3.tar.gz
avcodec/me_cmp,dvenc,mpegvideo: Move ildct_cmp to its users
MECmpContext.ildct_cmp is an array of function pointers that are not set by ff_me_cmp_init(), but that are set by users to one of the other arrays via ff_set_cmp(). Remove these pointers from MECmpContext and add pointers for the actually used functions to its users. (The DV encoder already did so.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/mpegvideo_enc.c')
-rw-r--r--libavcodec/mpegvideo_enc.c49
1 files changed, 25 insertions, 24 deletions
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 6ec8fa2e0b..6059bdee11 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -319,6 +319,15 @@ static av_cold int me_cmp_init(MpegEncContext *s, AVCodecContext *avctx)
if (ret < 0)
return ret;
s->frame_skip_cmp_fn = me_cmp[1];
+ if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
+ ret = ff_set_cmp(&s->mecc, me_cmp, avctx->ildct_cmp);
+ if (ret < 0)
+ return ret;
+ if (!me_cmp[0] || !me_cmp[4])
+ return AVERROR(EINVAL);
+ s->ildct_cmp[0] = me_cmp[0];
+ s->ildct_cmp[1] = me_cmp[4];
+ }
return 0;
}
@@ -929,14 +938,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
s->quant_precision = 5;
- if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
- ret = ff_set_cmp(&s->mecc, s->mecc.ildct_cmp, avctx->ildct_cmp);
- if (ret < 0)
- return ret;
- if (!s->mecc.ildct_cmp[0] || !s->mecc.ildct_cmp[4])
- return AVERROR(EINVAL);
- }
-
if (CONFIG_H263_ENCODER && s->out_format == FMT_H263) {
ff_h263_encode_init(s);
#if CONFIG_MSMPEG4ENC
@@ -2209,15 +2210,15 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s,
int progressive_score, interlaced_score;
s->interlaced_dct = 0;
- progressive_score = s->mecc.ildct_cmp[4](s, ptr_y, NULL, wrap_y, 8) +
- s->mecc.ildct_cmp[4](s, ptr_y + wrap_y * 8,
- NULL, wrap_y, 8) - 400;
+ progressive_score = s->ildct_cmp[1](s, ptr_y, NULL, wrap_y, 8) +
+ s->ildct_cmp[1](s, ptr_y + wrap_y * 8,
+ NULL, wrap_y, 8) - 400;
if (progressive_score > 0) {
- interlaced_score = s->mecc.ildct_cmp[4](s, ptr_y,
- NULL, wrap_y * 2, 8) +
- s->mecc.ildct_cmp[4](s, ptr_y + wrap_y,
- NULL, wrap_y * 2, 8);
+ interlaced_score = s->ildct_cmp[1](s, ptr_y,
+ NULL, wrap_y * 2, 8) +
+ s->ildct_cmp[1](s, ptr_y + wrap_y,
+ NULL, wrap_y * 2, 8);
if (progressive_score > interlaced_score) {
s->interlaced_dct = 1;
@@ -2288,20 +2289,20 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s,
int progressive_score, interlaced_score;
s->interlaced_dct = 0;
- progressive_score = s->mecc.ildct_cmp[0](s, dest_y, ptr_y, wrap_y, 8) +
- s->mecc.ildct_cmp[0](s, dest_y + wrap_y * 8,
- ptr_y + wrap_y * 8,
- wrap_y, 8) - 400;
+ progressive_score = s->ildct_cmp[0](s, dest_y, ptr_y, wrap_y, 8) +
+ s->ildct_cmp[0](s, dest_y + wrap_y * 8,
+ ptr_y + wrap_y * 8,
+ wrap_y, 8) - 400;
if (s->avctx->ildct_cmp == FF_CMP_VSSE)
progressive_score -= 400;
if (progressive_score > 0) {
- interlaced_score = s->mecc.ildct_cmp[0](s, dest_y, ptr_y,
- wrap_y * 2, 8) +
- s->mecc.ildct_cmp[0](s, dest_y + wrap_y,
- ptr_y + wrap_y,
- wrap_y * 2, 8);
+ interlaced_score = s->ildct_cmp[0](s, dest_y, ptr_y,
+ wrap_y * 2, 8) +
+ s->ildct_cmp[0](s, dest_y + wrap_y,
+ ptr_y + wrap_y,
+ wrap_y * 2, 8);
if (progressive_score > interlaced_score) {
s->interlaced_dct = 1;