diff options
author | Anton Khirnov <anton@khirnov.net> | 2024-01-23 18:42:20 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2024-01-30 09:52:00 +0100 |
commit | d5f9ef766b4e7958f3cf75c6b838fbe0f22936c5 (patch) | |
tree | 82c098c98ef948b1d27c8939bef9cc36dbac31f0 /fftools/ffmpeg_dec.c | |
parent | 097f9ddbe94039b3c6f888560e24cc1753fec3f3 (diff) | |
download | ffmpeg-d5f9ef766b4e7958f3cf75c6b838fbe0f22936c5.tar.gz |
fftools/ffmpeg_dec: eliminate InputStream use in hw_device_setup_for_decode()
The same information can also be obtained from the decoder itself.
This is a step towards decoupling Decoder and InputStream.
Diffstat (limited to 'fftools/ffmpeg_dec.c')
-rw-r--r-- | fftools/ffmpeg_dec.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index cbb782bf9d..734549ed0b 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -803,7 +803,8 @@ static HWDevice *hw_device_match_by_codec(const AVCodec *codec) } } -static int hw_device_setup_for_decode(InputStream *ist, DecoderPriv *dp, +static int hw_device_setup_for_decode(DecoderPriv *dp, + const AVCodec *codec, const char *hwaccel_device) { const AVCodecHWConfig *config; @@ -858,7 +859,7 @@ static int hw_device_setup_for_decode(InputStream *ist, DecoderPriv *dp, if (!dev) err = hw_device_init_from_type(type, NULL, &dev); } else { - dev = hw_device_match_by_codec(ist->dec); + dev = hw_device_match_by_codec(codec); if (!dev) { // No device for this codec, but not using generic hwaccel // and therefore may well not need one - ignore. @@ -869,12 +870,12 @@ static int hw_device_setup_for_decode(InputStream *ist, DecoderPriv *dp, if (auto_device) { int i; - if (!avcodec_get_hw_config(ist->dec, 0)) { + if (!avcodec_get_hw_config(codec, 0)) { // Decoder does not support any hardware devices. return 0; } for (i = 0; !dev; i++) { - config = avcodec_get_hw_config(ist->dec, i); + config = avcodec_get_hw_config(codec, i); if (!config) break; type = config->device_type; @@ -886,7 +887,7 @@ static int hw_device_setup_for_decode(InputStream *ist, DecoderPriv *dp, } } for (i = 0; !dev; i++) { - config = avcodec_get_hw_config(ist->dec, i); + config = avcodec_get_hw_config(codec, i); if (!config) break; type = config->device_type; @@ -921,7 +922,7 @@ static int hw_device_setup_for_decode(InputStream *ist, DecoderPriv *dp, if (!dev) { av_log(dp, AV_LOG_ERROR, "No device available " "for decoder: device type %s needed for codec %s.\n", - av_hwdevice_get_type_name(type), ist->dec->name); + av_hwdevice_get_type_name(type), codec->name); return err; } @@ -1010,7 +1011,7 @@ int dec_open(InputStream *ist, Scheduler *sch, unsigned sch_idx, av_dict_set(dec_opts, "flags", "+copy_opaque", AV_DICT_MULTIKEY); - ret = hw_device_setup_for_decode(ist, dp, o->hwaccel_device); + ret = hw_device_setup_for_decode(dp, codec, o->hwaccel_device); if (ret < 0) { av_log(dp, AV_LOG_ERROR, "Hardware device setup failed for decoder: %s\n", |