diff mbox

[FFmpeg-devel] ffmpeg: use explicitly requested hwaccel only

Message ID 20171110212046.6870-1-timo@rothenpieler.org
State New
Headers show

Commit Message

Timo Rothenpieler Nov. 10, 2017, 9:20 p.m. UTC
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.
---
 fftools/ffmpeg.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Timo Rothenpieler Nov. 11, 2017, 1:20 p.m. UTC | #1
Am 11.11.2017 um 13:02 schrieb Michael Niedermayer:
> On Fri, Nov 10, 2017 at 10:20:46PM +0100, Timo Rothenpieler wrote:
>> 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.
>> ---
>>   fftools/ffmpeg.c | 7 ++++---
>>   1 file changed, 4 insertions(+), 3 deletions(-)
> 
> should be ok
> 
> thx

applied
diff mbox

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 679929cfc4..d430353b56 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2782,11 +2782,12 @@  fail:
     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;
     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 NULL;
 }
@@ -2804,7 +2805,7 @@  static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat
         if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))
             break;
 
-        hwaccel = get_hwaccel(*p);
+        hwaccel = get_hwaccel(*p, ist->hwaccel_id);
         if (!hwaccel ||
             (ist->active_hwaccel_id && ist->active_hwaccel_id != hwaccel->id) ||
             (ist->hwaccel_id != HWACCEL_AUTO && ist->hwaccel_id != hwaccel->id))