fix[av1d]: add hdr metadata info to frame

Signed-off-by: shine.liu <shine.liu@rock-chips.com>
Signed-off-by: Yandong Lin <yandong.lin@rock-chips.com>
Change-Id: I713b357eb49e6f96267a64dc5c8239eaf2fa6f17
This commit is contained in:
shine.liu
2023-12-27 11:57:01 +08:00
committed by Herman Chen
parent d8472abf85
commit e2eeeb5764
3 changed files with 29 additions and 1 deletions

View File

@@ -491,6 +491,9 @@ static RK_S32 mpp_av1_color_config(AV1Context *ctx, BitReadCtx_t *gb,
fb(8, color_primaries);
fb(8, transfer_characteristics);
fb(8, matrix_coefficients);
if (current->transfer_characteristics == MPP_FRAME_TRC_BT2020_10 ||
current->transfer_characteristics == MPP_FRAME_TRC_SMPTEST2084)
ctx->is_hdr = 1;
} else {
infer(color_primaries, MPP_FRAME_PRI_UNSPECIFIED);
infer(transfer_characteristics, MPP_FRAME_TRC_UNSPECIFIED);
@@ -2276,6 +2279,9 @@ static RK_S32 mpp_av1_metadata_hdr_cll(AV1Context *ctx, BitReadCtx_t *gb,
fb(16, max_cll);
fb(16, max_fall);
ctx->content_light.MaxCLL = current->max_cll;
ctx->content_light.MaxFALL = current->max_fall;
return 0;
}
@@ -2298,6 +2304,15 @@ static RK_S32 mpp_av1_metadata_hdr_mdcv(AV1Context *ctx, BitReadCtx_t *gb,
fc(32, luminance_min, 0, MPP_MIN(((RK_U64)current->luminance_max << 6) - 1,
MAX_UINT_BITS(32)));
for (i = 0; i < 3; i++) {
ctx->mastering_display.display_primaries[i][0] = current->primary_chromaticity_x[i];
ctx->mastering_display.display_primaries[i][1] = current->primary_chromaticity_y[i];
}
ctx->mastering_display.white_point[0] = current->white_point_chromaticity_x;
ctx->mastering_display.white_point[1] = current->white_point_chromaticity_y;
ctx->mastering_display.max_luminance = current->luminance_max;
ctx->mastering_display.min_luminance = current->luminance_min;
return 0;
}
@@ -2978,7 +2993,7 @@ int mpp_av1_set_context_with_sequence(Av1CodecContext *ctx,
ctx->color_range =
seq->color_config.color_range ? MPP_FRAME_RANGE_JPEG : MPP_FRAME_RANGE_MPEG;
ctx->color_primaries = seq->color_config.color_primaries;
ctx->colorspace = seq->color_config.color_primaries;
ctx->colorspace = seq->color_config.matrix_coefficients;
ctx->color_trc = seq->color_config.transfer_characteristics;
switch (seq->color_config.chroma_sample_position) {

View File

@@ -746,6 +746,16 @@ static MPP_RET get_current_frame(Av1CodecContext *ctx)
if (s->is_hdr)
ctx->pix_fmt |= MPP_FRAME_HDR;
if (s->sequence_header->color_config.color_description_present_flag) {
mpp_frame_set_color_trc(frame->f, ctx->color_trc);
mpp_frame_set_color_primaries(frame->f, ctx->color_primaries);
mpp_frame_set_colorspace(frame->f, ctx->colorspace);
mpp_frame_set_color_range(frame->f, ctx->color_range);
}
mpp_frame_set_mastering_display(frame->f, s->mastering_display);
mpp_frame_set_content_light(frame->f, s->content_light);
if (MPP_FRAME_FMT_IS_FBC(s->cfg->base.out_fmt)) {
mpp_slots_set_prop(s->slots, SLOTS_HOR_ALIGN, hor_align_16);
if (s->bit_depth == 10) {

View File

@@ -21,6 +21,7 @@
#include "mpp_mem.h"
#include "mpp_bitread.h"
#include "mpp_frame.h"
#include "parser_api.h"
@@ -92,6 +93,8 @@ typedef struct AV1Context_t {
AV1Frame ref[AV1_NUM_REF_FRAMES];
AV1Frame cur_frame;
MppFrameMasteringDisplayMetadata mastering_display;
MppFrameContentLightMetadata content_light;
MppFrameHdrDynamicMeta *hdr_dynamic_meta;
RK_U32 hdr_dynamic;
RK_U32 is_hdr;