diff mbox series

[FFmpeg-devel] ffmpeg_qsv: respect hwaccel_output_format setting

Message ID 20201022015239.1675600-1-haihao.xiang@intel.com
State New
Headers show
Series [FFmpeg-devel] ffmpeg_qsv: respect hwaccel_output_format setting | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Xiang, Haihao Oct. 22, 2020, 1:52 a.m. UTC
Without this change, the output pixel format from qsv decoder is always
'qsv' regardless of the hwaccel_output_format setting, user will get
errors when FFmpeg inserts an auto filter to convert 'qsv' format to the
specified format

Fox example:

ffmpeg -loglevel verbose -hwaccel qsv -c:v h264_qsv
-hwaccel_output_format yuv420p -i input.h264
-pix_fmt rgb24 -f null -

......
[graph 0 input from stream 0:0 @ 0x55c057c8f050] w:1280 h:720 pixfmt:qsv
tb:1/1001 fr:30000/1001 sar:1/1
[auto_scaler_0 @ 0x55c057c90d20] w:iw h:ih flags:'bicubic' interl:0
[format @ 0x55c057c8f990] auto-inserting filter 'auto_scaler_0' between
the filter 'Parsed_null_0' and the filter 'format'
Impossible to convert between the formats supported by the filter
'Parsed_null_0' and the filter 'auto_scaler_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while processing the decoded data for stream #0:
---
 fftools/ffmpeg_opt.c | 6 ++++++
 fftools/ffmpeg_qsv.c | 2 ++
 2 files changed, 8 insertions(+)

Comments

Mark Thompson Oct. 28, 2020, 8:04 p.m. UTC | #1
On 22/10/2020 02:52, Haihao Xiang wrote:
> Without this change, the output pixel format from qsv decoder is always
> 'qsv' ...

No it isn't.

> ffmpeg -loglevel verbose -hwaccel qsv -c:v h264_qsv
> -hwaccel_output_format yuv420p -i input.h264
> -pix_fmt rgb24 -f null -

The legacy decoders still use the -hwaccel option to indicate a desire for hardware-surface output, so don't set that.

(Updating them to use the hw_device_ctx API like everything else would be more useful than adding workarounds in the generic code.)

- Mark
Xiang, Haihao Oct. 29, 2020, 2:38 a.m. UTC | #2
> On 22/10/2020 02:52, Haihao Xiang wrote:
> > Without this change, the output pixel format from qsv decoder is always
> > 'qsv' ...
> 
> No it isn't.

My thought was for '-hwaccel qsv' part. 

> 
> > ffmpeg -loglevel verbose -hwaccel qsv -c:v h264_qsv
> > -hwaccel_output_format yuv420p -i input.h264
> > -pix_fmt rgb24 -f null -
> 
> The legacy decoders still use the -hwaccel option to indicate a desire for
> hardware-surface output, so don't set that.
> 
> (Updating them to use the hw_device_ctx API like everything else would be more
> useful than adding workarounds in the generic code.)

Did you mean to take hwaccel_qsv as a generic hwaccel method and make
hw_device_setup_for_decode() works for qsv too? 

Thanks
Haihao


> 
> - Mark
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 19f719e3ff..6835affa3c 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -884,6 +884,12 @@  static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
                     "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 && hwaccel && !strcmp(hwaccel, "qsv")) {
+                av_log(NULL, AV_LOG_WARNING,
+                    "WARNING: defaulting hwaccel_output_format to qsv for compatibility "
+                    "with old commandlines. This behaviour is DEPRECATED and will be removed "
+                    "in the future. Please explicitly set \"-hwaccel_output_format qsv\".\n");
+                ist->hwaccel_output_format = AV_PIX_FMT_QSV;
             } 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) {
diff --git a/fftools/ffmpeg_qsv.c b/fftools/ffmpeg_qsv.c
index 960c88b69d..7f01370ada 100644
--- a/fftools/ffmpeg_qsv.c
+++ b/fftools/ffmpeg_qsv.c
@@ -82,6 +82,8 @@  int qsv_init(AVCodecContext *s)
             return ret;
     }
 
+    hwaccel_decode_init(s);
+
     av_buffer_unref(&ist->hw_frames_ctx);
     ist->hw_frames_ctx = av_hwframe_ctx_alloc(hw_device_ctx);
     if (!ist->hw_frames_ctx)