History

avcodec/me_cmp, mpegvideo: Move frame_skip_cmp to MpegEncContext

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.

Andreas Rheinhardt committed 2 years ago

Commit cd2e46a1 parent 182e6474 files · +7 −6Browse files

Unified · Split

4 files
  1. libavcodec/me_cmp.h +0 −1
  2. libavcodec/mpegvideo.h +1 −0
  3. libavcodec/mpegvideo_enc.c +6 −4
  4. tests/checkasm/motion.c +0 −1
libavcodec/me_cmp.h+0−1
@@ -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 used73 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];
libavcodec/mpegvideo.h+1−0
@@ -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;
libavcodec/mpegvideo_enc.c+6−4
@@ -308,12 +308,17 @@ av_cold void ff_dct_encode_init(MpegEncContext *s) · 307 unmodified lines
308 308
309static av_cold int me_cmp_init(MpegEncContext *s, AVCodecContext *avctx)309static 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;
tests/checkasm/motion.c+0−1
@@ -95,7 +95,6 @@ static void test_motion(const char *name, me_cmp_func test_func) · 94 unmodified lines
95 XX(vsse) \95 XX(vsse) \
96 XX(nsse) \96 XX(nsse) \
97 XX(ildct_cmp) \97 XX(ildct_cmp) \
98 XX(frame_skip_cmp) \
99 XX(median_sad)98 XX(median_sad)
100 99
101// tests for functions not yet implemented100// tests for functions not yet implemented

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