avfilter/vf_vpp_amf: Minor clean up.

-vf_vpp_amf.c: Remove unused variables.
-vf_amf_common.c: Fix hdrmeta_buffer memory leak.
-hwcontext_amf.c: Fix av_amf_extract_hdr_metadata not picking up light metadata if display mastering metadata is not set.
-doc/filters.texi: Remove irrelevant example with HDR metadata for vpp_amf.
This commit is contained in:
Dmitrii Gershenkop
2026-03-18 15:43:25 +01:00
committed by ArazIusubov
parent 7d57621b83
commit 6f75e879b6
4 changed files with 24 additions and 25 deletions

View File

@@ -452,6 +452,7 @@ int amf_avframe_to_amfsurface(AVFilterContext *avctx, const AVFrame *frame, AMFS
{
AMFVariantStruct var = { 0 };
AMFFilterContext *ctx = avctx->priv;
AMFBuffer *hdrmeta_buffer = NULL;
AMFSurface *surface;
AMF_RESULT res;
int hw_surface = 0;
@@ -541,7 +542,6 @@ int amf_avframe_to_amfsurface(AVFilterContext *avctx, const AVFrame *frame, AMFS
}
if (ctx->in_trc == AMF_COLOR_TRANSFER_CHARACTERISTIC_SMPTE2084 && (ctx->master_display || ctx->light_meta)) {
AMFBuffer *hdrmeta_buffer = NULL;
res = ctx->amf_device_ctx->context->pVtbl->AllocBuffer(ctx->amf_device_ctx->context, AMF_MEMORY_HOST, sizeof(AMFHDRMetadata), &hdrmeta_buffer);
if (res == AMF_OK) {
AMFHDRMetadata *hdrmeta = (AMFHDRMetadata*)hdrmeta_buffer->pVtbl->GetNative(hdrmeta_buffer);
@@ -553,18 +553,21 @@ int amf_avframe_to_amfsurface(AVFilterContext *avctx, const AVFrame *frame, AMFS
} else if (frame->color_trc == AVCOL_TRC_SMPTE2084) {
res = surface->pVtbl->GetProperty(surface, AMF_VIDEO_DECODER_HDR_METADATA, &var);
if (res == AMF_NOT_FOUND) {
AMFBuffer *hdrmeta_buffer = NULL;
res = ctx->amf_device_ctx->context->pVtbl->AllocBuffer(ctx->amf_device_ctx->context, AMF_MEMORY_HOST, sizeof(AMFHDRMetadata), &hdrmeta_buffer);
if (res == AMF_OK) {
AMFHDRMetadata *hdrmeta = (AMFHDRMetadata*)hdrmeta_buffer->pVtbl->GetNative(hdrmeta_buffer);
if (av_amf_extract_hdr_metadata(frame, hdrmeta) == 0)
AMF_ASSIGN_PROPERTY_INTERFACE(res, surface, AMF_VIDEO_DECODER_HDR_METADATA, hdrmeta_buffer);
hdrmeta_buffer->pVtbl->Release(hdrmeta_buffer);
}
}
}
if (hdrmeta_buffer) {
hdrmeta_buffer->pVtbl->Release(hdrmeta_buffer);
hdrmeta_buffer = NULL;
}
if (frame->crop_left || frame->crop_right || frame->crop_top || frame->crop_bottom) {
size_t crop_x = frame->crop_left;
size_t crop_y = frame->crop_top;

View File

@@ -85,14 +85,11 @@ static int amf_filter_config_output(AVFilterLink *outlink)
AMFBuffer *hdrmeta_buffer = NULL;
AMFHDRMetadata *hdrmeta = NULL;
AMFSize out_size;
size_t size = 0;
int ret;
AMF_RESULT res;
const AVFrameSideData *sd;
enum AMF_VIDEO_CONVERTER_COLOR_PROFILE_ENUM amf_color_profile;
enum AVPixelFormat in_format;
const int chroma_den = 50000;
const int luma_den = 10000;
ret = amf_init_filter_config(outlink, &in_format);
if (ret < 0)