diff mbox

[FFmpeg-devel] lavc/qsvdec: fix the regression on linux for init_hw_device

Message ID 1567493466-21852-1-git-send-email-linjie.fu@intel.com
State New
Headers show

Commit Message

Fu, Linjie Sept. 3, 2019, 6:51 a.m. UTC
Fixed the regression mentioned in #7030 since commit:
b0cd14fb1dab4b044f7fe6b53ac635409849de77
which breaks the decode pipeline with " -init_hw_device qsv:hw"
on Linux.

hw_device_match_by_codec(ist->dec) can't get the valid dev for QSV
thus can't call ff_qsv_init_session_device.
(called ff_qsv_init_internal_session instead)

As a contrast, the previous version found the dev and called
ff_qsv_init_session_device successfully.

Application shall call SetHandle on Linux, however currently in
Linux pipeline ff_qsv_set_display_handle was removed in
ff_qsv_init_internal_session since commit:
1f26a231bb065276cd80ce02957c759f3197edfa
so the Handle was not set on ffmpeg level.

The regression could not be detected on windows is because of the
difference between windows and linux in MSDK:

"on the past we intentionally didn't implement initialization of
vaDisplay inside MSDK library on Linux."

Details in ticket #7030 and issue in MSDK:
https://github.com/Intel-Media-SDK/MediaSDK/issues/1611

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
---
 libavcodec/qsvdec.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Zhong Li Sept. 3, 2019, 10:18 a.m. UTC | #1
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index eef4fe7..319b549

> 100644

> --- a/libavcodec/qsvdec.c

> +++ b/libavcodec/qsvdec.c

> @@ -46,6 +46,7 @@ const AVCodecHWConfigInternal *ff_qsv_hw_configs[] = {

>          .public = {

>              .pix_fmt     = AV_PIX_FMT_QSV,

>              .methods     = AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |

> +                           AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |


AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX means we can support AV_PIX_FMT_QSV by AVCodecContext.hw_device_ctx
This is not supported for qsv now. 
And even if it is supported, there is no business of system memory frame, just means output AV_PIX_FMT_QSV format frame created by hw_device_ctx.

>                             AV_CODEC_HW_CONFIG_METHOD_AD_HOC,

>              .device_type = AV_HWDEVICE_TYPE_QSV,

>          },

> --

> 2.7.4


Probably we need to add MFXVideoCORE_SetHandle() function for system memory output path, which is removed by 1f26a231bb065276cd80ce02957c759f3197edfa.
I will try to give a patch to fix it ASAP.
Fu, Linjie Sept. 3, 2019, 11:09 a.m. UTC | #2
> -----Original Message-----

> From: Li, Zhong

> Sent: Tuesday, September 3, 2019 18:18

> To: FFmpeg development discussions and patches <ffmpeg-

> devel@ffmpeg.org>

> Cc: Fu, Linjie <linjie.fu@intel.com>

> Subject: RE: [FFmpeg-devel] [PATCH] lavc/qsvdec: fix the regression on linux

> for init_hw_device

> 

> > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index

> eef4fe7..319b549

> > 100644

> > --- a/libavcodec/qsvdec.c

> > +++ b/libavcodec/qsvdec.c

> > @@ -46,6 +46,7 @@ const AVCodecHWConfigInternal

> *ff_qsv_hw_configs[] = {

> >          .public = {

> >              .pix_fmt     = AV_PIX_FMT_QSV,

> >              .methods     =

> AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |

> > +                           AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |

> 

> AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX means we can

> support AV_PIX_FMT_QSV by AVCodecContext.hw_device_ctx

> This is not supported for qsv now.

> And even if it is supported, there is no business of system memory frame,

> just means output AV_PIX_FMT_QSV format frame created by

> hw_device_ctx.


Thanks for the explanation of this flag.

> 

> >                             AV_CODEC_HW_CONFIG_METHOD_AD_HOC,

> >              .device_type = AV_HWDEVICE_TYPE_QSV,

> >          },

> > --

> > 2.7.4

> 

> Probably we need to add MFXVideoCORE_SetHandle() function for system

> memory output path, which is removed by

> 1f26a231bb065276cd80ce02957c759f3197edfa.


Yes, that's another possibility to fix this issue.
This patch aims at matching the behavior before the regression happened since
currently qsv is working on different session_init path compared with previous
version.

If ff_qsv_init_session_device() should not be called, it's good to set handle in
ff_qsv_init_internal_session (), since MSDK won't do such implementation on Linux
internally:
https://github.com/Intel-Media-SDK/MediaSDK/issues/1611#issuecomment-527359911

> I will try to give a patch to fix it ASAP.


Thanks,

-linjie
diff mbox

Patch

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index eef4fe7..319b549 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -46,6 +46,7 @@  const AVCodecHWConfigInternal *ff_qsv_hw_configs[] = {
         .public = {
             .pix_fmt     = AV_PIX_FMT_QSV,
             .methods     = AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
+                           AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |
                            AV_CODEC_HW_CONFIG_METHOD_AD_HOC,
             .device_type = AV_HWDEVICE_TYPE_QSV,
         },