diff mbox series

[FFmpeg-devel,07/21] fftools/ffmpeg_hw: inline hwaccel_decode_init() into its caller

Message ID 20230614164908.28712-7-anton@khirnov.net
State Accepted
Commit 25d96ab6c03ce979a14c05ed7a737d345d8d36a1
Headers show
Series [FFmpeg-devel,01/21] fftools/ffmpeg_dec: drop always-0 InputStream.prev_sub.ret | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov June 14, 2023, 4:48 p.m. UTC
The function is now trivial and cannot fail, so all error handling in
its caller can be removed.
---
 fftools/ffmpeg.h     |  2 +-
 fftools/ffmpeg_dec.c | 15 +--------------
 fftools/ffmpeg_hw.c  | 11 +----------
 3 files changed, 3 insertions(+), 25 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 7189629ad4..aeecf92fe6 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -805,7 +805,7 @@  void hw_device_free_all(void);
  */
 AVBufferRef *hw_device_for_filter(void);
 
-int hwaccel_decode_init(AVCodecContext *avctx);
+int hwaccel_retrieve_data(AVCodecContext *avctx, AVFrame *input);
 
 int dec_open(InputStream *ist);
 void dec_free(Decoder **pdec);
diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index 6582917a39..ca9fbb9bd8 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -538,7 +538,6 @@  static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat
 {
     InputStream *ist = s->opaque;
     const enum AVPixelFormat *p;
-    int ret;
 
     for (p = pix_fmts; *p != AV_PIX_FMT_NONE; p++) {
         const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(*p);
@@ -562,19 +561,7 @@  static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat
             }
         }
         if (config && config->device_type == ist->hwaccel_device_type) {
-            ret = hwaccel_decode_init(s);
-            if (ret < 0) {
-                if (ist->hwaccel_id == HWACCEL_GENERIC) {
-                    av_log(NULL, AV_LOG_FATAL,
-                           "%s hwaccel requested for input stream #%d:%d, "
-                           "but cannot be initialized.\n",
-                           av_hwdevice_get_type_name(config->device_type),
-                           ist->file_index, ist->index);
-                    return AV_PIX_FMT_NONE;
-                }
-                continue;
-            }
-
+            ist->hwaccel_retrieve_data = hwaccel_retrieve_data;
             ist->hwaccel_pix_fmt = *p;
             break;
         }
diff --git a/fftools/ffmpeg_hw.c b/fftools/ffmpeg_hw.c
index 4a0b346fe1..46bc7e39c2 100644
--- a/fftools/ffmpeg_hw.c
+++ b/fftools/ffmpeg_hw.c
@@ -297,7 +297,7 @@  void hw_device_free_all(void)
     nb_hw_devices = 0;
 }
 
-static int hwaccel_retrieve_data(AVCodecContext *avctx, AVFrame *input)
+int hwaccel_retrieve_data(AVCodecContext *avctx, AVFrame *input)
 {
     InputStream *ist = avctx->opaque;
     AVFrame *output = NULL;
@@ -339,15 +339,6 @@  fail:
     return err;
 }
 
-int hwaccel_decode_init(AVCodecContext *avctx)
-{
-    InputStream *ist = avctx->opaque;
-
-    ist->hwaccel_retrieve_data = &hwaccel_retrieve_data;
-
-    return 0;
-}
-
 AVBufferRef *hw_device_for_filter(void)
 {
     // Pick the last hardware device if the user doesn't pick the device for