mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-03 05:10:03 +02:00
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>
This commit is contained in:
parent
cd2e46a350
commit
b1a31b32ab
@ -96,15 +96,16 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
|
||||
|
||||
if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
|
||||
MECmpContext mecc;
|
||||
me_cmp_func ildct_cmp[6];
|
||||
|
||||
memset(&mecc,0, sizeof(mecc));
|
||||
ff_me_cmp_init(&mecc, avctx);
|
||||
ret = ff_set_cmp(&mecc, mecc.ildct_cmp, avctx->ildct_cmp);
|
||||
ret = ff_set_cmp(&mecc, ildct_cmp, avctx->ildct_cmp);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (!mecc.ildct_cmp[5])
|
||||
if (!ildct_cmp[5])
|
||||
return AVERROR(EINVAL);
|
||||
s->ildct_cmp = mecc.ildct_cmp[5];
|
||||
s->ildct_cmp = ildct_cmp[5];
|
||||
}
|
||||
|
||||
memset(&fdsp,0, sizeof(fdsp));
|
||||
|
@ -70,8 +70,6 @@ typedef struct MECmpContext {
|
||||
me_cmp_func dct_max[6];
|
||||
me_cmp_func dct264_sad[6];
|
||||
|
||||
me_cmp_func ildct_cmp[6]; // only width 16 used
|
||||
|
||||
me_cmp_func pix_abs[2][4];
|
||||
me_cmp_func median_sad[6];
|
||||
} MECmpContext;
|
||||
|
@ -506,6 +506,8 @@ typedef struct MpegEncContext {
|
||||
int mpv_flags; ///< flags set by private options
|
||||
int quantizer_noise_shaping;
|
||||
|
||||
me_cmp_func ildct_cmp[2]; ///< 0 = intra, 1 = non-intra
|
||||
|
||||
/**
|
||||
* ratecontrol qmin qmax limiting method
|
||||
* 0-> clipping, 1-> use a nice continuous function to limit qscale within qmin/qmax.
|
||||
|
@ -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;
|
||||
|
@ -94,7 +94,6 @@ static void test_motion(const char *name, me_cmp_func test_func)
|
||||
XX(vsad) \
|
||||
XX(vsse) \
|
||||
XX(nsse) \
|
||||
XX(ildct_cmp) \
|
||||
XX(median_sad)
|
||||
|
||||
// tests for functions not yet implemented
|
||||
|
Loading…
Reference in New Issue
Block a user