[FFmpeg-cvslog] fftools/ffmpeg_enc: inline init_encoder_time_base() into its callers
Anton Khirnov
git at videolan.org
Mon Jun 5 17:31:09 EEST 2023
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sun May 28 18:16:53 2023 +0200| [2f92650c5d8b23f5935285d18567d1ddf3150a96] | committer: Anton Khirnov
fftools/ffmpeg_enc: inline init_encoder_time_base() into its callers
The function now reduces to a ternary operator, so it is shorter and
clearer to eliminate it.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2f92650c5d8b23f5935285d18567d1ddf3150a96
---
fftools/ffmpeg_enc.c | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index 04d2c3c201..4a5ae3aa1b 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -177,18 +177,6 @@ static void set_encoder_id(OutputFile *of, OutputStream *ost)
AV_DICT_DONT_STRDUP_VAL | AV_DICT_DONT_OVERWRITE);
}
-static void init_encoder_time_base(OutputStream *ost, AVRational default_time_base)
-{
- AVCodecContext *enc_ctx = ost->enc_ctx;
-
- if (ost->enc_timebase.num > 0) {
- enc_ctx->time_base = ost->enc_timebase;
- return;
- }
-
- enc_ctx->time_base = default_time_base;
-}
-
int enc_open(OutputStream *ost, AVFrame *frame)
{
InputStream *ist = ost->ist;
@@ -222,7 +210,8 @@ int enc_open(OutputStream *ost, AVFrame *frame)
enc_ctx->bits_per_raw_sample = FFMIN(dec_ctx->bits_per_raw_sample,
av_get_bytes_per_sample(enc_ctx->sample_fmt) << 3);
- init_encoder_time_base(ost, av_make_q(1, enc_ctx->sample_rate));
+ enc_ctx->time_base = ost->enc_timebase.num > 0 ? ost->enc_timebase :
+ av_make_q(1, enc_ctx->sample_rate);
break;
case AVMEDIA_TYPE_VIDEO:
@@ -252,7 +241,8 @@ int enc_open(OutputStream *ost, AVFrame *frame)
ost->frame_rate.num, ost->frame_rate.den, 65535);
}
- init_encoder_time_base(ost, av_inv_q(ost->frame_rate));
+ enc_ctx->time_base = ost->enc_timebase.num > 0 ? ost->enc_timebase :
+ av_inv_q(ost->frame_rate);
if (!(enc_ctx->time_base.num && enc_ctx->time_base.den))
enc_ctx->time_base = av_buffersink_get_time_base(ost->filter->filter);
More information about the ffmpeg-cvslog
mailing list