diff mbox series

[FFmpeg-devel] ffmpeg: default hwaccel_output_format to cuda when hwaccel is cuvid

Message ID 20200307122704.27410-1-timo@rothenpieler.org
State Accepted
Headers show
Series [FFmpeg-devel] ffmpeg: default hwaccel_output_format to cuda when hwaccel is cuvid | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Timo Rothenpieler March 7, 2020, 12:27 p.m. UTC
This ensures old commandlines using -hwaccel cuvid don't break due to
the recent removal of the the cuvid-specific hwaccel bringup.
---
 fftools/ffmpeg_opt.c | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

Comments

James Almer March 7, 2020, 3:20 p.m. UTC | #1
On 3/7/2020 9:27 AM, Timo Rothenpieler wrote:
> This ensures old commandlines using -hwaccel cuvid don't break due to
> the recent removal of the the cuvid-specific hwaccel bringup.
> ---
>  fftools/ffmpeg_opt.c | 31 +++++++++++++++++++------------
>  1 file changed, 19 insertions(+), 12 deletions(-)
> 
> diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
> index 1b721c4954..043919faeb 100644
> --- a/fftools/ffmpeg_opt.c
> +++ b/fftools/ffmpeg_opt.c
> @@ -817,6 +817,25 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
>              MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, ic, st);
>  
>              MATCH_PER_STREAM_OPT(hwaccels, str, hwaccel, ic, st);
> +            MATCH_PER_STREAM_OPT(hwaccel_output_formats, str,
> +                                 hwaccel_output_format, ic, st);
> +
> +            if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel, "cuvid")) {
> +                av_log(NULL, AV_LOG_WARNING,
> +                    "WARNING: defaulting hwaccel_output_format to cuda for compatibility "
> +                    "with old commandlines. This behaviour is DEPRECATED and will be removed "
> +                    "in the future. Please explicitly set \"-hwaccel_output_format cuda\".\n");

So deprecating only the forced output format and leaving the alias alone?

LGTM either way.

> +                ist->hwaccel_output_format = AV_PIX_FMT_CUDA;
> +            } else if (hwaccel_output_format) {
> +                ist->hwaccel_output_format = av_get_pix_fmt(hwaccel_output_format);
> +                if (ist->hwaccel_output_format == AV_PIX_FMT_NONE) {
> +                    av_log(NULL, AV_LOG_FATAL, "Unrecognised hwaccel output "
> +                           "format: %s", hwaccel_output_format);
> +                }
> +            } else {
> +                ist->hwaccel_output_format = AV_PIX_FMT_NONE;
> +            }
> +
>              if (hwaccel) {
>                  // The NVDEC hwaccels use a CUDA device, so remap the name here.
>                  if (!strcmp(hwaccel, "nvdec") || !strcmp(hwaccel, "cuvid"))
> @@ -868,18 +887,6 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
>                      exit_program(1);
>              }
>  
> -            MATCH_PER_STREAM_OPT(hwaccel_output_formats, str,
> -                                 hwaccel_output_format, ic, st);
> -            if (hwaccel_output_format) {
> -                ist->hwaccel_output_format = av_get_pix_fmt(hwaccel_output_format);
> -                if (ist->hwaccel_output_format == AV_PIX_FMT_NONE) {
> -                    av_log(NULL, AV_LOG_FATAL, "Unrecognised hwaccel output "
> -                           "format: %s", hwaccel_output_format);
> -                }
> -            } else {
> -                ist->hwaccel_output_format = AV_PIX_FMT_NONE;
> -            }
> -
>              ist->hwaccel_pix_fmt = AV_PIX_FMT_NONE;
>  
>              break;
>
Timo Rothenpieler March 7, 2020, 7 p.m. UTC | #2
On 07.03.2020 16:20, James Almer wrote:
> On 3/7/2020 9:27 AM, Timo Rothenpieler wrote:
>> This ensures old commandlines using -hwaccel cuvid don't break due to
>> the recent removal of the the cuvid-specific hwaccel bringup.
>> ---
>>   fftools/ffmpeg_opt.c | 31 +++++++++++++++++++------------
>>   1 file changed, 19 insertions(+), 12 deletions(-)
>>
>> diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
>> index 1b721c4954..043919faeb 100644
>> --- a/fftools/ffmpeg_opt.c
>> +++ b/fftools/ffmpeg_opt.c
>> @@ -817,6 +817,25 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
>>               MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, ic, st);
>>   
>>               MATCH_PER_STREAM_OPT(hwaccels, str, hwaccel, ic, st);
>> +            MATCH_PER_STREAM_OPT(hwaccel_output_formats, str,
>> +                                 hwaccel_output_format, ic, st);
>> +
>> +            if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel, "cuvid")) {
>> +                av_log(NULL, AV_LOG_WARNING,
>> +                    "WARNING: defaulting hwaccel_output_format to cuda for compatibility "
>> +                    "with old commandlines. This behaviour is DEPRECATED and will be removed "
>> +                    "in the future. Please explicitly set \"-hwaccel_output_format cuda\".\n");
> 
> So deprecating only the forced output format and leaving the alias alone?
> 
> LGTM either way.

Yes, if we want to deprecate the entire alias, that should be another 
patch anyway, so leaving it alone for now.

will apply very soon
diff mbox series

Patch

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 1b721c4954..043919faeb 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -817,6 +817,25 @@  static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
             MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, ic, st);
 
             MATCH_PER_STREAM_OPT(hwaccels, str, hwaccel, ic, st);
+            MATCH_PER_STREAM_OPT(hwaccel_output_formats, str,
+                                 hwaccel_output_format, ic, st);
+
+            if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel, "cuvid")) {
+                av_log(NULL, AV_LOG_WARNING,
+                    "WARNING: defaulting hwaccel_output_format to cuda for compatibility "
+                    "with old commandlines. This behaviour is DEPRECATED and will be removed "
+                    "in the future. Please explicitly set \"-hwaccel_output_format cuda\".\n");
+                ist->hwaccel_output_format = AV_PIX_FMT_CUDA;
+            } else if (hwaccel_output_format) {
+                ist->hwaccel_output_format = av_get_pix_fmt(hwaccel_output_format);
+                if (ist->hwaccel_output_format == AV_PIX_FMT_NONE) {
+                    av_log(NULL, AV_LOG_FATAL, "Unrecognised hwaccel output "
+                           "format: %s", hwaccel_output_format);
+                }
+            } else {
+                ist->hwaccel_output_format = AV_PIX_FMT_NONE;
+            }
+
             if (hwaccel) {
                 // The NVDEC hwaccels use a CUDA device, so remap the name here.
                 if (!strcmp(hwaccel, "nvdec") || !strcmp(hwaccel, "cuvid"))
@@ -868,18 +887,6 @@  static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
                     exit_program(1);
             }
 
-            MATCH_PER_STREAM_OPT(hwaccel_output_formats, str,
-                                 hwaccel_output_format, ic, st);
-            if (hwaccel_output_format) {
-                ist->hwaccel_output_format = av_get_pix_fmt(hwaccel_output_format);
-                if (ist->hwaccel_output_format == AV_PIX_FMT_NONE) {
-                    av_log(NULL, AV_LOG_FATAL, "Unrecognised hwaccel output "
-                           "format: %s", hwaccel_output_format);
-                }
-            } else {
-                ist->hwaccel_output_format = AV_PIX_FMT_NONE;
-            }
-
             ist->hwaccel_pix_fmt = AV_PIX_FMT_NONE;
 
             break;