hevc: remove first packet offset for hevc. [1/1]
authorshihong.zheng <shihong.zheng@amlogic.com>
Tue, 24 Nov 2020 09:11:27 +0000 (17:11 +0800)
committerHui Zhang <hui.zhang@amlogic.com>
Tue, 1 Dec 2020 03:11:09 +0000 (19:11 -0800)
PD#SWPL-37489

Problem:
hevc picture stream offset is not based on
streambuf start. it get from shiftbyte count.
so it's wrong to add first wp.

Solution:
remove first packet offset for hevc.

Verify:
ah212

Change-Id: I51e4fa9a1f8e41fcddfa02531ead11124a9cfccf
Signed-off-by: shihong.zheng <shihong.zheng@amlogic.com>
drivers/frame_provider/decoder/utils/vdec.c
drivers/stream_input/amports/stream_buffer_base.c

index a096e306953623fe58f4a61354cd32377ebfd5b2..d8c2c1174498db0d2b47ba7c4e0436bc84e79e42 100644 (file)
@@ -1638,12 +1638,9 @@ 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
+                       if (vdec->vbuf.ext_buf_addr)
+                               first_set_rp = STBUF_READ(&vdec->vbuf, get_rp);
+                       else
                                first_set_rp = input->start;
 
                        if (input->target == VDEC_INPUT_TARGET_VLD) {
index bc6560a2a9bbe3d93deebf87068973a605bba712..a7e525908084349f6885bc26f83b6a0e220434d9 100644 (file)
@@ -135,16 +135,32 @@ void stream_buffer_meta_write(struct stream_buf_s *stbuf,
                (wp == stbuf->ext_buf_addr) &&
                (meta->stbuf_pktaddr > stbuf->ext_buf_addr)) {
                struct vdec_s *vdec = container_of(stbuf, struct vdec_s, vbuf);
+               u32 first_ptr;
+               u32 round_down_size = 0;
+
+               /*RP max alignment requirement*/
+               if (vdec->input.target == VDEC_INPUT_TARGET_HEVC)
+                       round_down_size = 0x80;
+               else if (vdec->input.target == VDEC_INPUT_TARGET_VLD)
+                       round_down_size = 0x100;
+
+               if (stbuf->ext_buf_addr > (meta->stbuf_pktaddr - round_down_size))
+                       first_ptr = stbuf->ext_buf_addr;
+               else {
+                       first_ptr = round_down(meta->stbuf_pktaddr, round_down_size);
+                       pr_info("warn: first packet_wp(%x round_down %x) is not stbuf start addr(%lx)\n",
+                               meta->stbuf_pktaddr, first_ptr, stbuf->ext_buf_addr);
+               }
 
-               pr_info("warn: first packet_wp(%x) is not stbuf start addr(%lx)\n",
-                       meta->stbuf_pktaddr, stbuf->ext_buf_addr);
-
-               stbuf->ops->set_wp(stbuf, meta->stbuf_pktaddr);
-               stbuf->ops->set_rp(stbuf, meta->stbuf_pktaddr);
-               vdec->input.swap_rp = meta->stbuf_pktaddr;
+               stbuf->ops->set_wp(stbuf, first_ptr);
+               stbuf->ops->set_rp(stbuf, first_ptr);
+               vdec->input.swap_rp = first_ptr;
                if (vdec->slave)
-                       vdec->slave->input.swap_rp = meta->stbuf_pktaddr;
-               stbuf->stream_offset += (meta->stbuf_pktaddr - stbuf->ext_buf_addr);
+                       vdec->slave->input.swap_rp = first_ptr;
+               if (vdec->input.target != VDEC_INPUT_TARGET_HEVC)
+                       stbuf->stream_offset += (meta->stbuf_pktaddr - stbuf->ext_buf_addr);
+               else
+                       stbuf->stream_offset += (meta->stbuf_pktaddr - first_ptr);
        }
 
        if (meta->stbuf_pktaddr + meta->stbuf_pktsize < stbuf->buf_start + stbuf->buf_size)
@@ -159,7 +175,6 @@ 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);