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
352 mv_codes[0][1] = 1;352 mv_codes[0][1] = 1;
353}353}
354 354
355av_cold int ff_h261_encode_init(MpegEncContext *s)355static av_cold int h261_encode_init(AVCodecContext *avctx)
356{356{
357 H261EncContext *const h = (H261EncContext*)s;
358 static AVOnce init_static_once = AV_ONCE_INIT;357 static AVOnce init_static_once = AV_ONCE_INIT;
358 H261EncContext *const h = avctx->priv_data;
359 MpegEncContext *const s = &h->s.s;
359 360
360 if (s->width == 176 && s->height == 144) {361 if (avctx->width == 176 && avctx->height == 144) {
361 h->format = H261_QCIF;362 h->format = H261_QCIF;
362 } else if (s->width == 352 && s->height == 288) {363 } else if (avctx->width == 352 && avctx->height == 288) {
363 h->format = H261_CIF;364 h->format = H261_CIF;
364 } else {365 } else {
365 av_log(s->avctx, AV_LOG_ERROR,366 av_log(avctx, AV_LOG_ERROR,
366 "The specified picture size of %dx%d is not valid for the "367 "The specified picture size of %dx%d is not valid for the "
367 "H.261 codec.\nValid sizes are 176x144, 352x288\n",368 "H.261 codec.\nValid sizes are 176x144, 352x288\n",
368 s->width, s->height);369 avctx->width, avctx->height);
369 return AVERROR(EINVAL);370 return AVERROR(EINVAL);
370 }371 }
371 s->private_ctx = &h->common;372 s->private_ctx = &h->common;
@@ -380,7 +381,7 @@ av_cold int ff_h261_encode_init(MpegEncContext *s) · 8 unmodified lines
380 s->intra_ac_vlc_last_length = s->inter_ac_vlc_last_length = uni_h261_rl_len_last;381 s->intra_ac_vlc_last_length = s->inter_ac_vlc_last_length = uni_h261_rl_len_last;
381 ff_thread_once(&init_static_once, h261_encode_init_static);382 ff_thread_once(&init_static_once, h261_encode_init_static);
382 383
383 return 0;384 return ff_mpv_encode_init(avctx);
384}385}
385 386
386const FFCodec ff_h261_encoder = {387const FFCodec ff_h261_encoder = {
@@ -391,7 +392,7 @@ const FFCodec ff_h261_encoder = { · 4 unmodified lines
391 .p.priv_class = &ff_mpv_enc_class,392 .p.priv_class = &ff_mpv_enc_class,
392 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,393 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
393 .priv_data_size = sizeof(H261EncContext),394 .priv_data_size = sizeof(H261EncContext),
394 .init = ff_mpv_encode_init,395 .init = h261_encode_init,
395 FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),396 FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
396 .close = ff_mpv_encode_end,397 .close = ff_mpv_encode_end,
397 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,398 .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
34void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64],34void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64],
35 int motion_x, int motion_y);35 int motion_x, int motion_y);
36void ff_h261_encode_picture_header(MpegEncContext *s);36void ff_h261_encode_picture_header(MpegEncContext *s);
37int ff_h261_encode_init(MpegEncContext *s);
38 37
39#endif38#endif
libavcodec/mpegvideo_enc.c+0−5
@@ -778,11 +778,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) · 777 unmodified lines
778 s->low_delay = 1;778 s->low_delay = 1;
779 break;779 break;
780 case AV_CODEC_ID_H261:780 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;
786 s->out_format = FMT_H261;781 s->out_format = FMT_H261;
787 avctx->delay = 0;782 avctx->delay = 0;
788 s->low_delay = 1;783 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