mirror of
https://mirror.skon.top/https://github.com/FFmpeg/FFmpeg
synced 2026-04-30 13:50:50 +08:00
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:
committed by
ArazIusubov
parent
7d57621b83
commit
6f75e879b6
@@ -25804,18 +25804,10 @@ vpp_amf=4096:2160:color_profile=bt2020
|
||||
@end example
|
||||
|
||||
@item
|
||||
Override display mastering, max CLL and max FALL metadata for filter input to represent those parameters:
|
||||
Primary G: x=0.2650 y=0.6900
|
||||
Primary B: x=0.1500 y=0.0600
|
||||
Primary R: x=0.6800 y=0.3200
|
||||
White point: x=0.3127 y=0.3290
|
||||
Max. luminance: 1100.0000 cd/m²
|
||||
Min. luminance: 0.0040 cd/m²
|
||||
MaxCLL: 1100 cd/m²
|
||||
MaxFALL: 400 cd/m²
|
||||
Override input primaries and input transfer characteristics, change both to bt709.
|
||||
|
||||
@example
|
||||
vpp_amf=color_profile=bt2020:in_trc=smpte2084:in_primaries=bt2020:master_display='G(13250,23460)B(7500,3000)R(34000,16000)WP(15635,16450)L(11000000,40)':max_cll='1100,400'
|
||||
vpp_amf=color_profile=bt2020:in_trc=smpte2084:in_primaries=bt2020:out_trc=bt709:out_primaries=bt709
|
||||
@end example
|
||||
@end itemize
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -232,24 +232,31 @@ int av_amf_light_metadata_to_hdrmeta(const AVContentLightMetadata *light_meta, A
|
||||
|
||||
int av_amf_extract_hdr_metadata(const AVFrame *frame, AMFHDRMetadata *hdrmeta)
|
||||
{
|
||||
AVFrameSideData *sidedata;
|
||||
AVFrameSideData *sidedata;
|
||||
AVContentLightMetadata *content_light = NULL;
|
||||
AVMasteringDisplayMetadata *mastering_display = NULL;
|
||||
|
||||
if (!frame || !hdrmeta)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
sidedata = av_frame_get_side_data(frame, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA);
|
||||
if (!sidedata)
|
||||
return AVERROR(ENODATA);
|
||||
|
||||
if (av_amf_display_mastering_meta_to_hdrmeta((AVMasteringDisplayMetadata *)sidedata->data, hdrmeta) != 0)
|
||||
return AVERROR(ENODATA);
|
||||
if (sidedata) {
|
||||
mastering_display = (AVMasteringDisplayMetadata *)sidedata->data;
|
||||
if (av_amf_display_mastering_meta_to_hdrmeta(mastering_display, hdrmeta) != 0)
|
||||
mastering_display = NULL;
|
||||
}
|
||||
|
||||
sidedata = av_frame_get_side_data(frame, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL);
|
||||
if (sidedata)
|
||||
av_amf_light_metadata_to_hdrmeta((AVContentLightMetadata *)sidedata->data, hdrmeta);
|
||||
if (sidedata) {
|
||||
content_light = (AVContentLightMetadata *)sidedata->data;
|
||||
if (av_amf_light_metadata_to_hdrmeta(content_light, hdrmeta) != 0)
|
||||
content_light = NULL;
|
||||
}
|
||||
|
||||
if (!mastering_display && !content_light)
|
||||
return AVERROR(ENODATA);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int av_amf_attach_hdr_metadata(AVFrame *frame, const AMFHDRMetadata *hdrmeta) {
|
||||
|
||||
Reference in New Issue
Block a user