1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-15 14:13:16 +02:00

ffmpeg: use explicitly requested hwaccel only

With there being two hwaccels that use the CUDA pix_fmt now, just
relying on the pix_fmt to identify the selected hwaccel is not enough
anymore.

So this checks if the user explicitly selected a hwaccel, and only
accepts that one.
This commit is contained in:
Timo Rothenpieler
2017-11-10 22:06:22 +01:00
parent bc50961731
commit 6a4d1c9063

View File

@@ -2782,11 +2782,12 @@ fail:
av_freep(&avc); av_freep(&avc);
} }
static const HWAccel *get_hwaccel(enum AVPixelFormat pix_fmt) static const HWAccel *get_hwaccel(enum AVPixelFormat pix_fmt, enum HWAccelID selected_hwaccel_id)
{ {
int i; int i;
for (i = 0; hwaccels[i].name; i++) for (i = 0; hwaccels[i].name; i++)
if (hwaccels[i].pix_fmt == pix_fmt) if (hwaccels[i].pix_fmt == pix_fmt &&
(!selected_hwaccel_id || selected_hwaccel_id == HWACCEL_AUTO || hwaccels[i].id == selected_hwaccel_id))
return &hwaccels[i]; return &hwaccels[i];
return NULL; return NULL;
} }
@@ -2804,7 +2805,7 @@ static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat
if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))
break; break;
hwaccel = get_hwaccel(*p); hwaccel = get_hwaccel(*p, ist->hwaccel_id);
if (!hwaccel || if (!hwaccel ||
(ist->active_hwaccel_id && ist->active_hwaccel_id != hwaccel->id) || (ist->active_hwaccel_id && ist->active_hwaccel_id != hwaccel->id) ||
(ist->hwaccel_id != HWACCEL_AUTO && ist->hwaccel_id != hwaccel->id)) (ist->hwaccel_id != HWACCEL_AUTO && ist->hwaccel_id != hwaccel->id))