[FFmpeg-devel] [PATCH] avutils/hwcontext: When deriving a hwdevice, search for existing device in both directions
Soft Works
softworkz at hotmail.com
Tue Aug 10 12:06:53 EEST 2021
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of
> Xiang, Haihao
> Sent: Monday, 9 August 2021 09:27
> To: ffmpeg-devel at ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH] avutils/hwcontext: When deriving a
> hwdevice, search for existing device in both directions
>
> On Sat, 2021-08-07 at 01:46 +0000, Soft Works wrote:
[...]
> > if (ret == 0) {
> > dst_ctx->internal->source_device =
> > av_buffer_ref(src_ref);
> > + tmp_ctx->internal->derived_device =
> > + av_buffer_ref(dst_ref);
> > if (!dst_ctx->internal->source_device) {
>
> Need to check tmp_ctx->internal->derived_device too.
>
> > ret = AVERROR(ENOMEM);
> > goto fail;
> > diff --git a/libavutil/hwcontext_internal.h
> > b/libavutil/hwcontext_internal.h index e6266494ac..cfe525d20c 100644
> > --- a/libavutil/hwcontext_internal.h
> > +++ b/libavutil/hwcontext_internal.h
> > @@ -109,6 +109,12 @@ struct AVHWDeviceInternal {
> > * context it was derived from.
> > */
> > AVBufferRef *source_device;
> > +
> > + /**
> > + * A reference to a device context which
> > + * was derived from this device.
> > + */
> > + AVBufferRef *derived_device;
> > };
> >
> > struct AVHWFramesInternal {
> > diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
> > index 08a6e0ee1c..27d96d116f 100644
> > --- a/libavutil/hwcontext_qsv.c
> > +++ b/libavutil/hwcontext_qsv.c
> > @@ -1268,8 +1268,13 @@ static int
> qsv_device_create(AVHWDeviceContext
> > *ctx, const char *device,
> > child_device = (AVHWDeviceContext*)priv->child_device_ctx->data;
> >
> > 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);
> > + child_device->internal->derived_device =
> > av_buffer_create((uint8_t*)ctx, sizeof(*ctx), 0, ctx, 0);
>
> Need to check the new references here.
Added checks in the next update.
Thanks a lot for reviewing.
softworkz
More information about the ffmpeg-devel
mailing list