Revert "avutils/hwcontext: When deriving a hwdevice, search for existing device in both directions"
This reverts commit a428949775
.
There were objections on ML (see
https://ffmpeg.org/pipermail/ffmpeg-devel/2021-December/290530.html)
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
This commit is contained in:
parent
8d4c0c8823
commit
7c6f9b9d63
|
@ -122,7 +122,6 @@ static const AVClass hwdevice_ctx_class = {
|
||||||
static void hwdevice_ctx_free(void *opaque, uint8_t *data)
|
static void hwdevice_ctx_free(void *opaque, uint8_t *data)
|
||||||
{
|
{
|
||||||
AVHWDeviceContext *ctx = (AVHWDeviceContext*)data;
|
AVHWDeviceContext *ctx = (AVHWDeviceContext*)data;
|
||||||
int i;
|
|
||||||
|
|
||||||
/* uninit might still want access the hw context and the user
|
/* uninit might still want access the hw context and the user
|
||||||
* free() callback might destroy it, so uninit has to be called first */
|
* free() callback might destroy it, so uninit has to be called first */
|
||||||
|
@ -133,8 +132,6 @@ static void hwdevice_ctx_free(void *opaque, uint8_t *data)
|
||||||
ctx->free(ctx);
|
ctx->free(ctx);
|
||||||
|
|
||||||
av_buffer_unref(&ctx->internal->source_device);
|
av_buffer_unref(&ctx->internal->source_device);
|
||||||
for (i = 0; i < AV_HWDEVICE_TYPE_NB; i++)
|
|
||||||
av_buffer_unref(&ctx->internal->derived_devices[i]);
|
|
||||||
|
|
||||||
av_freep(&ctx->hwctx);
|
av_freep(&ctx->hwctx);
|
||||||
av_freep(&ctx->internal->priv);
|
av_freep(&ctx->internal->priv);
|
||||||
|
@ -646,26 +643,6 @@ fail:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static AVBufferRef* find_derived_hwdevice_ctx(AVBufferRef *src_ref, enum AVHWDeviceType type)
|
|
||||||
{
|
|
||||||
AVBufferRef *tmp_ref;
|
|
||||||
AVHWDeviceContext *src_ctx;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
src_ctx = (AVHWDeviceContext*)src_ref->data;
|
|
||||||
if (src_ctx->type == type)
|
|
||||||
return src_ref;
|
|
||||||
|
|
||||||
for (i = 0; i < AV_HWDEVICE_TYPE_NB; i++)
|
|
||||||
if (src_ctx->internal->derived_devices[i]) {
|
|
||||||
tmp_ref = find_derived_hwdevice_ctx(src_ctx->internal->derived_devices[i], type);
|
|
||||||
if (tmp_ref)
|
|
||||||
return tmp_ref;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int av_hwdevice_ctx_create_derived_opts(AVBufferRef **dst_ref_ptr,
|
int av_hwdevice_ctx_create_derived_opts(AVBufferRef **dst_ref_ptr,
|
||||||
enum AVHWDeviceType type,
|
enum AVHWDeviceType type,
|
||||||
AVBufferRef *src_ref,
|
AVBufferRef *src_ref,
|
||||||
|
@ -689,16 +666,6 @@ int av_hwdevice_ctx_create_derived_opts(AVBufferRef **dst_ref_ptr,
|
||||||
tmp_ref = tmp_ctx->internal->source_device;
|
tmp_ref = tmp_ctx->internal->source_device;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp_ref = find_derived_hwdevice_ctx(src_ref, type);
|
|
||||||
if (tmp_ref) {
|
|
||||||
dst_ref = av_buffer_ref(tmp_ref);
|
|
||||||
if (!dst_ref) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
dst_ref = av_hwdevice_ctx_alloc(type);
|
dst_ref = av_hwdevice_ctx_alloc(type);
|
||||||
if (!dst_ref) {
|
if (!dst_ref) {
|
||||||
ret = AVERROR(ENOMEM);
|
ret = AVERROR(ENOMEM);
|
||||||
|
@ -720,11 +687,6 @@ int av_hwdevice_ctx_create_derived_opts(AVBufferRef **dst_ref_ptr,
|
||||||
ret = AVERROR(ENOMEM);
|
ret = AVERROR(ENOMEM);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
tmp_ctx->internal->derived_devices[type] = av_buffer_ref(dst_ref);
|
|
||||||
if (!tmp_ctx->internal->derived_devices[type]) {
|
|
||||||
ret = AVERROR(ENOMEM);
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
ret = av_hwdevice_ctx_init(dst_ref);
|
ret = av_hwdevice_ctx_init(dst_ref);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
|
@ -37,7 +37,6 @@ enum AVHWDeviceType {
|
||||||
AV_HWDEVICE_TYPE_OPENCL,
|
AV_HWDEVICE_TYPE_OPENCL,
|
||||||
AV_HWDEVICE_TYPE_MEDIACODEC,
|
AV_HWDEVICE_TYPE_MEDIACODEC,
|
||||||
AV_HWDEVICE_TYPE_VULKAN,
|
AV_HWDEVICE_TYPE_VULKAN,
|
||||||
AV_HWDEVICE_TYPE_NB, ///< number of hw device types, not part of API/ABI.
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct AVHWDeviceInternal AVHWDeviceInternal;
|
typedef struct AVHWDeviceInternal AVHWDeviceInternal;
|
||||||
|
|
|
@ -109,12 +109,6 @@ struct AVHWDeviceInternal {
|
||||||
* context it was derived from.
|
* context it was derived from.
|
||||||
*/
|
*/
|
||||||
AVBufferRef *source_device;
|
AVBufferRef *source_device;
|
||||||
|
|
||||||
/**
|
|
||||||
* An array of reference to device contexts which
|
|
||||||
* were derived from this device.
|
|
||||||
*/
|
|
||||||
AVBufferRef *derived_devices[AV_HWDEVICE_TYPE_NB];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AVHWFramesInternal {
|
struct AVHWFramesInternal {
|
||||||
|
|
|
@ -274,7 +274,7 @@ static void qsv_frames_uninit(AVHWFramesContext *ctx)
|
||||||
av_buffer_unref(&s->child_frames_ref);
|
av_buffer_unref(&s->child_frames_ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qsv_release_dummy(void *opaque, uint8_t *data)
|
static void qsv_pool_release_dummy(void *opaque, uint8_t *data)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,7 +287,7 @@ static AVBufferRef *qsv_pool_alloc(void *opaque, size_t size)
|
||||||
if (s->nb_surfaces_used < hwctx->nb_surfaces) {
|
if (s->nb_surfaces_used < hwctx->nb_surfaces) {
|
||||||
s->nb_surfaces_used++;
|
s->nb_surfaces_used++;
|
||||||
return av_buffer_create((uint8_t*)(s->surfaces_internal + s->nb_surfaces_used - 1),
|
return av_buffer_create((uint8_t*)(s->surfaces_internal + s->nb_surfaces_used - 1),
|
||||||
sizeof(*hwctx->surfaces), qsv_release_dummy, NULL, 0);
|
sizeof(*hwctx->surfaces), qsv_pool_release_dummy, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1596,15 +1596,8 @@ static int qsv_device_create(AVHWDeviceContext *ctx, const char *device,
|
||||||
child_device = (AVHWDeviceContext*)priv->child_device_ctx->data;
|
child_device = (AVHWDeviceContext*)priv->child_device_ctx->data;
|
||||||
|
|
||||||
impl = choose_implementation(device, child_device_type);
|
impl = choose_implementation(device, child_device_type);
|
||||||
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), qsv_release_dummy, ctx, 0);
|
|
||||||
if (!child_device->internal->derived_devices[ctx->type])
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return qsv_device_derive_from_child(ctx, impl, child_device, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const HWContextType ff_hwcontext_type_qsv = {
|
const HWContextType ff_hwcontext_type_qsv = {
|
||||||
|
|
Loading…
Reference in New Issue