diff mbox series

[FFmpeg-devel] avutils/hwcontext_qsv: set the source device in qsv_device_create

Message ID 20210222084504.339978-1-guangxin.xu@intel.com
State New
Headers show
Series [FFmpeg-devel] avutils/hwcontext_qsv: set the source device in qsv_device_create
Related show

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

Xu, Guangxin Feb. 22, 2021, 8:45 a.m. UTC
opencl_device_derive only handles AV_HWDEVICE_TYPE_VAAPI.
We need a source device for qsv.

this will fix following pipeline:
ffmpeg -init_hw_device vaapi=intel:/dev/dri/renderD128 -init_hw_device opencl=ocl@intel -hwaccel qsv -c:v h264_qsv -hwaccel_output_format qsv -i $input -filter_hw_device ocl -vf 'hwmap=derive_device=opencl,format=opencl,unsharp_opencl,hwmap=derive_device=qsv:reverse=1:extra_hw_frames=32'  -c:v hevc_qsv  -y test.h265
---
 libavutil/hwcontext_qsv.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Soft Works Feb. 22, 2021, 9:16 a.m. UTC | #1
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Xu
> Guangxin
> Sent: Monday, February 22, 2021 9:45 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Xu Guangxin <guangxin.xu@intel.com>
> Subject: [FFmpeg-devel] [PATCH] avutils/hwcontext_qsv: set the source
> device in qsv_device_create
> 
> opencl_device_derive only handles AV_HWDEVICE_TYPE_VAAPI.
> We need a source device for qsv.
> 
> this will fix following pipeline:
> ffmpeg -init_hw_device vaapi=intel:/dev/dri/renderD128 -init_hw_device
> opencl=ocl@intel -hwaccel qsv -c:v h264_qsv -hwaccel_output_format qsv -i
> $input -filter_hw_device ocl -vf
> 'hwmap=derive_device=opencl,format=opencl,unsharp_opencl,hwmap=der
> ive_device=qsv:reverse=1:extra_hw_frames=32'  -c:v hevc_qsv  -y test.h265
> ---
>  libavutil/hwcontext_qsv.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index
> 35a944f8f8..af3ee32cac 100644
> --- a/libavutil/hwcontext_qsv.c
> +++ b/libavutil/hwcontext_qsv.c
> @@ -1269,7 +1269,13 @@ static int qsv_device_create(AVHWDeviceContext
> *ctx, const char *device,
> 
>      impl = choose_implementation(device);
> 
> -    return qsv_device_derive_from_child(ctx, impl, child_device, 0);
> +    ret = qsv_device_derive_from_child(ctx, impl, child_device, 0);
> +    if (ret == 0) {
> +        ctx->internal->source_device = av_buffer_ref(priv->child_device_ctx);
> +        if (!ctx->internal->source_device)
> +            ret = AVERROR(ENOMEM);
> +    }
> +    return ret;
>  }

That's funny, I made almost the same change only two days ago:

    impl = choose_implementation(device);
    ret = qsv_device_derive_from_child(ctx, impl, child_device, 0);
    if (ret >= 0)
        ctx->internal->source_device = av_buffer_ref(priv->child_device_ctx);

    return ret;


From my POV, this change is correct and required.

softworkz
Guangxin Xu Feb. 23, 2021, 1:34 a.m. UTC | #2
On Mon, Feb 22, 2021 at 5:17 PM Soft Works <softworkz@hotmail.com> wrote:

>
>
> > -----Original Message-----
> > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Xu
> > Guangxin
> > Sent: Monday, February 22, 2021 9:45 AM
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Xu Guangxin <guangxin.xu@intel.com>
> > Subject: [FFmpeg-devel] [PATCH] avutils/hwcontext_qsv: set the source
> > device in qsv_device_create
> >
> > opencl_device_derive only handles AV_HWDEVICE_TYPE_VAAPI.
> > We need a source device for qsv.
> >
> > this will fix following pipeline:
> > ffmpeg -init_hw_device vaapi=intel:/dev/dri/renderD128 -init_hw_device
> > opencl=ocl@intel -hwaccel qsv -c:v h264_qsv -hwaccel_output_format qsv
> -i
> > $input -filter_hw_device ocl -vf
> > 'hwmap=derive_device=opencl,format=opencl,unsharp_opencl,hwmap=der
> > ive_device=qsv:reverse=1:extra_hw_frames=32'  -c:v hevc_qsv  -y test.h265
> > ---
> >  libavutil/hwcontext_qsv.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index
> > 35a944f8f8..af3ee32cac 100644
> > --- a/libavutil/hwcontext_qsv.c
> > +++ b/libavutil/hwcontext_qsv.c
> > @@ -1269,7 +1269,13 @@ static int qsv_device_create(AVHWDeviceContext
> > *ctx, const char *device,
> >
> >      impl = choose_implementation(device);
> >
> > -    return qsv_device_derive_from_child(ctx, impl, child_device, 0);
> > +    ret = qsv_device_derive_from_child(ctx, impl, child_device, 0);
> > +    if (ret == 0) {
> > +        ctx->internal->source_device =
> av_buffer_ref(priv->child_device_ctx);
> > +        if (!ctx->internal->source_device)
> > +            ret = AVERROR(ENOMEM);
> > +    }
> > +    return ret;
> >  }
>
> That's funny, I made almost the same change only two days ago:
>
>     impl = choose_implementation(device);
>     ret = qsv_device_derive_from_child(ctx, impl, child_device, 0);
>     if (ret >= 0)
>         ctx->internal->source_device =
> av_buffer_ref(priv->child_device_ctx);
>
>     return ret;
>
>
> From my POV, this change is correct and required.
>
Glad to hear this. Thanks for the endorsement  :)

>
> softworkz
> _______________________________________________
> 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".
Guangxin Xu March 5, 2021, 1:46 a.m. UTC | #3
On Tue, Feb 23, 2021 at 9:34 AM Guangxin Xu <oddstone@gmail.com> wrote:

>
>
> On Mon, Feb 22, 2021 at 5:17 PM Soft Works <softworkz@hotmail.com> wrote:
>
>>
>>
>> > -----Original Message-----
>> > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Xu
>> > Guangxin
>> > Sent: Monday, February 22, 2021 9:45 AM
>> > To: ffmpeg-devel@ffmpeg.org
>> > Cc: Xu Guangxin <guangxin.xu@intel.com>
>> > Subject: [FFmpeg-devel] [PATCH] avutils/hwcontext_qsv: set the source
>> > device in qsv_device_create
>> >
>> > opencl_device_derive only handles AV_HWDEVICE_TYPE_VAAPI.
>> > We need a source device for qsv.
>> >
>> > this will fix following pipeline:
>> > ffmpeg -init_hw_device vaapi=intel:/dev/dri/renderD128 -init_hw_device
>> > opencl=ocl@intel -hwaccel qsv -c:v h264_qsv -hwaccel_output_format qsv
>> -i
>> > $input -filter_hw_device ocl -vf
>> > 'hwmap=derive_device=opencl,format=opencl,unsharp_opencl,hwmap=der
>> > ive_device=qsv:reverse=1:extra_hw_frames=32'  -c:v hevc_qsv  -y
>> test.h265
>> > ---
>> >  libavutil/hwcontext_qsv.c | 8 +++++++-
>> >  1 file changed, 7 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index
>> > 35a944f8f8..af3ee32cac 100644
>> > --- a/libavutil/hwcontext_qsv.c
>> > +++ b/libavutil/hwcontext_qsv.c
>> > @@ -1269,7 +1269,13 @@ static int qsv_device_create(AVHWDeviceContext
>> > *ctx, const char *device,
>> >
>> >      impl = choose_implementation(device);
>> >
>> > -    return qsv_device_derive_from_child(ctx, impl, child_device, 0);
>> > +    ret = qsv_device_derive_from_child(ctx, impl, child_device, 0);
>> > +    if (ret == 0) {
>> > +        ctx->internal->source_device =
>> av_buffer_ref(priv->child_device_ctx);
>> > +        if (!ctx->internal->source_device)
>> > +            ret = AVERROR(ENOMEM);
>> > +    }
>> > +    return ret;
>> >  }
>>
>> That's funny, I made almost the same change only two days ago:
>>
>>     impl = choose_implementation(device);
>>     ret = qsv_device_derive_from_child(ctx, impl, child_device, 0);
>>     if (ret >= 0)
>>         ctx->internal->source_device =
>> av_buffer_ref(priv->child_device_ctx);
>>
>>     return ret;
>>
>>
>> From my POV, this change is correct and required.
>>
> Glad to hear this. Thanks for the endorsement  :)
>
Hi softworkz,
Could you help merge this?
thanks


>> softworkz
>> _______________________________________________
>> 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/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 35a944f8f8..af3ee32cac 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -1269,7 +1269,13 @@  static int qsv_device_create(AVHWDeviceContext *ctx, const char *device,
 
     impl = choose_implementation(device);
 
-    return qsv_device_derive_from_child(ctx, impl, child_device, 0);
+    ret = qsv_device_derive_from_child(ctx, impl, child_device, 0);
+    if (ret == 0) {
+        ctx->internal->source_device = av_buffer_ref(priv->child_device_ctx);
+        if (!ctx->internal->source_device)
+            ret = AVERROR(ENOMEM);
+    }
+    return ret;
 }
 
 const HWContextType ff_hwcontext_type_qsv = {