Hi softworkz: Any updates on this patch? I want to submit pathes to qsv, but they depends on this patch
Thanks Wenbin > -----Original Message----- > From: ffmpeg-devel <ffmpeg-devel-boun...@ffmpeg.org> On Behalf Of Soft > Works > Sent: Thursday, August 19, 2021 3:52 PM > To: FFmpeg development discussions and patches <ffmpeg- > de...@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH v2] avutils/hwcontext: When deriving a > hwdevice, search for existing device in both directions > > > > > -----Original Message----- > > From: ffmpeg-devel <ffmpeg-devel-boun...@ffmpeg.org> On Behalf Of > Xiang, > > Haihao > > Sent: Thursday, 19 August 2021 09:37 > > To: ffmpeg-devel@ffmpeg.org > > Subject: Re: [FFmpeg-devel] [PATCH v2] avutils/hwcontext: When deriving a > > hwdevice, search for existing device in both directions > > > > On Fri, 2021-08-13 at 06:29 +0000, Xiang, Haihao wrote: > > > On Tue, 2021-08-10 at 09:52 +0000, Soft Works wrote: > > > > The test /libavutil/tests/hwdevice checks that when deriving a device > > > > from a source device and then deriving back to the type of the source > > > > device, the result is matching the original source device, i.e. the > > > > derivation mechanism doesn't create a new device in this case. > > > > > > [..] > > > > > > > video:143kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB > > muxing > > > overhead: unknown > > > corrupted size vs. prev_size in fastbins > > > Aborted > > > > > > > Hi Softworks, > > > > + child_device->internal->derived_devices[ctx->type] = > > av_buffer_create((uint8_t*)ctx, sizeof(*ctx), 0, ctx, 0); > > > > The above change introduces a new AVBufferRef for ctx. The first > AVBufferRef > > for > > ctx is created when function av_hwdevice_ctx_alloc is called. So there are > > two > > different AVBufferRefs referring to the same ctx, then ctx will be double- > > freed > > > > The change below is a bit ugly, but it may fix this double-free issue. > > > > +static void qsv_ctx_free(void *opaque, uint8_t *ctx) > > +{ > > + // Do nothing here > > + // ctx is freed in hwdevice_ctx_free > > +} > > + > > static int qsv_device_create(AVHWDeviceContext *ctx, const char *device, > > AVDictionary *opts, int flags) > > { > > @@ -1271,7 +1277,7 @@ static int qsv_device_create(AVHWDeviceContext > *ctx, > > const > > char *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_devices[ctx->type] = > > av_buffer_create((uint8_t*)ctx, sizeof(*ctx), 0, ctx, 0); > > + child_device->internal->derived_devices[ctx->type] = > > av_buffer_create((uint8_t*)ctx, sizeof(*ctx), qsv_ctx_free, ctx, 0); > > if (!child_device->internal->derived_devices[ctx->type]) { > > return AVERROR(ENOMEM); > > } > > Hi Haihao, > > sorry for getting back late and thanks for your suggested fix. > I'll apply it and submit a new patch version. > > Best regards, > 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-requ...@ffmpeg.org with subject "unsubscribe". _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".