[FFmpeg-cvslog] fftools/ffmpeg_dec: eliminate InputStream use in hw_device_setup_for_decode()
Anton Khirnov
git at videolan.org
Tue Jan 30 11:08:01 EET 2024
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Tue Jan 23 18:42:20 2024 +0100| [d5f9ef766b4e7958f3cf75c6b838fbe0f22936c5] | committer: Anton Khirnov
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.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d5f9ef766b4e7958f3cf75c6b838fbe0f22936c5
---
fftools/ffmpeg_dec.c | 15 ++++++++-------
1 file 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",
More information about the ffmpeg-cvslog
mailing list