History

avcodec/h261enc: Make h261_encode_init() call ff_mpv_encode_init()

Right now, ff_mpv_encode_init() is set as FFCodec.init and calls ff_h261_encode_init(). The opposite is more natural and avoids a non-static function.

Andreas Rheinhardt committed 1 year ago

Commit b7ee7991 parent 3275d783 files · +9 −14Browse files

Unified · Split

3 files
  1. libavcodec/h261enc.c +9 −8
  2. libavcodec/h261enc.h +0 −1
  3. libavcodec/mpegvideo_enc.c +0 −5
libavcodec/h261enc.c+9−8
@@ -352,20 +352,21 @@ static av_cold void h261_encode_init_static(void) · 351 unmodified lines
352352 mv_codes[0][1] = 1;
353353 }
354354
355−av_cold int ff_h261_encode_init(MpegEncContext *s)
355+static av_cold int h261_encode_init(AVCodecContext *avctx)
356356 {
357− H261EncContext *const h = (H261EncContext*)s;
358357 static AVOnce init_static_once = AV_ONCE_INIT;
358+ H261EncContext *const h = avctx->priv_data;
359+ MpegEncContext *const s = &h->s.s;
359360
360− if (s->width == 176 && s->height == 144) {
361+ if (avctx->width == 176 && avctx->height == 144) {
361362 h->format = H261_QCIF;
362− } else if (s->width == 352 && s->height == 288) {
363+ } else if (avctx->width == 352 && avctx->height == 288) {
363364 h->format = H261_CIF;
364365 } else {
365− av_log(s->avctx, AV_LOG_ERROR,
366+ av_log(avctx, AV_LOG_ERROR,
366367 "The specified picture size of %dx%d is not valid for the "
367368 "H.261 codec.\nValid sizes are 176x144, 352x288\n",
368− s->width, s->height);
369+ avctx->width, avctx->height);
369370 return AVERROR(EINVAL);
370371 }
371372 s->private_ctx = &h->common;
@@ -380,7 +381,7 @@ av_cold int ff_h261_encode_init(MpegEncContext *s) · 8 unmodified lines
380381 s->intra_ac_vlc_last_length = s->inter_ac_vlc_last_length = uni_h261_rl_len_last;
381382 ff_thread_once(&init_static_once, h261_encode_init_static);
382383
383− return 0;
384+ return ff_mpv_encode_init(avctx);
384385 }
385386
386387 const FFCodec ff_h261_encoder = {
@@ -391,7 +392,7 @@ const FFCodec ff_h261_encoder = { · 4 unmodified lines
391392 .p.priv_class = &ff_mpv_enc_class,
392393 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
393394 .priv_data_size = sizeof(H261EncContext),
394− .init = ff_mpv_encode_init,
395+ .init = h261_encode_init,
395396 FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
396397 .close = ff_mpv_encode_end,
397398 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
libavcodec/h261enc.h+0−1
@@ -34,6 +34,5 @@ void ff_h261_reorder_mb_index(MpegEncContext *s); · 33 unmodified lines
3434 void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64],
3535 int motion_x, int motion_y);
3636 void ff_h261_encode_picture_header(MpegEncContext *s);
37−int ff_h261_encode_init(MpegEncContext *s);
3837
3938 #endif
libavcodec/mpegvideo_enc.c+0−5
@@ -778,11 +778,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) · 777 unmodified lines
778778 s->low_delay = 1;
779779 break;
780780 case AV_CODEC_ID_H261:
781− if (!CONFIG_H261_ENCODER)
782− return AVERROR_ENCODER_NOT_FOUND;
783− ret = ff_h261_encode_init(s);
784− if (ret < 0)
785− return ret;
786781 s->out_format = FMT_H261;
787782 avctx->delay = 0;
788783 s->low_delay = 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