History

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.)

Andreas Rheinhardt committed 2 years ago

Commit b1a31b31 parent cd2e46a5 files · +31 −30Browse files

Showing the changes to libavcodec (4 of 5 files). Show all

Unified · Split

4 files
  1. libavcodec/dvenc.c +4 −3
  2. libavcodec/me_cmp.h +0 −2
  3. libavcodec/mpegvideo.h +2 −0
  4. libavcodec/mpegvideo_enc.c +25 −24
libavcodec/dvenc.c+4−3
@@ -96,15 +96,16 @@ static av_cold int dvvideo_encode_init(AVCodecContext *avctx) · 95 unmodified lines
96 96
97 if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {97 if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
98 MECmpContext mecc;98 MECmpContext mecc;
99 me_cmp_func ildct_cmp[6];
99 100
100 memset(&mecc,0, sizeof(mecc));101 memset(&mecc,0, sizeof(mecc));
101 ff_me_cmp_init(&mecc, avctx);102 ff_me_cmp_init(&mecc, avctx);
102 ret = ff_set_cmp(&mecc, mecc.ildct_cmp, avctx->ildct_cmp);103 ret = ff_set_cmp(&mecc, ildct_cmp, avctx->ildct_cmp);
103 if (ret < 0)104 if (ret < 0)
104 return ret;105 return ret;
105 if (!mecc.ildct_cmp[5])106 if (!ildct_cmp[5])
106 return AVERROR(EINVAL);107 return AVERROR(EINVAL);
107 s->ildct_cmp = mecc.ildct_cmp[5];108 s->ildct_cmp = ildct_cmp[5];
108 }109 }
109 110
110 memset(&fdsp,0, sizeof(fdsp));111 memset(&fdsp,0, sizeof(fdsp));
libavcodec/me_cmp.h+0−2
@@ -70,8 +70,6 @@ typedef struct MECmpContext { · 69 unmodified lines
70 me_cmp_func dct_max[6];70 me_cmp_func dct_max[6];
71 me_cmp_func dct264_sad[6];71 me_cmp_func dct264_sad[6];
72 72
73 me_cmp_func ildct_cmp[6]; // only width 16 used
74
75 me_cmp_func pix_abs[2][4];73 me_cmp_func pix_abs[2][4];
76 me_cmp_func median_sad[6];74 me_cmp_func median_sad[6];
77} MECmpContext;75} MECmpContext;
libavcodec/mpegvideo.h+2−0
@@ -506,6 +506,8 @@ typedef struct MpegEncContext { · 505 unmodified lines
506 int mpv_flags; ///< flags set by private options506 int mpv_flags; ///< flags set by private options
507 int quantizer_noise_shaping;507 int quantizer_noise_shaping;
508 508
509 me_cmp_func ildct_cmp[2]; ///< 0 = intra, 1 = non-intra
510
509 /**511 /**
510 * ratecontrol qmin qmax limiting method512 * ratecontrol qmin qmax limiting method
511 * 0-> clipping, 1-> use a nice continuous function to limit qscale within qmin/qmax.513 * 0-> clipping, 1-> use a nice continuous function to limit qscale within qmin/qmax.
libavcodec/mpegvideo_enc.c+25−24
@@ -319,6 +319,15 @@ static av_cold int me_cmp_init(MpegEncContext *s, AVCodecContext *avctx) · 318 unmodified lines
319 if (ret < 0)319 if (ret < 0)
320 return ret;320 return ret;
321 s->frame_skip_cmp_fn = me_cmp[1];321 s->frame_skip_cmp_fn = me_cmp[1];
322 if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
323 ret = ff_set_cmp(&s->mecc, me_cmp, avctx->ildct_cmp);
324 if (ret < 0)
325 return ret;
326 if (!me_cmp[0] || !me_cmp[4])
327 return AVERROR(EINVAL);
328 s->ildct_cmp[0] = me_cmp[0];
329 s->ildct_cmp[1] = me_cmp[4];
330 }
322 331
323 return 0;332 return 0;
324}333}
@@ -929,14 +938,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) · 604 unmodified lines
929 938
930 s->quant_precision = 5;939 s->quant_precision = 5;
931 940
932 if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
933 ret = ff_set_cmp(&s->mecc, s->mecc.ildct_cmp, avctx->ildct_cmp);
934 if (ret < 0)
935 return ret;
936 if (!s->mecc.ildct_cmp[0] || !s->mecc.ildct_cmp[4])
937 return AVERROR(EINVAL);
938 }
939
940 if (CONFIG_H263_ENCODER && s->out_format == FMT_H263) {941 if (CONFIG_H263_ENCODER && s->out_format == FMT_H263) {
941 ff_h263_encode_init(s);942 ff_h263_encode_init(s);
942#if CONFIG_MSMPEG4ENC943#if CONFIG_MSMPEG4ENC
@@ -2209,15 +2210,15 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, · 1266 unmodified lines
2209 int progressive_score, interlaced_score;2210 int progressive_score, interlaced_score;
2210 2211
2211 s->interlaced_dct = 0;2212 s->interlaced_dct = 0;
2212 progressive_score = s->mecc.ildct_cmp[4](s, ptr_y, NULL, wrap_y, 8) +2213 progressive_score = s->ildct_cmp[1](s, ptr_y, NULL, wrap_y, 8) +
2213 s->mecc.ildct_cmp[4](s, ptr_y + wrap_y * 8,2214 s->ildct_cmp[1](s, ptr_y + wrap_y * 8,
2214 NULL, wrap_y, 8) - 400;2215 NULL, wrap_y, 8) - 400;
2215 2216
2216 if (progressive_score > 0) {2217 if (progressive_score > 0) {
2217 interlaced_score = s->mecc.ildct_cmp[4](s, ptr_y,2218 interlaced_score = s->ildct_cmp[1](s, ptr_y,
2218 NULL, wrap_y * 2, 8) +2219 NULL, wrap_y * 2, 8) +
2219 s->mecc.ildct_cmp[4](s, ptr_y + wrap_y,2220 s->ildct_cmp[1](s, ptr_y + wrap_y,
2220 NULL, wrap_y * 2, 8);2221 NULL, wrap_y * 2, 8);
2221 if (progressive_score > interlaced_score) {2222 if (progressive_score > interlaced_score) {
2222 s->interlaced_dct = 1;2223 s->interlaced_dct = 1;
2223 2224
@@ -2288,20 +2289,20 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, · 64 unmodified lines
2288 int progressive_score, interlaced_score;2289 int progressive_score, interlaced_score;
2289 2290
2290 s->interlaced_dct = 0;2291 s->interlaced_dct = 0;
2291 progressive_score = s->mecc.ildct_cmp[0](s, dest_y, ptr_y, wrap_y, 8) +2292 progressive_score = s->ildct_cmp[0](s, dest_y, ptr_y, wrap_y, 8) +
2292 s->mecc.ildct_cmp[0](s, dest_y + wrap_y * 8,2293 s->ildct_cmp[0](s, dest_y + wrap_y * 8,
2293 ptr_y + wrap_y * 8,2294 ptr_y + wrap_y * 8,
2294 wrap_y, 8) - 400;2295 wrap_y, 8) - 400;
2295 2296
2296 if (s->avctx->ildct_cmp == FF_CMP_VSSE)2297 if (s->avctx->ildct_cmp == FF_CMP_VSSE)
2297 progressive_score -= 400;2298 progressive_score -= 400;
2298 2299
2299 if (progressive_score > 0) {2300 if (progressive_score > 0) {
2300 interlaced_score = s->mecc.ildct_cmp[0](s, dest_y, ptr_y,2301 interlaced_score = s->ildct_cmp[0](s, dest_y, ptr_y,
2301 wrap_y * 2, 8) +2302 wrap_y * 2, 8) +
2302 s->mecc.ildct_cmp[0](s, dest_y + wrap_y,2303 s->ildct_cmp[0](s, dest_y + wrap_y,
2303 ptr_y + wrap_y,2304 ptr_y + wrap_y,
2304 wrap_y * 2, 8);2305 wrap_y * 2, 8);
2305 2306
2306 if (progressive_score > interlaced_score) {2307 if (progressive_score > interlaced_score) {
2307 s->interlaced_dct = 1;2308 s->interlaced_dct = 1;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t