decoder: no parser stream mode interface improve . [1/1]
authorshihong.zheng <shihong.zheng@amlogic.com>
Tue, 17 Nov 2020 08:15:47 +0000 (16:15 +0800)
committerHui Zhang <hui.zhang@amlogic.com>
Fri, 20 Nov 2020 03:24:13 +0000 (19:24 -0800)
PD#SWPL-37019

Problem:
demux first packet data is not start from
stream buf start addr;
tsplayer do not need 2nd filed offset.

Solution:
1.correct decode start wp rp at first packet;
2.set 2nd field offset invalid for tsplayer pts lookup.

Verify:
ah212

Change-Id: Ib9abc1066252da76d5951144af29eb83947c81ba
Signed-off-by: shihong.zheng <shihong.zheng@amlogic.com>
drivers/frame_provider/decoder/avs_multi/avs_multi.c
drivers/frame_provider/decoder/h264_multi/vmh264.c
drivers/frame_provider/decoder/mpeg12/vmpeg12_multi.c
drivers/frame_provider/decoder/mpeg4/vmpeg4_multi.c
drivers/frame_provider/decoder/utils/vdec.c
drivers/stream_input/amports/stream_buffer_base.c

index 5d3f9d33e41705f31afee68f3285d6b1a952386c..ae341c470cf5b7cf61465343e4f2c6e099ece54c 100644 (file)
@@ -3488,7 +3488,8 @@ static irqreturn_t vmavs_isr_thread_fn(struct vdec_s *vdec, int irq)
                                        set_vframe_pts(hw, decode_pic_count, vf);
 
                                if (vdec_stream_based(vdec) && (!vdec->vbuf.use_ptsserv)) {
-                                       vf->pts_us64 = offset;
+                                       vf->pts_us64 =
+                                               (((u64)vf->duration << 32) & 0xffffffff00000000) | offset;
                                        vf->pts = 0;
                                }
 
@@ -3570,7 +3571,7 @@ static irqreturn_t vmavs_isr_thread_fn(struct vdec_s *vdec, int irq)
                                        set_vframe_pts(hw, decode_pic_count, vf);
 
                                if (vdec_stream_based(vdec) && (!vdec->vbuf.use_ptsserv)) {
-                                       vf->pts_us64 = offset;
+                                       vf->pts_us64 = (u64)-1;
                                        vf->pts = 0;
                                }
                                debug_print(hw, PRINT_FLAG_PTS,
@@ -3670,7 +3671,8 @@ static irqreturn_t vmavs_isr_thread_fn(struct vdec_s *vdec, int irq)
                                        set_vframe_pts(hw, decode_pic_count, vf);
 
                                if (vdec_stream_based(vdec) && (!vdec->vbuf.use_ptsserv)) {
-                                       vf->pts_us64 = offset;
+                                       vf->pts_us64 =
+                                               (((u64)vf->duration << 32) & 0xffffffff00000000) | offset;
                                        vf->pts = 0;
                                }
                                vdec_vframe_ready(hw_to_vdec(hw), vf);
index c7b38e08d2f5e5cb102c627f5a9d66105ca6029b..e9ef17139742a6e8395d51dd1c2ce41f536d1044 100644 (file)
@@ -3073,8 +3073,16 @@ static int post_video_frame(struct vdec_s *vdec, struct FrameStore *frame)
                vf->sar_width = hw->width_aspect_ratio;
                vf->sar_height = hw->height_aspect_ratio;
                if (!vdec->vbuf.use_ptsserv && vdec_stream_based(vdec)) {
-                       vf->pts_us64 = frame->offset_delimiter;
-                       vf->pts = 0;
+                       /* offset for tsplayer pts lookup */
+                       if (i == 0) {
+                               vf->pts_us64 =
+                                       (((u64)vf->duration << 32) &
+                                       0xffffffff00000000) | frame->offset_delimiter;
+                               vf->pts = 0;
+                       } else {
+                               vf->pts_us64 = (u64)-1;
+                               vf->pts = 0;
+                       }
                }
                kfifo_put(&hw->display_q, (const struct vframe_s *)vf);
                ATRACE_COUNTER(MODULE_NAME, vf->pts);
index c487aac3de4a02f4d3d4762ba1922213a06e348f..48dc24988d820ac4bf259c5c2be79c77e9789e12 100644 (file)
@@ -1687,8 +1687,16 @@ static int prepare_display_buf(struct vdec_mpeg12_hw_s *hw,
                                decoder_bmmu_box_get_mem_handle(
                                hw->mm_blk_handle, index);
                        if (!vdec->vbuf.use_ptsserv && vdec_stream_based(vdec)) {
-                               vf->pts_us64 = pic->offset;
-                               vf->pts = 0;
+                               /* offset for tsplayer pts lookup */
+                               if (i == 0) {
+                                       vf->pts_us64 =
+                                               (((u64)vf->duration << 32) &
+                                               0xffffffff00000000) | pic->offset;
+                                       vf->pts = 0;
+                               } else {
+                                       vf->pts_us64 = (u64)-1;
+                                       vf->pts = 0;
+                               }
                        }
                        kfifo_put(&hw->display_q,
                                (const struct vframe_s *)vf);
index 860fcadb19ea4efe72a5809055a35f4a2876a02f..ad76deee95911517f7e6ba15cda926c27b610507 100644 (file)
@@ -717,7 +717,9 @@ static int prepare_display_buf(struct vdec_mpeg4_hw_s * hw,
                        vf->pts, vf->pts_us64, vf->width, vf->height, vf->duration);
 
                if (vdec_stream_based(vdec) && (!vdec->vbuf.use_ptsserv)) {
-                       vf->pts_us64 = pic->offset;
+                       vf->pts_us64 =
+                               (((u64)vf->duration << 32) &
+                               0xffffffff00000000) | pic->offset;
                        vf->pts = 0;
                }
                if (((hw->first_i_frame_ready == 0) || pb_skip)
@@ -786,7 +788,7 @@ static int prepare_display_buf(struct vdec_mpeg4_hw_s * hw,
                        vf->pts, vf->pts_us64, vf->width, vf->height, vf->duration);
 
                if (vdec_stream_based(vdec) && (!vdec->vbuf.use_ptsserv)) {
-                       vf->pts_us64 = pic->offset;
+                       vf->pts_us64 = (u64)-1;
                        vf->pts = 0;
                }
 
@@ -870,7 +872,9 @@ static int prepare_display_buf(struct vdec_mpeg4_hw_s * hw,
                        vf->pts, vf->pts_us64, vf->width, vf->height, vf->duration);
 
                if (vdec_stream_based(vdec) && (!vdec->vbuf.use_ptsserv)) {
-                       vf->pts_us64 = pic->offset;
+                       vf->pts_us64 =
+                               (((u64)vf->duration << 32) &
+                               0xffffffff00000000) | pic->offset;
                        vf->pts = 0;
                }
 
index 4e2e7703cc36a3c1799ff330bee93299e60d802d..df1048074bb554905e5ec709531687e5900e4839 100644 (file)
@@ -1476,7 +1476,7 @@ int vdec_prepare_input(struct vdec_s *vdec, struct vframe_chunk_s **p)
 
        } else {
                /* stream based */
-               u32 rp = 0, wp = 0, fifo_len = 0;
+               u32 rp = 0, wp = 0, fifo_len = 0, first_set_rp = 0;
                int size;
                bool swap_valid = input->swap_valid;
                unsigned long swap_page_phys = input->swap_page_phys;
@@ -1570,20 +1570,28 @@ int vdec_prepare_input(struct vdec_s *vdec, struct vframe_chunk_s **p)
                        }
 
                } else {
+                       if (vdec->vbuf.ext_buf_addr) {
+                               first_set_rp =
+                                       STBUF_READ(&vdec->vbuf, get_rp);
+                               first_set_rp =
+                                       round_down(first_set_rp, VDEC_FIFO_ALIGN);
+                       } else
+                               first_set_rp = input->start;
+
                        if (input->target == VDEC_INPUT_TARGET_VLD) {
                                WRITE_VREG(VLD_MEM_VIFIFO_START_PTR,
                                        input->start);
                                WRITE_VREG(VLD_MEM_VIFIFO_END_PTR,
                                        input->start + input->size - 8);
                                WRITE_VREG(VLD_MEM_VIFIFO_CURR_PTR,
-                                       input->start);
+                                       first_set_rp);
 
                                WRITE_VREG(VLD_MEM_VIFIFO_CONTROL, 1);
                                WRITE_VREG(VLD_MEM_VIFIFO_CONTROL, 0);
 
                                /* set to manual mode */
                                WRITE_VREG(VLD_MEM_VIFIFO_BUF_CNTL, 2);
-                               WRITE_VREG(VLD_MEM_VIFIFO_RP, input->start);
+                               WRITE_VREG(VLD_MEM_VIFIFO_RP, first_set_rp);
                                WRITE_VREG(VLD_MEM_VIFIFO_WP,
                                        STBUF_READ(&vdec->vbuf, get_wp));
                                rp = READ_VREG(VLD_MEM_VIFIFO_RP);
@@ -1603,7 +1611,7 @@ int vdec_prepare_input(struct vdec_s *vdec, struct vframe_chunk_s **p)
                                WRITE_VREG(HEVC_STREAM_END_ADDR,
                                        input->start + input->size);
                                WRITE_VREG(HEVC_STREAM_RD_PTR,
-                                       input->start);
+                                       first_set_rp);
                                WRITE_VREG(HEVC_STREAM_WR_PTR,
                                        STBUF_READ(&vdec->vbuf, get_wp));
                                rp = READ_VREG(HEVC_STREAM_RD_PTR);
index 6801301a7a5d12c2d8be19035fe6dec7e44356d1..bc6560a2a9bbe3d93deebf87068973a605bba712 100644 (file)
@@ -134,14 +134,17 @@ void stream_buffer_meta_write(struct stream_buf_s *stbuf,
        if ((stbuf->stream_offset == 0) &&
                (wp == stbuf->ext_buf_addr) &&
                (meta->stbuf_pktaddr > stbuf->ext_buf_addr)) {
-               struct stream_buffer_metainfo self_meta;
+               struct vdec_s *vdec = container_of(stbuf, struct vdec_s, vbuf);
 
                pr_info("warn: first packet_wp(%x) is not stbuf start addr(%lx)\n",
                        meta->stbuf_pktaddr, stbuf->ext_buf_addr);
 
-               self_meta.stbuf_pktaddr = stbuf->ext_buf_addr;
-               self_meta.stbuf_pktsize = meta->stbuf_pktaddr - stbuf->ext_buf_addr;
-               stream_buffer_meta_write(stbuf, &self_meta);
+               stbuf->ops->set_wp(stbuf, meta->stbuf_pktaddr);
+               stbuf->ops->set_rp(stbuf, meta->stbuf_pktaddr);
+               vdec->input.swap_rp = meta->stbuf_pktaddr;
+               if (vdec->slave)
+                       vdec->slave->input.swap_rp = meta->stbuf_pktaddr;
+               stbuf->stream_offset += (meta->stbuf_pktaddr - stbuf->ext_buf_addr);
        }
 
        if (meta->stbuf_pktaddr + meta->stbuf_pktsize < stbuf->buf_start + stbuf->buf_size)
@@ -156,6 +159,7 @@ void stream_buffer_meta_write(struct stream_buf_s *stbuf,
        pr_debug("%s, update wp 0x%x + sz 0x%x --> 0x%x, stream_offset 0x%x\n",
                __func__, meta->stbuf_pktaddr, meta->stbuf_pktsize, wp, stbuf->stream_offset);
        */
+
 }
 EXPORT_SYMBOL(stream_buffer_meta_write);