diff mbox

[FFmpeg-devel] lavc/qsvdec: hw device should be set

Message ID 1514531169-20636-1-git-send-email-zhong.li@intel.com
State New
Headers show

Commit Message

Zhong Li Dec. 29, 2017, 7:06 a.m. UTC
Add the flag "AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX" to indicate
AVCodecContext.hw_device_ctx should be set before calling
avcodec_open2() for qsv decoding.
It is consistent with examples/qsvdec.c.

It also can make function "hw_device_match_by_codec()" can find qsv
device successfully.

Signed-off-by: Zhong Li <zhong.li@intel.com>
---
 libavcodec/qsvdec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

wm4 Dec. 29, 2017, 8:17 a.m. UTC | #1
On Fri, 29 Dec 2017 15:06:09 +0800
Zhong Li <zhong.li@intel.com> wrote:

> Add the flag "AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX" to indicate
> AVCodecContext.hw_device_ctx should be set before calling
> avcodec_open2() for qsv decoding.
> It is consistent with examples/qsvdec.c.
> 
> It also can make function "hw_device_match_by_codec()" can find qsv
> device successfully.
> 
> Signed-off-by: Zhong Li <zhong.li@intel.com>
> ---
>  libavcodec/qsvdec.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> index 55fe59b..ff1dcf1 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -45,7 +45,8 @@ const AVCodecHWConfigInternal *ff_qsv_hw_configs[] = {
>      &(const AVCodecHWConfigInternal) {
>          .public = {
>              .pix_fmt     = AV_PIX_FMT_QSV,
> -            .methods     = AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
> +            .methods     = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |
> +                           AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
>                             AV_CODEC_HW_CONFIG_METHOD_AD_HOC,
>              .device_type = AV_HWDEVICE_TYPE_QSV,
>          },

I guess that's correct. It also looks like it supports the INTERNAL
method? (Not sure.)
Mark Thompson Jan. 1, 2018, 11:35 p.m. UTC | #2
On 29/12/17 07:06, Zhong Li wrote:
> Add the flag "AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX" to indicate
> AVCodecContext.hw_device_ctx should be set before calling
> avcodec_open2() for qsv decoding.
> It is consistent with examples/qsvdec.c.
> 
> It also can make function "hw_device_match_by_codec()" can find qsv
> device successfully.
> 
> Signed-off-by: Zhong Li <zhong.li@intel.com>
> ---
>  libavcodec/qsvdec.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> index 55fe59b..ff1dcf1 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -45,7 +45,8 @@ const AVCodecHWConfigInternal *ff_qsv_hw_configs[] = {
>      &(const AVCodecHWConfigInternal) {
>          .public = {
>              .pix_fmt     = AV_PIX_FMT_QSV,
> -            .methods     = AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
> +            .methods     = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |
> +                           AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
>                             AV_CODEC_HW_CONFIG_METHOD_AD_HOC,
>              .device_type = AV_HWDEVICE_TYPE_QSV,
>          },
> 

Did you omit a patch implementing this?  The change here is only to the metadata, and it's not currently implemented.

- Mark
Zhong Li Jan. 2, 2018, 9:15 a.m. UTC | #3
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf

> Of Mark Thompson

> Sent: Tuesday, January 2, 2018 7:36 AM

> To: ffmpeg-devel@ffmpeg.org

> Subject: Re: [FFmpeg-devel] [PATCH] lavc/qsvdec: hw device should be set

> 

> On 29/12/17 07:06, Zhong Li wrote:

> > Add the flag "AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX" to

> indicate

> > AVCodecContext.hw_device_ctx should be set before calling

> > avcodec_open2() for qsv decoding.

> > It is consistent with examples/qsvdec.c.

> >

> > It also can make function "hw_device_match_by_codec()" can find qsv

> > device successfully.

> >

> > Signed-off-by: Zhong Li <zhong.li@intel.com>

> > ---

> >  libavcodec/qsvdec.c | 3 ++-

> >  1 file changed, 2 insertions(+), 1 deletion(-)

> >

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

> > 55fe59b..ff1dcf1 100644

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

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

> > @@ -45,7 +45,8 @@ const AVCodecHWConfigInternal

> *ff_qsv_hw_configs[] = {

> >      &(const AVCodecHWConfigInternal) {

> >          .public = {

> >              .pix_fmt     = AV_PIX_FMT_QSV,

> > -            .methods     =

> AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |

> > +            .methods     =

> AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |

> > +

> AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |

> >

> AV_CODEC_HW_CONFIG_METHOD_AD_HOC,

> >              .device_type = AV_HWDEVICE_TYPE_QSV,

> >          },

> >

> 

> Did you omit a patch implementing this?  The change here is only to the

> metadata, and it's not currently implemented.


Sorry maybe I omitted it, could you specify which patch?
wm4 Jan. 2, 2018, 11:27 a.m. UTC | #4
On Mon, 1 Jan 2018 23:35:42 +0000
Mark Thompson <sw@jkqxz.net> wrote:

> On 29/12/17 07:06, Zhong Li wrote:
> > Add the flag "AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX" to indicate
> > AVCodecContext.hw_device_ctx should be set before calling
> > avcodec_open2() for qsv decoding.
> > It is consistent with examples/qsvdec.c.
> > 
> > It also can make function "hw_device_match_by_codec()" can find qsv
> > device successfully.
> > 
> > Signed-off-by: Zhong Li <zhong.li@intel.com>
> > ---
> >  libavcodec/qsvdec.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> > index 55fe59b..ff1dcf1 100644
> > --- a/libavcodec/qsvdec.c
> > +++ b/libavcodec/qsvdec.c
> > @@ -45,7 +45,8 @@ const AVCodecHWConfigInternal *ff_qsv_hw_configs[] = {
> >      &(const AVCodecHWConfigInternal) {
> >          .public = {
> >              .pix_fmt     = AV_PIX_FMT_QSV,
> > -            .methods     = AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
> > +            .methods     = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |
> > +                           AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
> >                             AV_CODEC_HW_CONFIG_METHOD_AD_HOC,
> >              .device_type = AV_HWDEVICE_TYPE_QSV,
> >          },
> >   
> 
> Did you omit a patch implementing this?  The change here is only to the metadata, and it's not currently implemented.

Haven't looked too closely, but doesn't it do _something_ with it?
Mark Thompson Jan. 2, 2018, 12:32 p.m. UTC | #5
On 02/01/18 09:15, Li, Zhong wrote:
>> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf
>> Of Mark Thompson
>> Sent: Tuesday, January 2, 2018 7:36 AM
>> To: ffmpeg-devel@ffmpeg.org
>> Subject: Re: [FFmpeg-devel] [PATCH] lavc/qsvdec: hw device should be set
>>
>> On 29/12/17 07:06, Zhong Li wrote:
>>> Add the flag "AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX" to
>> indicate
>>> AVCodecContext.hw_device_ctx should be set before calling
>>> avcodec_open2() for qsv decoding.
>>> It is consistent with examples/qsvdec.c.
>>>
>>> It also can make function "hw_device_match_by_codec()" can find qsv
>>> device successfully.
>>>
>>> Signed-off-by: Zhong Li <zhong.li@intel.com>
>>> ---
>>>  libavcodec/qsvdec.c | 3 ++-
>>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index
>>> 55fe59b..ff1dcf1 100644
>>> --- a/libavcodec/qsvdec.c
>>> +++ b/libavcodec/qsvdec.c
>>> @@ -45,7 +45,8 @@ const AVCodecHWConfigInternal
>> *ff_qsv_hw_configs[] = {
>>>      &(const AVCodecHWConfigInternal) {
>>>          .public = {
>>>              .pix_fmt     = AV_PIX_FMT_QSV,
>>> -            .methods     =
>> AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
>>> +            .methods     =
>> AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |
>>> +
>> AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
>>>
>> AV_CODEC_HW_CONFIG_METHOD_AD_HOC,
>>>              .device_type = AV_HWDEVICE_TYPE_QSV,
>>>          },
>>>
>>
>> Did you omit a patch implementing this?  The change here is only to the
>> metadata, and it's not currently implemented.
> 
> Sorry maybe I omitted it, could you specify which patch? 

You sent one patch, which is just adding the HW_DEVICE_CTX method flag for AV_PIX_FMT_QSV output.  The feature itself is not implemented in current lavc, however, so applying it as-is would be wrong.  Hence I'm wondering if you forgot to send a patch before it which implements the feature first?

- Mark
Mark Thompson Jan. 2, 2018, 12:40 p.m. UTC | #6
On 02/01/18 11:27, wm4 wrote:
> On Mon, 1 Jan 2018 23:35:42 +0000
> Mark Thompson <sw@jkqxz.net> wrote:
> 
>> On 29/12/17 07:06, Zhong Li wrote:
>>> Add the flag "AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX" to indicate
>>> AVCodecContext.hw_device_ctx should be set before calling
>>> avcodec_open2() for qsv decoding.
>>> It is consistent with examples/qsvdec.c.
>>>
>>> It also can make function "hw_device_match_by_codec()" can find qsv
>>> device successfully.
>>>
>>> Signed-off-by: Zhong Li <zhong.li@intel.com>
>>> ---
>>>  libavcodec/qsvdec.c | 3 ++-
>>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
>>> index 55fe59b..ff1dcf1 100644
>>> --- a/libavcodec/qsvdec.c
>>> +++ b/libavcodec/qsvdec.c
>>> @@ -45,7 +45,8 @@ const AVCodecHWConfigInternal *ff_qsv_hw_configs[] = {
>>>      &(const AVCodecHWConfigInternal) {
>>>          .public = {
>>>              .pix_fmt     = AV_PIX_FMT_QSV,
>>> -            .methods     = AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
>>> +            .methods     = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |
>>> +                           AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
>>>                             AV_CODEC_HW_CONFIG_METHOD_AD_HOC,
>>>              .device_type = AV_HWDEVICE_TYPE_QSV,
>>>          },
>>>   
>>
>> Did you omit a patch implementing this?  The change here is only to the metadata, and it's not currently implemented.
> 
> Haven't looked too closely, but doesn't it do _something_ with it?

It's used to set the device used with software output (NV12/P010), which is orthogonal to the use with hardware output being shown here.  (It can be helpful when multiple instances (a decoder and an encoder, say) are going to use the same device but it can only be opened for exclusive access (e.g. the /dev/dri/cardN DRM master device on older Linux), but is usually unnecessary.)

- Mark
Zhong Li Jan. 4, 2018, 7:34 a.m. UTC | #7
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf

> Of Mark Thompson

> Sent: Tuesday, January 2, 2018 8:32 PM

> To: ffmpeg-devel@ffmpeg.org

> Subject: Re: [FFmpeg-devel] [PATCH] lavc/qsvdec: hw device should be set

> 

> On 02/01/18 09:15, Li, Zhong wrote:

> >> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On

> Behalf

> >> Of Mark Thompson

> >> Sent: Tuesday, January 2, 2018 7:36 AM

> >> To: ffmpeg-devel@ffmpeg.org

> >> Subject: Re: [FFmpeg-devel] [PATCH] lavc/qsvdec: hw device should be

> >> set

> >>

> >> On 29/12/17 07:06, Zhong Li wrote:

> >>> Add the flag "AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX" to

> >> indicate

> >>> AVCodecContext.hw_device_ctx should be set before calling

> >>> avcodec_open2() for qsv decoding.

> >>> It is consistent with examples/qsvdec.c.

> >>>

> >>> It also can make function "hw_device_match_by_codec()" can find qsv

> >>> device successfully.

> >>>

> >>> Signed-off-by: Zhong Li <zhong.li@intel.com>

> >>> ---

> >>>  libavcodec/qsvdec.c | 3 ++-

> >>>  1 file changed, 2 insertions(+), 1 deletion(-)

> >>>

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

> >>> 55fe59b..ff1dcf1 100644

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

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

> >>> @@ -45,7 +45,8 @@ const AVCodecHWConfigInternal

> >> *ff_qsv_hw_configs[] = {

> >>>      &(const AVCodecHWConfigInternal) {

> >>>          .public = {

> >>>              .pix_fmt     = AV_PIX_FMT_QSV,

> >>> -            .methods     =

> >> AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |

> >>> +            .methods     =

> >> AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |

> >>> +

> >> AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |

> >>>

> >> AV_CODEC_HW_CONFIG_METHOD_AD_HOC,

> >>>              .device_type = AV_HWDEVICE_TYPE_QSV,

> >>>          },

> >>>

> >>

> >> Did you omit a patch implementing this?  The change here is only to

> >> the metadata, and it's not currently implemented.

> >

> > Sorry maybe I omitted it, could you specify which patch?

> 

> You sent one patch, which is just adding the HW_DEVICE_CTX method flag

> for AV_PIX_FMT_QSV output.  The feature itself is not implemented in

> current lavc, however, so applying it as-is would be wrong.  Hence I'm

> wondering if you forgot to send a patch before it which implements the

> feature first?


Got it. I will update it as a patch set. Thanks for your remind.
diff mbox

Patch

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 55fe59b..ff1dcf1 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -45,7 +45,8 @@  const AVCodecHWConfigInternal *ff_qsv_hw_configs[] = {
     &(const AVCodecHWConfigInternal) {
         .public = {
             .pix_fmt     = AV_PIX_FMT_QSV,
-            .methods     = AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
+            .methods     = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |
+                           AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
                            AV_CODEC_HW_CONFIG_METHOD_AD_HOC,
             .device_type = AV_HWDEVICE_TYPE_QSV,
         },