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) {
|
if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
|
||||||
MECmpContext mecc;
|
MECmpContext mecc;
|
||||||
|
me_cmp_func ildct_cmp[6];
|
||||||
|
|
||||||
memset(&mecc,0, sizeof(mecc));
|
memset(&mecc,0, sizeof(mecc));
|
||||||
ff_me_cmp_init(&mecc, avctx);
|
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)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
if (!mecc.ildct_cmp[5])
|
if (!ildct_cmp[5])
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
s->ildct_cmp = mecc.ildct_cmp[5];
|
s->ildct_cmp = ildct_cmp[5];
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&fdsp,0, sizeof(fdsp));
|
memset(&fdsp,0, sizeof(fdsp));
|
||||||
|
@ -70,8 +70,6 @@ typedef struct MECmpContext {
|
|||||||
me_cmp_func dct_max[6];
|
me_cmp_func dct_max[6];
|
||||||
me_cmp_func dct264_sad[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 pix_abs[2][4];
|
||||||
me_cmp_func median_sad[6];
|
me_cmp_func median_sad[6];
|
||||||
} MECmpContext;
|
} MECmpContext;
|
||||||
|
@ -506,6 +506,8 @@ typedef struct MpegEncContext {
|
|||||||
int mpv_flags; ///< flags set by private options
|
int mpv_flags; ///< flags set by private options
|
||||||
int quantizer_noise_shaping;
|
int quantizer_noise_shaping;
|
||||||
|
|
||||||
|
me_cmp_func ildct_cmp[2]; ///< 0 = intra, 1 = non-intra
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ratecontrol qmin qmax limiting method
|
* ratecontrol qmin qmax limiting method
|
||||||
* 0-> clipping, 1-> use a nice continuous function to limit qscale within qmin/qmax.
|
* 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)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
s->frame_skip_cmp_fn = me_cmp[1];
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -929,14 +938,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
|
|||||||
|
|
||||||
s->quant_precision = 5;
|
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) {
|
if (CONFIG_H263_ENCODER && s->out_format == FMT_H263) {
|
||||||
ff_h263_encode_init(s);
|
ff_h263_encode_init(s);
|
||||||
#if CONFIG_MSMPEG4ENC
|
#if CONFIG_MSMPEG4ENC
|
||||||
@ -2209,15 +2210,15 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s,
|
|||||||
int progressive_score, interlaced_score;
|
int progressive_score, interlaced_score;
|
||||||
|
|
||||||
s->interlaced_dct = 0;
|
s->interlaced_dct = 0;
|
||||||
progressive_score = s->mecc.ildct_cmp[4](s, ptr_y, NULL, wrap_y, 8) +
|
progressive_score = s->ildct_cmp[1](s, ptr_y, NULL, wrap_y, 8) +
|
||||||
s->mecc.ildct_cmp[4](s, ptr_y + wrap_y * 8,
|
s->ildct_cmp[1](s, ptr_y + wrap_y * 8,
|
||||||
NULL, wrap_y, 8) - 400;
|
NULL, wrap_y, 8) - 400;
|
||||||
|
|
||||||
if (progressive_score > 0) {
|
if (progressive_score > 0) {
|
||||||
interlaced_score = s->mecc.ildct_cmp[4](s, ptr_y,
|
interlaced_score = s->ildct_cmp[1](s, ptr_y,
|
||||||
NULL, wrap_y * 2, 8) +
|
NULL, wrap_y * 2, 8) +
|
||||||
s->mecc.ildct_cmp[4](s, ptr_y + wrap_y,
|
s->ildct_cmp[1](s, ptr_y + wrap_y,
|
||||||
NULL, wrap_y * 2, 8);
|
NULL, wrap_y * 2, 8);
|
||||||
if (progressive_score > interlaced_score) {
|
if (progressive_score > interlaced_score) {
|
||||||
s->interlaced_dct = 1;
|
s->interlaced_dct = 1;
|
||||||
|
|
||||||
@ -2288,20 +2289,20 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s,
|
|||||||
int progressive_score, interlaced_score;
|
int progressive_score, interlaced_score;
|
||||||
|
|
||||||
s->interlaced_dct = 0;
|
s->interlaced_dct = 0;
|
||||||
progressive_score = s->mecc.ildct_cmp[0](s, dest_y, ptr_y, wrap_y, 8) +
|
progressive_score = s->ildct_cmp[0](s, dest_y, ptr_y, wrap_y, 8) +
|
||||||
s->mecc.ildct_cmp[0](s, dest_y + wrap_y * 8,
|
s->ildct_cmp[0](s, dest_y + wrap_y * 8,
|
||||||
ptr_y + wrap_y * 8,
|
ptr_y + wrap_y * 8,
|
||||||
wrap_y, 8) - 400;
|
wrap_y, 8) - 400;
|
||||||
|
|
||||||
if (s->avctx->ildct_cmp == FF_CMP_VSSE)
|
if (s->avctx->ildct_cmp == FF_CMP_VSSE)
|
||||||
progressive_score -= 400;
|
progressive_score -= 400;
|
||||||
|
|
||||||
if (progressive_score > 0) {
|
if (progressive_score > 0) {
|
||||||
interlaced_score = s->mecc.ildct_cmp[0](s, dest_y, ptr_y,
|
interlaced_score = s->ildct_cmp[0](s, dest_y, ptr_y,
|
||||||
wrap_y * 2, 8) +
|
wrap_y * 2, 8) +
|
||||||
s->mecc.ildct_cmp[0](s, dest_y + wrap_y,
|
s->ildct_cmp[0](s, dest_y + wrap_y,
|
||||||
ptr_y + wrap_y,
|
ptr_y + wrap_y,
|
||||||
wrap_y * 2, 8);
|
wrap_y * 2, 8);
|
||||||
|
|
||||||
if (progressive_score > interlaced_score) {
|
if (progressive_score > interlaced_score) {
|
||||||
s->interlaced_dct = 1;
|
s->interlaced_dct = 1;
|
||||||
|
@ -94,7 +94,6 @@ static void test_motion(const char *name, me_cmp_func test_func)
|
|||||||
XX(vsad) \
|
XX(vsad) \
|
||||||
XX(vsse) \
|
XX(vsse) \
|
||||||
XX(nsse) \
|
XX(nsse) \
|
||||||
XX(ildct_cmp) \
|
|
||||||
XX(median_sad)
|
XX(median_sad)
|
||||||
|
|
||||||
// tests for functions not yet implemented
|
// tests for functions not yet implemented
|
||||||
|
Loading…
x
Reference in New Issue
Block a user