MECmpContext has several arrays 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(). One of these other users is mpegvideo_enc; it is the only user of MECmpContext.frame_skip_cmp and it only uses one of these function pointers at all. This commit therefore moves this function pointer to MpegEncContext; and removes the array from MECmpContext.
Showing the changes to libavcodec (3 of 4 files). Show all
Unified · Split
| @@ -71,7 +71,6 @@ typedef struct MECmpContext { · 70 unmodified lines | |||
| 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 | 73 | me_cmp_func ildct_cmp[6]; // only width 16 used |
| 74 | me_cmp_func frame_skip_cmp[6]; // only width 8 used | ||
| 75 | 74 | ||
| 76 | me_cmp_func pix_abs[2][4]; | 75 | me_cmp_func pix_abs[2][4]; |
| 77 | me_cmp_func median_sad[6]; | 76 | me_cmp_func median_sad[6]; |
| @@ -542,6 +542,7 @@ typedef struct MpegEncContext { · 541 unmodified lines | |||
| 542 | int frame_skip_factor; | 542 | int frame_skip_factor; |
| 543 | int frame_skip_exp; | 543 | int frame_skip_exp; |
| 544 | int frame_skip_cmp; | 544 | int frame_skip_cmp; |
| 545 | me_cmp_func frame_skip_cmp_fn; | ||
| 545 | 546 | ||
| 546 | int scenechange_threshold; | 547 | int scenechange_threshold; |
| 547 | int noise_reduction; | 548 | int noise_reduction; |
| @@ -308,12 +308,17 @@ av_cold void ff_dct_encode_init(MpegEncContext *s) · 307 unmodified lines | |||
| 308 | 308 | ||
| 309 | static av_cold int me_cmp_init(MpegEncContext *s, AVCodecContext *avctx) | 309 | static av_cold int me_cmp_init(MpegEncContext *s, AVCodecContext *avctx) |
| 310 | { | 310 | { |
| 311 | me_cmp_func me_cmp[6]; | ||
| 311 | int ret; | 312 | int ret; |
| 312 | 313 | ||
| 313 | ff_me_cmp_init(&s->mecc, avctx); | 314 | ff_me_cmp_init(&s->mecc, avctx); |
| 314 | ret = ff_me_init(&s->me, avctx, &s->mecc); | 315 | ret = ff_me_init(&s->me, avctx, &s->mecc); |
| 315 | if (ret < 0) | 316 | if (ret < 0) |
| 316 | return ret; | 317 | return ret; |
| 318 | ret = ff_set_cmp(&s->mecc, me_cmp, s->frame_skip_cmp); | ||
| 319 | if (ret < 0) | ||
| 320 | return ret; | ||
| 321 | s->frame_skip_cmp_fn = me_cmp[1]; | ||
| 317 | 322 | ||
| 318 | return 0; | 323 | return 0; |
| 319 | } | 324 | } |
| @@ -931,9 +936,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) · 611 unmodified lines | |||
| 931 | if (!s->mecc.ildct_cmp[0] || !s->mecc.ildct_cmp[4]) | 936 | if (!s->mecc.ildct_cmp[0] || !s->mecc.ildct_cmp[4]) |
| 932 | return AVERROR(EINVAL); | 937 | return AVERROR(EINVAL); |
| 933 | } | 938 | } |
| 934 | ret = ff_set_cmp(&s->mecc, s->mecc.frame_skip_cmp, s->frame_skip_cmp); | ||
| 935 | if (ret < 0) | ||
| 936 | return AVERROR(EINVAL); | ||
| 937 | 939 | ||
| 938 | if (CONFIG_H263_ENCODER && s->out_format == FMT_H263) { | 940 | if (CONFIG_H263_ENCODER && s->out_format == FMT_H263) { |
| 939 | ff_h263_encode_init(s); | 941 | ff_h263_encode_init(s); |
| @@ -1311,7 +1313,7 @@ static int skip_check(MpegEncContext *s, const MPVPicture *p, const MPVPicture * · 371 unmodified lines | |||
| 1311 | int off = p->shared ? 0 : 16; | 1313 | int off = p->shared ? 0 : 16; |
| 1312 | const uint8_t *dptr = p->f->data[plane] + 8 * (x + y * stride) + off; | 1314 | const uint8_t *dptr = p->f->data[plane] + 8 * (x + y * stride) + off; |
| 1313 | const uint8_t *rptr = ref->f->data[plane] + 8 * (x + y * stride); | 1315 | const uint8_t *rptr = ref->f->data[plane] + 8 * (x + y * stride); |
| 1314 | int v = s->mecc.frame_skip_cmp[1](s, dptr, rptr, stride, 8); | 1316 | int v = s->frame_skip_cmp_fn(s, dptr, rptr, stride, 8); |
| 1315 | 1317 | ||
| 1316 | switch (FFABS(s->frame_skip_exp)) { | 1318 | switch (FFABS(s->frame_skip_exp)) { |
| 1317 | case 0: score = FFMAX(score, v); break; | 1319 | case 0: score = FFMAX(score, v); break; |