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.
This commit is contained in:
@@ -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 char *hwaccel_device)
|
||||||
{
|
{
|
||||||
const AVCodecHWConfig *config;
|
const AVCodecHWConfig *config;
|
||||||
@@ -858,7 +859,7 @@ static int hw_device_setup_for_decode(InputStream *ist, DecoderPriv *dp,
|
|||||||
if (!dev)
|
if (!dev)
|
||||||
err = hw_device_init_from_type(type, NULL, &dev);
|
err = hw_device_init_from_type(type, NULL, &dev);
|
||||||
} else {
|
} else {
|
||||||
dev = hw_device_match_by_codec(ist->dec);
|
dev = hw_device_match_by_codec(codec);
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
// No device for this codec, but not using generic hwaccel
|
// No device for this codec, but not using generic hwaccel
|
||||||
// and therefore may well not need one - ignore.
|
// 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) {
|
if (auto_device) {
|
||||||
int i;
|
int i;
|
||||||
if (!avcodec_get_hw_config(ist->dec, 0)) {
|
if (!avcodec_get_hw_config(codec, 0)) {
|
||||||
// Decoder does not support any hardware devices.
|
// Decoder does not support any hardware devices.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
for (i = 0; !dev; i++) {
|
for (i = 0; !dev; i++) {
|
||||||
config = avcodec_get_hw_config(ist->dec, i);
|
config = avcodec_get_hw_config(codec, i);
|
||||||
if (!config)
|
if (!config)
|
||||||
break;
|
break;
|
||||||
type = config->device_type;
|
type = config->device_type;
|
||||||
@@ -886,7 +887,7 @@ static int hw_device_setup_for_decode(InputStream *ist, DecoderPriv *dp,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; !dev; i++) {
|
for (i = 0; !dev; i++) {
|
||||||
config = avcodec_get_hw_config(ist->dec, i);
|
config = avcodec_get_hw_config(codec, i);
|
||||||
if (!config)
|
if (!config)
|
||||||
break;
|
break;
|
||||||
type = config->device_type;
|
type = config->device_type;
|
||||||
@@ -921,7 +922,7 @@ static int hw_device_setup_for_decode(InputStream *ist, DecoderPriv *dp,
|
|||||||
if (!dev) {
|
if (!dev) {
|
||||||
av_log(dp, AV_LOG_ERROR, "No device available "
|
av_log(dp, AV_LOG_ERROR, "No device available "
|
||||||
"for decoder: device type %s needed for codec %s.\n",
|
"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;
|
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);
|
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) {
|
if (ret < 0) {
|
||||||
av_log(dp, AV_LOG_ERROR,
|
av_log(dp, AV_LOG_ERROR,
|
||||||
"Hardware device setup failed for decoder: %s\n",
|
"Hardware device setup failed for decoder: %s\n",
|
||||||
|
Reference in New Issue
Block a user