mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-12-26 11:17:44 +01:00
feat[h264d]: support hdr meta parse
Signed-off-by: Yandong Lin <yandong.lin@rock-chips.com> Change-Id: Id17781edfe480c859a2e89909e517030ea07c43b
This commit is contained in:
parent
b9a9ba00d5
commit
d96a88673c
6 changed files with 72 additions and 8 deletions
|
|
@ -114,15 +114,26 @@ void fill_hdr_meta_to_frame(MppFrame frame, MppCodingType in_type)
|
|||
* hevc trc = 18
|
||||
* avs trc = 14
|
||||
* hdr10:
|
||||
* hevc trc = 16
|
||||
* hevc/h264 trc = 16
|
||||
* avs trc = 12
|
||||
*/
|
||||
if ((codec_type == HDR_HEVC && static_meta->color_trc == MPP_FRAME_TRC_ARIB_STD_B67) ||
|
||||
(codec_type == HDR_AVS2 && static_meta->color_trc == MPP_FRAME_TRC_BT2020_10))
|
||||
hdr_format = HLG;
|
||||
if ((codec_type == HDR_HEVC && static_meta->color_trc == MPP_FRAME_TRC_SMPTEST2084) ||
|
||||
(codec_type == HDR_AVS2 && static_meta->color_trc == MPP_FRAME_TRC_BT1361_ECG))
|
||||
hdr_format = HDR10;
|
||||
switch (codec_type) {
|
||||
case HDR_HEVC :
|
||||
case HDR_H264 : {
|
||||
if (static_meta->color_trc == MPP_FRAME_TRC_ARIB_STD_B67)
|
||||
hdr_format = HLG;
|
||||
else if (static_meta->color_trc == MPP_FRAME_TRC_SMPTEST2084)
|
||||
hdr_format = HDR10;
|
||||
} break;
|
||||
case HDR_AVS2 : {
|
||||
if (static_meta->color_trc == MPP_FRAME_TRC_BT2020_10)
|
||||
hdr_format = HLG;
|
||||
else if (static_meta->color_trc == MPP_FRAME_TRC_BT1361_ECG)
|
||||
hdr_format = HDR10;
|
||||
} break;
|
||||
default : {
|
||||
} break;
|
||||
}
|
||||
}
|
||||
off += hdr_static_meta_header->size;
|
||||
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ static MPP_RET free_cur_ctx(H264dCurCtx_t *p_Cur)
|
|||
|
||||
MPP_FREE(p_Cur->subsps);
|
||||
MPP_FREE(p_Cur->sei);
|
||||
MPP_FREE(p_Cur->hdr_dynamic_meta);
|
||||
}
|
||||
|
||||
__RETURN:
|
||||
|
|
|
|||
|
|
@ -971,6 +971,8 @@ typedef struct h264d_cur_ctx_t {
|
|||
RK_S32 abs_diff_view_idx_minus1[2][MAX_REORDER_TIMES];
|
||||
|
||||
struct h264_drpm_t *dec_ref_pic_marking_buffer[MAX_MARKING_TIMES];
|
||||
MppFrameHdrDynamicMeta *hdr_dynamic_meta;
|
||||
RK_U32 hdr_dynamic;
|
||||
} H264dCurCtx_t;
|
||||
|
||||
//!< parameters for video decoder
|
||||
|
|
|
|||
|
|
@ -546,6 +546,8 @@ static MPP_RET dpb_mark_malloc(H264dVideoCtx_t *p_Vid, H264_StorePic_t *dec_pic)
|
|||
impl->color_primaries = p->colour_primaries;
|
||||
impl->color_trc = p->transfer_characteristics;
|
||||
impl->colorspace = p->matrix_coefficients;
|
||||
if (impl->color_trc == MPP_FRAME_TRC_SMPTEST2084)
|
||||
impl->fmt |= MPP_FRAME_HDR;
|
||||
} else {
|
||||
impl->color_primaries = MPP_FRAME_PRI_UNSPECIFIED;
|
||||
impl->color_trc = MPP_FRAME_TRC_UNSPECIFIED;
|
||||
|
|
@ -553,6 +555,12 @@ static MPP_RET dpb_mark_malloc(H264dVideoCtx_t *p_Vid, H264_StorePic_t *dec_pic)
|
|||
}
|
||||
}
|
||||
|
||||
if (p_Vid->p_Cur->hdr_dynamic && p_Vid->p_Cur->hdr_dynamic_meta) {
|
||||
impl->hdr_dynamic_meta = p_Vid->p_Cur->hdr_dynamic_meta;
|
||||
p_Vid->p_Cur->hdr_dynamic = 0;
|
||||
impl->fmt |= MPP_FRAME_HDR;
|
||||
}
|
||||
|
||||
impl->poc = dec_pic->poc;
|
||||
impl->viewid = dec_pic->layer_id;
|
||||
impl->status.is_intra = dec_pic->slice_type == H264_I_SLICE;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include "h264d_sei.h"
|
||||
#include "h264d_init.h"
|
||||
#include "h264d_fill.h"
|
||||
#include "rk_hdr_meta_com.h"
|
||||
|
||||
#define HEAD_SYNTAX_MAX_SIZE (12800)
|
||||
#define NALU_TYPE_NORMAL_LENGTH (1)
|
||||
|
|
@ -336,6 +337,41 @@ __FAILED:
|
|||
return ret;
|
||||
}
|
||||
|
||||
void mpp_h264d_fill_dynamic_meta(H264dCurCtx_t *p_Cur, const RK_U8 *data, RK_U32 size, RK_U32 hdr_fmt)
|
||||
{
|
||||
MppFrameHdrDynamicMeta *hdr_dynamic_meta = p_Cur->hdr_dynamic_meta;
|
||||
|
||||
if (hdr_fmt == DOLBY)
|
||||
size += 4;
|
||||
|
||||
if (hdr_dynamic_meta && (hdr_dynamic_meta->size < size)) {
|
||||
mpp_free(hdr_dynamic_meta);
|
||||
hdr_dynamic_meta = NULL;
|
||||
}
|
||||
|
||||
if (!hdr_dynamic_meta) {
|
||||
hdr_dynamic_meta = mpp_calloc_size(MppFrameHdrDynamicMeta,
|
||||
sizeof(MppFrameHdrDynamicMeta) + size);
|
||||
if (!hdr_dynamic_meta) {
|
||||
mpp_err_f("malloc hdr dynamic data failed!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (size && data) {
|
||||
if (hdr_fmt == DOLBY) {
|
||||
RK_U8 start_code[4] = {0, 0, 0, 1};
|
||||
|
||||
memcpy((RK_U8*)hdr_dynamic_meta->data, start_code, 4);
|
||||
memcpy((RK_U8*)hdr_dynamic_meta->data + 4, (RK_U8*)data, size - 4);
|
||||
} else
|
||||
memcpy((RK_U8*)hdr_dynamic_meta->data, (RK_U8*)data, size);
|
||||
hdr_dynamic_meta->size = size;
|
||||
hdr_dynamic_meta->hdr_fmt = hdr_fmt;
|
||||
}
|
||||
p_Cur->hdr_dynamic_meta = hdr_dynamic_meta;
|
||||
p_Cur->hdr_dynamic = 1;
|
||||
}
|
||||
|
||||
static MPP_RET store_cur_nalu(H264dCurCtx_t *p_Cur, H264dCurStream_t *p_strm, H264dDxvaCtx_t *dxva_ctx)
|
||||
{
|
||||
MPP_RET ret = MPP_ERR_UNKNOW;
|
||||
|
|
@ -405,6 +441,11 @@ static MPP_RET store_cur_nalu(H264dCurCtx_t *p_Cur, H264dCurStream_t *p_strm, H2
|
|||
memcpy(p_des + sizeof(g_start_precode), p_strm->nalu_buf, p_strm->nalu_len);
|
||||
dxva_ctx->strm_offset += add_size;
|
||||
}
|
||||
|
||||
/* Dolby Vision RPUs masquerade as unregistered NALs of type 28. */
|
||||
if (p_strm->nalu_type == H264_NALU_TYPE_UNSPECIFIED28)
|
||||
mpp_h264d_fill_dynamic_meta(p_Cur, p_strm->nalu_buf + 2, p_strm->nalu_len - 2, DOLBY);
|
||||
|
||||
if (h264d_debug & H264D_DBG_WRITE_ES_EN) {
|
||||
H264dInputCtx_t *p_Inp = p_Cur->p_Inp;
|
||||
if ((p_strm->nalu_type == H264_NALU_TYPE_SPS)
|
||||
|
|
|
|||
|
|
@ -94,7 +94,8 @@ typedef enum H264NaluType_e {
|
|||
H264_NALU_TYPE_SUB_SPS = 15,
|
||||
H264_NALU_TYPE_SLICE_AUX = 19,
|
||||
H264_NALU_TYPE_SLC_EXT = 20, // slice extensive
|
||||
H264_NALU_TYPE_VDRD = 24 // View and Dependency Representation Delimiter NAL Unit
|
||||
H264_NALU_TYPE_VDRD = 24, // View and Dependency Representation Delimiter NAL Unit
|
||||
H264_NALU_TYPE_UNSPECIFIED28 = 28,
|
||||
} H264NaluType;
|
||||
|
||||
typedef enum H264ChromaFmt_e {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue