media: Pass the hdr10p data to the vpp. [2/2]
authorgan.zhang <gan.zhang@amlogic.com>
Fri, 2 Oct 2020 09:51:50 +0000 (17:51 +0800)
committerHui Zhang <hui.zhang@amlogic.com>
Fri, 23 Oct 2020 05:06:13 +0000 (22:06 -0700)
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 <gan.zhang@amlogic.com>
drivers/frame_provider/decoder/h265/vh265.c
drivers/frame_provider/decoder/utils/vdec.h
drivers/frame_provider/decoder/utils/vdec_input.c
drivers/frame_provider/decoder/utils/vdec_input.h
drivers/frame_provider/decoder/vp9/vvp9.c
drivers/stream_input/amports/amstream.c

index 07aa8adb8a3f569910693fec1fb69a31fb23a0c8..e905fe1ade3b0af34d4cc212e768b7d055b9cde9 100644 (file)
@@ -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]) {
index 16caa952c36100251bf8e8ab12a53e307e401d2a..c4633faad48277feaa7174bc3a301abdef7fb829 100644 (file)
@@ -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 */
index 4eed7dc909d7314d1ce701c9e6da9167e22e6680..bfe22bbbaf7fa63d68862aafdc74a05df4278b5b 100644 (file)
@@ -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;
index 3a6180b83771ebcefbcd910988d746f8e6437441..c5d8b66aca79a3f34661297856e75558b63b7e79 100644 (file)
@@ -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
index 7aec5e7a2e7d03115d46dddf247d9dedf8569991..92fb6054f10f67e150c8765f5d2402f90d72836e 100644 (file)
@@ -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) {
index fc7092e1eb67d8e50491f23f5fd9f5ca0c98a854..376d47dec9bc1f6f594a715ad53939d35b51cc12 100644 (file)
@@ -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;