From: gan.zhang Date: Fri, 2 Oct 2020 09:51:50 +0000 (+0800) Subject: media: Pass the hdr10p data to the vpp. [2/2] X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8654f7f2484d9dbb96bc4640eefdfb6d1c85ccb9;p=GitHub%2FLineageOS%2FG12%2Fandroid_hardware_amlogic_kernel-modules_media.git media: Pass the hdr10p data to the vpp. [2/2] PD#SWPL-33535 Problem: No hdr10p data was passed to the vpp via vf. Solution: hdr10p data is passed to the vpp via vf. Verify: U212 Change-Id: Ic2ef7592f59c6cf8878b8f7414966476da7d0c71 Signed-off-by: gan.zhang --- diff --git a/drivers/frame_provider/decoder/h265/vh265.c b/drivers/frame_provider/decoder/h265/vh265.c index 07aa8ad..e905fe1 100644 --- a/drivers/frame_provider/decoder/h265/vh265.c +++ b/drivers/frame_provider/decoder/h265/vh265.c @@ -1455,6 +1455,8 @@ struct PIC_s { bool vframe_bound; bool ip_mode; u32 stream_frame_size; //for stream base + u32 hdr10p_data_size; + char *hdr10p_data_buf; } /*PIC_t */; #define MAX_TILE_COL_NUM 10 @@ -8133,8 +8135,22 @@ static int parse_sei(struct hevc_state_s *hevc, && p_sei[2] == 0x3C && p_sei[3] == 0x00 && p_sei[4] == 0x01 - && p_sei[5] == 0x04) + && p_sei[5] == 0x04) { + char *new_buf; hevc->sei_present_flag |= SEI_HDR10PLUS_MASK; + new_buf = vzalloc(payload_size); + if (new_buf) { + memcpy(new_buf, p_sei, payload_size); + pic->hdr10p_data_buf = new_buf; + pic->hdr10p_data_size = payload_size; + } else { + hevc_print(hevc, 0, + "%s:hdr10p data vzalloc size(%d) fail\n", + __func__, payload_size); + pic->hdr10p_data_buf = NULL; + pic->hdr10p_data_size = 0; + } + } break; case SEI_MasteringDisplayColorVolume: @@ -8394,6 +8410,41 @@ static void set_frame_info(struct hevc_state_s *hevc, struct vframe_s *vf, vdec_v4l_set_hdr_infos(ctx, &hdr); } + if ((hevc->sei_present_flag & SEI_HDR10PLUS_MASK) && (pic->hdr10p_data_buf != NULL) + && (pic->hdr10p_data_size != 0)) { + char *new_buf; + new_buf = vzalloc(pic->hdr10p_data_size); + + if (new_buf) { + memcpy(new_buf, pic->hdr10p_data_buf, pic->hdr10p_data_size); + if (get_dbg_flag(hevc) & H265_DEBUG_BUFMGR_MORE) { + hevc_print(hevc, 0, + "hdr10p data: (size %d)\n", + pic->hdr10p_data_size); + for (i = 0; i < pic->hdr10p_data_size; i++) { + hevc_print_cont(hevc, 0, + "%02x ", pic->hdr10p_data_buf[i]); + if (((i + 1) & 0xf) == 0) + hevc_print_cont(hevc, 0, "\n"); + } + hevc_print_cont(hevc, 0, "\n"); + } + + vf->hdr10p_data_size = pic->hdr10p_data_size; + vf->hdr10p_data_buf = new_buf; + } else { + hevc_print(hevc, 0, + "%s:hdr10p data vzalloc size(%d) fail\n", + __func__, pic->hdr10p_data_size); + vf->hdr10p_data_buf = NULL; + vf->hdr10p_data_size = 0; + } + + vfree(pic->hdr10p_data_buf); + pic->hdr10p_data_buf = NULL; + pic->hdr10p_data_size = 0; + } + vf->sidebind_type = hevc->sidebind_type; vf->sidebind_channel_id = hevc->sidebind_channel_id; } @@ -8651,6 +8702,12 @@ static void vh265_vf_put(struct vframe_s *vf, void *op_arg) kfifo_put(&hevc->newframe_q, (const struct vframe_s *)vf); spin_lock_irqsave(&lock, flags); + if (vf->hdr10p_data_buf) { + vfree(vf->hdr10p_data_buf); + vf->hdr10p_data_buf = NULL; + vf->hdr10p_data_size = 0; + } + if (index_top != 0xff && index_top < MAX_REF_PIC_NUM && hevc->m_PIC[index_top]) { diff --git a/drivers/frame_provider/decoder/utils/vdec.h b/drivers/frame_provider/decoder/utils/vdec.h index 16caa95..c4633fa 100644 --- a/drivers/frame_provider/decoder/utils/vdec.h +++ b/drivers/frame_provider/decoder/utils/vdec.h @@ -279,6 +279,10 @@ struct vdec_s { /*aux data check*/ struct aux_data_check_mgr_t adc; + + u32 hdr10p_data_size; + char hdr10p_data_buf[PAGE_SIZE]; + bool hdr10p_data_valid; }; /* common decoder vframe provider name to use default vfm path */ diff --git a/drivers/frame_provider/decoder/utils/vdec_input.c b/drivers/frame_provider/decoder/utils/vdec_input.c index 4eed7dc..bfe22bb 100644 --- a/drivers/frame_provider/decoder/utils/vdec_input.c +++ b/drivers/frame_provider/decoder/utils/vdec_input.c @@ -874,6 +874,26 @@ int vdec_input_add_chunk(struct vdec_input_s *input, const char *buf, return -ENOMEM; } + if ((vdec->hdr10p_data_valid == true) && + (vdec->hdr10p_data_size != 0)) { + char *new_buf; + new_buf = vzalloc(vdec->hdr10p_data_size); + if (new_buf) { + memcpy(new_buf, vdec->hdr10p_data_buf, vdec->hdr10p_data_size); + chunk->hdr10p_data_buf = new_buf; + chunk->hdr10p_data_size = vdec->hdr10p_data_size; + } else { + pr_err("%s:hdr10p data vzalloc size(%d) failed\n", + __func__, vdec->hdr10p_data_size); + chunk->hdr10p_data_buf = NULL; + chunk->hdr10p_data_size = 0; + } + } else { + chunk->hdr10p_data_buf = NULL; + chunk->hdr10p_data_size = 0; + } + vdec->hdr10p_data_valid = false; + chunk->magic = 0x4b554843; if (vdec->pts_valid) { chunk->pts = vdec->pts; diff --git a/drivers/frame_provider/decoder/utils/vdec_input.h b/drivers/frame_provider/decoder/utils/vdec_input.h index 3a6180b..c5d8b66 100644 --- a/drivers/frame_provider/decoder/utils/vdec_input.h +++ b/drivers/frame_provider/decoder/utils/vdec_input.h @@ -63,6 +63,8 @@ struct vframe_chunk_s { bool timestamp_valid; u64 sequence; struct vframe_block_list_s *block; + u32 hdr10p_data_size; + char *hdr10p_data_buf; }; #define VDEC_INPUT_TARGET_VLD 0 diff --git a/drivers/frame_provider/decoder/vp9/vvp9.c b/drivers/frame_provider/decoder/vp9/vvp9.c index 7aec5e7..92fb605 100644 --- a/drivers/frame_provider/decoder/vp9/vvp9.c +++ b/drivers/frame_provider/decoder/vp9/vvp9.c @@ -601,6 +601,10 @@ struct PIC_BUFFER_CONFIG_s { /* vdec sync. */ struct fence *fence; + + /* hdr10 plus data */ + u32 hdr10p_data_size; + char *hdr10p_data_buf; } PIC_BUFFER_CONFIG; enum BITSTREAM_PROFILE { @@ -6877,6 +6881,41 @@ static void set_frame_info(struct VP9Decoder_s *pbi, struct vframe_s *vf) vdec_v4l_set_hdr_infos(ctx, &hdr); } + if ((pbi->chunk != NULL) && (pbi->chunk->hdr10p_data_buf != NULL) + && (pbi->chunk->hdr10p_data_size != 0)) { + char *new_buf; + int i = 0; + new_buf = vzalloc(pbi->chunk->hdr10p_data_size); + + if (new_buf) { + memcpy(new_buf, pbi->chunk->hdr10p_data_buf, pbi->chunk->hdr10p_data_size); + if (debug & VP9_DEBUG_BUFMGR_MORE) { + vp9_print(pbi, VP9_DEBUG_BUFMGR_MORE, + "hdr10p data: (size %d)\n", + pbi->chunk->hdr10p_data_size); + for (i = 0; i < pbi->chunk->hdr10p_data_size; i++) { + vp9_print(pbi, VP9_DEBUG_BUFMGR_MORE, + "%02x ", pbi->chunk->hdr10p_data_buf[i]); + if (((i + 1) & 0xf) == 0) + vp9_print(pbi, VP9_DEBUG_BUFMGR_MORE, "\n"); + } + vp9_print(pbi, VP9_DEBUG_BUFMGR_MORE, "\n"); + } + + vf->hdr10p_data_size = pbi->chunk->hdr10p_data_size; + vf->hdr10p_data_buf = new_buf; + } else { + vp9_print(pbi, 0, "%s:hdr10p data vzalloc size(%d) fail\n", + __func__, pbi->chunk->hdr10p_data_size); + vf->hdr10p_data_size = pbi->chunk->hdr10p_data_size; + vf->hdr10p_data_buf = new_buf; + } + + vfree(pbi->chunk->hdr10p_data_buf); + pbi->chunk->hdr10p_data_buf = NULL; + pbi->chunk->hdr10p_data_size = 0; + } + vf->sidebind_type = pbi->sidebind_type; vf->sidebind_channel_id = pbi->sidebind_channel_id; } @@ -6963,6 +7002,12 @@ static void vvp9_vf_put(struct vframe_s *vf, void *op_arg) vf->fence = NULL; } + if (vf->hdr10p_data_buf) { + vfree(vf->hdr10p_data_buf); + vf->hdr10p_data_buf = NULL; + vf->hdr10p_data_size = 0; + } + kfifo_put(&pbi->newframe_q, (const struct vframe_s *)vf); pbi->vf_put_count++; if (index < pbi->used_buf_num) { diff --git a/drivers/stream_input/amports/amstream.c b/drivers/stream_input/amports/amstream.c index fc7092e..376d47d 100644 --- a/drivers/stream_input/amports/amstream.c +++ b/drivers/stream_input/amports/amstream.c @@ -2585,6 +2585,26 @@ static long amstream_ioctl_set_ptr(struct port_priv_s *priv, ulong arg) } else r = -EINVAL; break; + case AMSTREAM_SET_PTR_HDR10P_DATA: + if ((this->type & PORT_TYPE_VIDEO) && (this->type & PORT_TYPE_FRAME)) { + if (!parm.pointer || (parm.len <= 0) || + (parm.len > PAGE_SIZE)) { + r = -EINVAL; + } else { + r = copy_from_user(priv->vdec->hdr10p_data_buf, + parm.pointer, parm.len); + if (r) { + priv->vdec->hdr10p_data_size = 0; + priv->vdec->hdr10p_data_valid = false; + r = -EINVAL; + } else { + priv->vdec->hdr10p_data_size = parm.len; + priv->vdec->hdr10p_data_valid = true; + } + } + } else + r = -EINVAL; + break; default: r = -ENOIOCTLCMD; break;