aboutsummaryrefslogtreecommitdiffstats
path: root/fftools
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-05-28 18:16:53 +0200
committerAnton Khirnov <anton@khirnov.net>2023-06-05 16:15:04 +0200
commit2f92650c5d8b23f5935285d18567d1ddf3150a96 (patch)
treeedc2e238aa48984bc5e8f39b78944b69f7d9c161 /fftools
parent93e26a4db7784ca1372022ce7fea4a103eaf9a47 (diff)
downloadffmpeg-2f92650c5d8b23f5935285d18567d1ddf3150a96.tar.gz
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.
Diffstat (limited to 'fftools')
-rw-r--r--fftools/ffmpeg_enc.c18
1 files 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);