diff mbox series

[FFmpeg-devel,2/3] libavutil/hwcontext_qsv: fix a bug for mapping vaapi frame to qsv

Message ID 20211116081623.3081766-2-wenbin.chen@intel.com
State New
Headers show
Series [FFmpeg-devel,1/3] libavcodec/vaapi_decode: fix the problem that init_pool_size < nb_surface
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Wenbin Chen Nov. 16, 2021, 8:16 a.m. UTC
From: nyanmisaka <nst799610810@gmail.com>

The data stored in data[3] in VAAPI AVFrame is VASurfaceID while
the data stored in pair->first is the pointer of VASurfaceID, so
we need to do cast to make following commandline works:

ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 \
-hwaccel_output_format vaapi -i input.264 \
-vf "hwmap=derive_device=qsv,format=qsv" -c:v h264_qsv output.264

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
---
 libavutil/hwcontext_qsv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Wenbin Chen Nov. 23, 2021, 1:56 a.m. UTC | #1
> From: nyanmisaka <nst799610810@gmail.com>
> 
> The data stored in data[3] in VAAPI AVFrame is VASurfaceID while
> the data stored in pair->first is the pointer of VASurfaceID, so
> we need to do cast to make following commandline works:
> 
> ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 \
> -hwaccel_output_format vaapi -i input.264 \
> -vf "hwmap=derive_device=qsv,format=qsv" -c:v h264_qsv output.264
> 
> Signed-off-by: nyanmisaka <nst799610810@gmail.com>
> Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
> ---
>  libavutil/hwcontext_qsv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
> index c18747f7eb..d83754193a 100644
> --- a/libavutil/hwcontext_qsv.c
> +++ b/libavutil/hwcontext_qsv.c
> @@ -1220,7 +1220,7 @@ static int qsv_map_to(AVHWFramesContext
> *dst_ctx,
>          case AV_PIX_FMT_VAAPI:
>          {
>              mfxHDLPair *pair = (mfxHDLPair*)hwctx->surfaces[i].Data.MemId;
> -            if (pair->first == src->data[3]) {
> +            if (*(VASurfaceID*)pair->first == (VASurfaceID)src->data[3]) {
>                  index = i;
>                  break;
>              }
> --
> 2.25.1
> 

ping

> _______________________________________________
> 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".
Anton Khirnov Nov. 29, 2021, 9:39 a.m. UTC | #2
Quoting Chen, Wenbin (2021-11-23 02:56:37)
> > From: nyanmisaka <nst799610810@gmail.com>
> > 
> > The data stored in data[3] in VAAPI AVFrame is VASurfaceID while
> > the data stored in pair->first is the pointer of VASurfaceID, so
> > we need to do cast to make following commandline works:
> > 
> > ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 \
> > -hwaccel_output_format vaapi -i input.264 \
> > -vf "hwmap=derive_device=qsv,format=qsv" -c:v h264_qsv output.264
> > 
> > Signed-off-by: nyanmisaka <nst799610810@gmail.com>
> > Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
> > ---
> >  libavutil/hwcontext_qsv.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
> > index c18747f7eb..d83754193a 100644
> > --- a/libavutil/hwcontext_qsv.c
> > +++ b/libavutil/hwcontext_qsv.c
> > @@ -1220,7 +1220,7 @@ static int qsv_map_to(AVHWFramesContext
> > *dst_ctx,
> >          case AV_PIX_FMT_VAAPI:
> >          {
> >              mfxHDLPair *pair = (mfxHDLPair*)hwctx->surfaces[i].Data.MemId;
> > -            if (pair->first == src->data[3]) {
> > +            if (*(VASurfaceID*)pair->first == (VASurfaceID)src->data[3]) {
> >                  index = i;
> >                  break;
> >              }

Looks good, will push.
diff mbox series

Patch

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index c18747f7eb..d83754193a 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -1220,7 +1220,7 @@  static int qsv_map_to(AVHWFramesContext *dst_ctx,
         case AV_PIX_FMT_VAAPI:
         {
             mfxHDLPair *pair = (mfxHDLPair*)hwctx->surfaces[i].Data.MemId;
-            if (pair->first == src->data[3]) {
+            if (*(VASurfaceID*)pair->first == (VASurfaceID)src->data[3]) {
                 index = i;
                 break;
             }