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
9696
9797 if (avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
9898 MECmpContext mecc;
99+ me_cmp_func ildct_cmp[6];
99100
100101 memset(&mecc,0, sizeof(mecc));
101102 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);
103104 if (ret < 0)
104105 return ret;
105− if (!mecc.ildct_cmp[5])
106+ if (!ildct_cmp[5])
106107 return AVERROR(EINVAL);
107− s->ildct_cmp = mecc.ildct_cmp[5];
108+ s->ildct_cmp = ildct_cmp[5];
108109 }
109110
110111 memset(&fdsp,0, sizeof(fdsp));
libavcodec/me_cmp.h+0−2
@@ -70,8 +70,6 @@ typedef struct MECmpContext { · 69 unmodified lines
7070 me_cmp_func dct_max[6];
7171 me_cmp_func dct264_sad[6];
7272
73− me_cmp_func ildct_cmp[6]; // only width 16 used
74−
7573 me_cmp_func pix_abs[2][4];
7674 me_cmp_func median_sad[6];
7775 } MECmpContext;
libavcodec/mpegvideo.h+2−0
@@ -506,6 +506,8 @@ typedef struct MpegEncContext { · 505 unmodified lines
506506 int mpv_flags; ///< flags set by private options
507507 int quantizer_noise_shaping;
508508
509+ me_cmp_func ildct_cmp[2]; ///< 0 = intra, 1 = non-intra
510+
509511 /**
510512 * ratecontrol qmin qmax limiting method
511513 * 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
319319 if (ret < 0)
320320 return ret;
321321 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+ }
322331
323332 return 0;
324333 }
@@ -929,14 +938,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) · 604 unmodified lines
929938
930939 s->quant_precision = 5;
931940
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−
940941 if (CONFIG_H263_ENCODER && s->out_format == FMT_H263) {
941942 ff_h263_encode_init(s);
942943 #if CONFIG_MSMPEG4ENC
@@ -2209,15 +2210,15 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, · 1266 unmodified lines
22092210 int progressive_score, interlaced_score;
22102211
22112212 s->interlaced_dct = 0;
2212− progressive_score = s->mecc.ildct_cmp[4](s, ptr_y, NULL, wrap_y, 8) +
2213− s->mecc.ildct_cmp[4](s, ptr_y + wrap_y * 8,
2214− NULL, wrap_y, 8) - 400;
2213+ progressive_score = s->ildct_cmp[1](s, ptr_y, NULL, wrap_y, 8) +
2214+ s->ildct_cmp[1](s, ptr_y + wrap_y * 8,
2215+ NULL, wrap_y, 8) - 400;
22152216
22162217 if (progressive_score > 0) {
2217− interlaced_score = s->mecc.ildct_cmp[4](s, ptr_y,
2218− NULL, wrap_y * 2, 8) +
2219− s->mecc.ildct_cmp[4](s, ptr_y + wrap_y,
2220− NULL, wrap_y * 2, 8);
2218+ interlaced_score = s->ildct_cmp[1](s, ptr_y,
2219+ NULL, wrap_y * 2, 8) +
2220+ s->ildct_cmp[1](s, ptr_y + wrap_y,
2221+ NULL, wrap_y * 2, 8);
22212222 if (progressive_score > interlaced_score) {
22222223 s->interlaced_dct = 1;
22232224
@@ -2288,20 +2289,20 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, · 64 unmodified lines
22882289 int progressive_score, interlaced_score;
22892290
22902291 s->interlaced_dct = 0;
2291− progressive_score = s->mecc.ildct_cmp[0](s, dest_y, ptr_y, wrap_y, 8) +
2292− s->mecc.ildct_cmp[0](s, dest_y + wrap_y * 8,
2293− ptr_y + wrap_y * 8,
2294− wrap_y, 8) - 400;
2292+ progressive_score = s->ildct_cmp[0](s, dest_y, ptr_y, wrap_y, 8) +
2293+ s->ildct_cmp[0](s, dest_y + wrap_y * 8,
2294+ ptr_y + wrap_y * 8,
2295+ wrap_y, 8) - 400;
22952296
22962297 if (s->avctx->ildct_cmp == FF_CMP_VSSE)
22972298 progressive_score -= 400;
22982299
22992300 if (progressive_score > 0) {
2300− interlaced_score = s->mecc.ildct_cmp[0](s, dest_y, ptr_y,
2301− wrap_y * 2, 8) +
2302− s->mecc.ildct_cmp[0](s, dest_y + wrap_y,
2303− ptr_y + wrap_y,
2304− wrap_y * 2, 8);
2301+ interlaced_score = s->ildct_cmp[0](s, dest_y, ptr_y,
2302+ wrap_y * 2, 8) +
2303+ s->ildct_cmp[0](s, dest_y + wrap_y,
2304+ ptr_y + wrap_y,
2305+ wrap_y * 2, 8);
23052306
23062307 if (progressive_score > interlaced_score) {
23072308 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