diff mbox series

[FFmpeg-devel,v2,4/5] avutil/hwcontext_qsv: map QSV frames to D3D11VA frames

Message ID 20220429104505.1747-4-tong1.wu@intel.com
State New
Headers show
Series [FFmpeg-devel,v2,1/5] avutil/hwcontext_d3d11va: fix the uninitialized texture bindflag | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Wu, Tong1 April 29, 2022, 10:45 a.m. UTC
When input is a rawvideo, after mapping QSV frames to D3D11VA frames,
the output will have green frames. Now fix it.

Fixes:
$ ffmpeg.exe -y -init_hw_device d3d11va=d3d11 \
-init_hw_device qsv=qsv@d3d11 -s:v WxH -pix_fmt nv12 -i input.yuv \
-vf "format=nv12,hwupload=extra_hw_frames=16,\
hwmap=derive_device=d3d11va,format=d3d11,hwdownload,format=nv12" \
-f rawvideo output.yuv

Signed-off-by: Tong Wu <tong1.wu@intel.com>
---
 libavutil/hwcontext_qsv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Soft Works April 30, 2022, 3:08 p.m. UTC | #1
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Tong
> Wu
> Sent: Friday, April 29, 2022 12:45 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Tong Wu <tong1.wu@intel.com>
> Subject: [FFmpeg-devel] [PATCH v2 4/5] avutil/hwcontext_qsv: map QSV
> frames to D3D11VA frames
> 
> When input is a rawvideo, after mapping QSV frames to D3D11VA frames,
> the output will have green frames. Now fix it.
> 
> Fixes:
> $ ffmpeg.exe -y -init_hw_device d3d11va=d3d11 \
> -init_hw_device qsv=qsv@d3d11 -s:v WxH -pix_fmt nv12 -i input.yuv \
> -vf "format=nv12,hwupload=extra_hw_frames=16,\
> hwmap=derive_device=d3d11va,format=d3d11,hwdownload,format=nv12" \
> -f rawvideo output.yuv
> 
> Signed-off-by: Tong Wu <tong1.wu@intel.com>
> ---
>  libavutil/hwcontext_qsv.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
> index d9d05e936a..6bc920ef59 100644
> --- a/libavutil/hwcontext_qsv.c
> +++ b/libavutil/hwcontext_qsv.c
> @@ -915,7 +915,7 @@ static int qsv_map_from(AVHWFramesContext *ctx,
>         if (child_frames_ctx->device_ctx->type ==
> AV_HWDEVICE_TYPE_D3D11VA) {
>              mfxHDLPair *pair = (mfxHDLPair*)surf->Data.MemId;
>              dst->data[0] = pair->first;
> -            dst->data[1] = pair->second;
> +            dst->data[1] = pair->second == (mfxMemId)MFX_INFINITE ?
> (uint8_t *)0 : pair->second;
>          } else {
>              dst->data[3] = child_data;
>          }
> @@ -945,7 +945,7 @@ static int qsv_map_from(AVHWFramesContext *ctx,
>      if (child_frames_ctx->device_ctx->type ==
> AV_HWDEVICE_TYPE_D3D11VA) {
>          mfxHDLPair *pair = (mfxHDLPair*)surf->Data.MemId;
>          dummy->data[0] = pair->first;
> -        dummy->data[1] = pair->second;
> +        dummy->data[1] = pair->second == (mfxMemId)MFX_INFINITE ?
> (uint8_t *)0 : pair->second;
>      } else {
>          dummy->data[3] = child_data;
>      }
> --

LGTM.

The command line might not make much sense this way, but yes, this 
change is required for mapping non-array textures.

Thanks,
softworkz
diff mbox series

Patch

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index d9d05e936a..6bc920ef59 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -915,7 +915,7 @@  static int qsv_map_from(AVHWFramesContext *ctx,
        if (child_frames_ctx->device_ctx->type == AV_HWDEVICE_TYPE_D3D11VA) {
             mfxHDLPair *pair = (mfxHDLPair*)surf->Data.MemId;
             dst->data[0] = pair->first;
-            dst->data[1] = pair->second;
+            dst->data[1] = pair->second == (mfxMemId)MFX_INFINITE ? (uint8_t *)0 : pair->second;
         } else {
             dst->data[3] = child_data;
         }
@@ -945,7 +945,7 @@  static int qsv_map_from(AVHWFramesContext *ctx,
     if (child_frames_ctx->device_ctx->type == AV_HWDEVICE_TYPE_D3D11VA) {
         mfxHDLPair *pair = (mfxHDLPair*)surf->Data.MemId;
         dummy->data[0] = pair->first;
-        dummy->data[1] = pair->second;
+        dummy->data[1] = pair->second == (mfxMemId)MFX_INFINITE ? (uint8_t *)0 : pair->second;
     } else {
         dummy->data[3] = child_data;
     }