diff mbox series

[FFmpeg-devel,35/36] fftools/ffmpeg_dec: inline decode_audio() into dec_packet()

Message ID 20230517102029.541-35-anton@khirnov.net
State Accepted
Commit 909f5dfae15effe2e4f2fd7e0d1b490c224fde20
Headers show
Series [FFmpeg-devel,01/36] fftools/ffmpeg: shorten a variable name | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 fail Make fate failed

Commit Message

Anton Khirnov May 17, 2023, 10:20 a.m. UTC
The former function is now trivial - it has 3 lines and cannot fail.
---
 fftools/ffmpeg_dec.c | 29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index 4662d0a265..c8f9ba0f0c 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -128,17 +128,6 @@  static void audio_ts_process(InputStream *ist, AVFrame *frame)
     frame->time_base = tb_filter;
 }
 
-static int decode_audio(InputStream *ist, AVFrame *decoded_frame)
-{
-    ist->samples_decoded += decoded_frame->nb_samples;
-
-    audio_ts_process(ist, decoded_frame);
-
-    ist->nb_samples = decoded_frame->nb_samples;
-
-    return 0;
-}
-
 static int64_t video_duration_estimate(const InputStream *ist, const AVFrame *frame)
 {
     const InputFile   *ifile = input_files[ist->file_index];
@@ -463,14 +452,18 @@  int dec_packet(InputStream *ist, const AVPacket *pkt, int no_eof)
 
         frame->time_base = dec->pkt_timebase;
 
-        ret = dec->codec_type == AVMEDIA_TYPE_AUDIO ?
-                decode_audio(ist, frame)            :
-                decode_video(ist, frame);
+        if (dec->codec_type == AVMEDIA_TYPE_AUDIO) {
+            ist->samples_decoded += frame->nb_samples;
+            ist->nb_samples       = frame->nb_samples;
 
-        if (ret < 0) {
-            av_log(NULL, AV_LOG_FATAL, "Error while processing the decoded "
-                   "data for stream #%d:%d\n", ist->file_index, ist->st->index);
-            exit_program(1);
+            audio_ts_process(ist, frame);
+        } else {
+            ret = decode_video(ist, frame);
+            if (ret < 0) {
+                av_log(NULL, AV_LOG_FATAL, "Error while processing the decoded "
+                       "data for stream #%d:%d\n", ist->file_index, ist->st->index);
+                exit_program(1);
+            }
         }
 
         ist->frames_decoded++;