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

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

Unified · Split

3 files
  1. libavcodec/me_cmp.h +0 −1
  2. libavcodec/mpegvideo.h +1 −0
  3. libavcodec/mpegvideo_enc.c +6 −4
libavcodec/me_cmp.h+0−1
@@ -71,7 +71,6 @@ typedef struct MECmpContext { · 70 unmodified lines
7171 me_cmp_func dct264_sad[6];
7272
7373 me_cmp_func ildct_cmp[6]; // only width 16 used
74− me_cmp_func frame_skip_cmp[6]; // only width 8 used
7574
7675 me_cmp_func pix_abs[2][4];
7776 me_cmp_func median_sad[6];
libavcodec/mpegvideo.h+1−0
@@ -542,6 +542,7 @@ typedef struct MpegEncContext { · 541 unmodified lines
542542 int frame_skip_factor;
543543 int frame_skip_exp;
544544 int frame_skip_cmp;
545+ me_cmp_func frame_skip_cmp_fn;
545546
546547 int scenechange_threshold;
547548 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
308308
309309 static av_cold int me_cmp_init(MpegEncContext *s, AVCodecContext *avctx)
310310 {
311+ me_cmp_func me_cmp[6];
311312 int ret;
312313
313314 ff_me_cmp_init(&s->mecc, avctx);
314315 ret = ff_me_init(&s->me, avctx, &s->mecc);
315316 if (ret < 0)
316317 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];
317322
318323 return 0;
319324 }
@@ -931,9 +936,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) · 611 unmodified lines
931936 if (!s->mecc.ildct_cmp[0] || !s->mecc.ildct_cmp[4])
932937 return AVERROR(EINVAL);
933938 }
934− ret = ff_set_cmp(&s->mecc, s->mecc.frame_skip_cmp, s->frame_skip_cmp);
935− if (ret < 0)
936− return AVERROR(EINVAL);
937939
938940 if (CONFIG_H263_ENCODER && s->out_format == FMT_H263) {
939941 ff_h263_encode_init(s);
@@ -1311,7 +1313,7 @@ static int skip_check(MpegEncContext *s, const MPVPicture *p, const MPVPicture * · 371 unmodified lines
13111313 int off = p->shared ? 0 : 16;
13121314 const uint8_t *dptr = p->f->data[plane] + 8 * (x + y * stride) + off;
13131315 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);
13151317
13161318 switch (FFABS(s->frame_skip_exp)) {
13171319 case 0: score = FFMAX(score, v); break;

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