diff mbox series

[FFmpeg-devel,11/23] fftools/ffmpeg_enc: inline init_encoder_time_base() into its callers

Message ID 20230531145453.20994-11-anton@khirnov.net
State Accepted
Commit 2f92650c5d8b23f5935285d18567d1ddf3150a96
Headers show
Series [FFmpeg-devel,01/23] fftools/ffmpeg_enc: move nb_frames{dup, drop} globals into OutputStream | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov May 31, 2023, 2:54 p.m. UTC
The function now reduces to a ternary operator, so it is shorter and
clearer to eliminate it.
---
 fftools/ffmpeg_enc.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)
diff mbox series

Patch

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);