amstream: add pts checkin for no parser mode. [2/2]
authorshihong.zheng <shihong.zheng@amlogic.com>
Wed, 15 Jul 2020 06:04:42 +0000 (14:04 +0800)
committershihong.zheng <shihong.zheng@amlogic.com>
Wed, 26 Aug 2020 03:14:59 +0000 (11:14 +0800)
PD#SWPL-25652

Problem:
1. pts checkin with error offset in no parser mode.
2. decode driver output offset for no pts server mode.

Solution:
1. add stream offset, and update the checkin interface;
2. lookup pts when set use pts server enable;
3. when not use pts server, the pts_us64 in vf is offset.

Verify:
AH219

Change-Id: Ie5ea52decb4bad162f3526f03e714244a0481c3d
Signed-off-by: shihong.zheng <shihong.zheng@amlogic.com>
13 files changed:
drivers/frame_provider/decoder/avs2/vavs2.c
drivers/frame_provider/decoder/avs_multi/avs_multi.c
drivers/frame_provider/decoder/h264_multi/vmh264.c
drivers/frame_provider/decoder/h265/vh265.c
drivers/frame_provider/decoder/mjpeg/vmjpeg_multi.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/frame_provider/decoder/vp9/vvp9.c
drivers/stream_input/amports/amstream.c
drivers/stream_input/amports/stream_buffer_base.c
drivers/stream_input/amports/stream_buffer_interface.c
drivers/stream_input/amports/streambuf.h

index 8b03a3c6dbd2e4124268afe1af82acb25c8a0245..50df9896e19444e4aebfd5868d60932521102cf8 100644 (file)
@@ -4318,6 +4318,7 @@ static void set_vframe(struct AVS2Decoder_s *dec,
        int stream_offset;
        unsigned int frame_size = 0;
        int pts_discontinue;
+       struct vdec_s *vdec = hw_to_vdec(dec);
        stream_offset = pic->stream_offset;
        avs2_print(dec, AVS2_DBG_BUFMGR,
                "%s index = %d pos = %d\r\n",
@@ -4331,22 +4332,25 @@ static void set_vframe(struct AVS2Decoder_s *dec,
 
        if (!dummy) {
 #ifdef MULTI_INSTANCE_SUPPORT
-               if (vdec_frame_based(hw_to_vdec(dec))) {
+               if (vdec_frame_based(vdec)) {
                        vf->pts = pic->pts;
                        vf->pts_us64 = pic->pts64;
-               } else
+               } else {
 #endif
-               /* if (pts_lookup_offset(PTS_TYPE_VIDEO,
-                  stream_offset, &vf->pts, 0) != 0) { */
-               if (pts_lookup_offset_us64
-                       (PTS_TYPE_VIDEO, stream_offset,
-                       &vf->pts, &frame_size, 0,
-                        &vf->pts_us64) != 0) {
+                       if ((vdec->vbuf.no_parser == 0) || (vdec->vbuf.use_ptsserv)) {
+                               /* if (pts_lookup_offset(PTS_TYPE_VIDEO,
+                          stream_offset, &vf->pts, 0) != 0) { */
+                               if (pts_lookup_offset_us64
+                                       (PTS_TYPE_VIDEO, stream_offset,
+                                       &vf->pts, &frame_size, 0,
+                                        &vf->pts_us64) != 0) {
 #ifdef DEBUG_PTS
-                       dec->pts_missed++;
+                                       dec->pts_missed++;
 #endif
-                       vf->pts = 0;
-                       vf->pts_us64 = 0;
+                                       vf->pts = 0;
+                                       vf->pts_us64 = 0;
+                               }
+                       }
                }
 #ifdef DEBUG_PTS
                else
@@ -4535,7 +4539,10 @@ static void set_vframe(struct AVS2Decoder_s *dec,
                        dec->bmmu_box,
                        VF_BUFFER_IDX(pic->index));
 #endif
-
+       if (!vdec->vbuf.use_ptsserv && vdec_stream_based(vdec)) {
+               vf->pts_us64 = stream_offset;
+               vf->pts = 0;
+       }
        if (!dummy) {
                lock_buffer(dec, flags);
                pic->vf_ref = 1;
index d806fec9bc78962f05885d07f93a5d4862acc593..f395669ec27cd3691af5b2d6ca3649d99fbe7307 100644 (file)
@@ -3316,17 +3316,18 @@ static irqreturn_t vmavs_isr_thread_fn(struct vdec_s *vdec, int irq)
                        if (pts_by_offset) {
                                offset = READ_VREG(AVS_OFFSET_REG);
                                debug_print(hw, PRINT_FLAG_DECODING, "AVS OFFSET=%x\n", offset);
-                               if (pts_lookup_offset_us64(PTS_TYPE_VIDEO, offset, &pts,
-                                       &frame_size,
-                                       0, &pts_us64) == 0) {
-                                       pts_valid = 1;
+                               if ((vdec->vbuf.no_parser == 0) || (vdec->vbuf.use_ptsserv)) {
+                                       if (pts_lookup_offset_us64(PTS_TYPE_VIDEO, offset, &pts,
+                                               &frame_size, 0, &pts_us64) == 0) {
+                                               pts_valid = 1;
 #ifdef DEBUG_PTS
-                                       hw->pts_hit++;
+                                               hw->pts_hit++;
 #endif
-                               } else {
+                                       } else {
 #ifdef DEBUG_PTS
-                                       hw->pts_missed++;
+                                               hw->pts_missed++;
 #endif
+                                       }
                                }
                        }
        
@@ -3459,7 +3460,10 @@ static irqreturn_t vmavs_isr_thread_fn(struct vdec_s *vdec, int irq)
        
                                if (hw->m_ins_flag && vdec_frame_based(hw_to_vdec(hw)))
                                        set_vframe_pts(hw, decode_pic_count, vf);
-       
+                               if (vdec_stream_based(vdec) && (!vdec->vbuf.use_ptsserv)) {
+                                       vf->pts_us64 = offset;
+                                       vf->pts = 0;
+                               }
                                kfifo_put(&hw->display_q,
                                                  (const struct vframe_s *)vf);
                                avs_vf_notify_receiver(hw, PROVIDER_NAME,
@@ -3530,7 +3534,11 @@ static irqreturn_t vmavs_isr_thread_fn(struct vdec_s *vdec, int irq)
        
                                if (hw->m_ins_flag && vdec_frame_based(hw_to_vdec(hw)))
                                        set_vframe_pts(hw, decode_pic_count, vf);
-       
+
+                               if (vdec_stream_based(vdec) && (!vdec->vbuf.use_ptsserv)) {
+                                       vf->pts_us64 = offset;
+                                       vf->pts = 0;
+                               }
                                kfifo_put(&hw->display_q,
                                                  (const struct vframe_s *)vf);
                                avs_vf_notify_receiver(hw, PROVIDER_NAME,
@@ -3619,7 +3627,11 @@ static irqreturn_t vmavs_isr_thread_fn(struct vdec_s *vdec, int irq)
        
                                if (hw->m_ins_flag && vdec_frame_based(hw_to_vdec(hw)))
                                        set_vframe_pts(hw, decode_pic_count, vf);
-       
+
+                               if (vdec_stream_based(vdec) && (!vdec->vbuf.use_ptsserv)) {
+                                       vf->pts_us64 = offset;
+                                       vf->pts = 0;
+                               }
                                kfifo_put(&hw->display_q,
                                                  (const struct vframe_s *)vf);
                                avs_vf_notify_receiver(hw, PROVIDER_NAME,
index a19a634881f68f78a64bab6923e44541cbc75f83..715a0c0cd572661082a4dda597700dda0760f089 100644 (file)
@@ -2748,14 +2748,16 @@ int prepare_display_buf(struct vdec_s *vdec, struct FrameStore *frame)
                        frame->data_flag |= ERROR_FLAG;
        }
        if (vdec_stream_based(vdec) && !(frame->data_flag & NODISP_FLAG)) {
-               if ((pts_lookup_offset_us64(PTS_TYPE_VIDEO,
-                       frame->offset_delimiter, &frame->pts, &frame->frame_size,
-                       0, &frame->pts64) == 0)) {
-                       hw->last_pts64 = frame->pts64;
-                       hw->last_pts = frame->pts;
-               } else {
-                       frame->pts64 = hw->last_pts64 +DUR2PTS(hw->frame_dur) ;
-                       frame->pts = hw->last_pts + DUR2PTS(hw->frame_dur);
+               if ((vdec->vbuf.no_parser == 0) || (vdec->vbuf.use_ptsserv)) {
+                       if ((pts_lookup_offset_us64(PTS_TYPE_VIDEO,
+                               frame->offset_delimiter, &frame->pts, &frame->frame_size,
+                               0, &frame->pts64) == 0)) {
+                               hw->last_pts64 = frame->pts64;
+                               hw->last_pts = frame->pts;
+                       } else {
+                               frame->pts64 = hw->last_pts64 +DUR2PTS(hw->frame_dur) ;
+                               frame->pts = hw->last_pts + DUR2PTS(hw->frame_dur);
+                       }
                }
                dpb_print(DECODE_ID(hw), PRINT_FLAG_VDEC_STATUS,
                "%s error= 0x%x poc = %d  offset= 0x%x pts= 0x%x last_pts =0x%x  pts64 = %lld  last_pts64= %lld  duration = %d\n",
@@ -3012,7 +3014,10 @@ int prepare_display_buf(struct vdec_s *vdec, struct FrameStore *frame)
                /*vf->ratio_control |= (0x3FF << DISP_RATIO_ASPECT_RATIO_BIT);*/
                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;
+               }
                kfifo_put(&hw->display_q, (const struct vframe_s *)vf);
                ATRACE_COUNTER(MODULE_NAME, vf->pts);
                hw->vf_pre_count++;
index 087257782402e47dff06757ae047ca07f0b30ca2..1976def59427041ba246e923ef3aa16b736451c8 100644 (file)
@@ -8850,25 +8850,28 @@ static int prepare_display_buf(struct hevc_state_s *hevc, struct PIC_s *pic)
                                hevc->pts_lookup_margin = hevc->min_pic_size;
                }
 
-               hevc_print(hevc, H265_DEBUG_OUT_PTS,
-                       "call pts_lookup_offset_us64(0x%x)\n",
-                       stream_offset);
-               if (pts_lookup_offset_us64
-                       (PTS_TYPE_VIDEO, stream_offset, &vf->pts,
-                       &frame_size, hevc->pts_lookup_margin,
-                        &vf->pts_us64) != 0) {
+                       hevc_print(hevc, H265_DEBUG_OUT_PTS,
+                               "call pts_lookup_offset_us64(0x%x)\n",
+                               stream_offset);
+                       if ((vdec->vbuf.no_parser == 0) || (vdec->vbuf.use_ptsserv)) {
+                               if (pts_lookup_offset_us64
+                                       (PTS_TYPE_VIDEO, stream_offset, &vf->pts,
+                                       &frame_size, hevc->pts_lookup_margin,
+                                        &vf->pts_us64) != 0) {
 #ifdef DEBUG_PTS
-                       hevc->pts_missed++;
+                                       hevc->pts_missed++;
 #endif
-                       vf->pts = 0;
-                       vf->pts_us64 = 0;
-                       hevc->pts_continue_miss++;
-               } else {
-                       hevc->pts_continue_miss = 0;
+                                       vf->pts = 0;
+                                       vf->pts_us64 = 0;
+                                       hevc->pts_continue_miss++;
+                               } else {
+                                       hevc->pts_continue_miss = 0;
 #ifdef DEBUG_PTS
-                       hevc->pts_hit++;
+                                       hevc->pts_hit++;
 #endif
-               }
+                               }
+                       }
+
 #ifdef MULTI_INSTANCE_SUPPORT
 #ifdef CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION
                } else {
@@ -9047,6 +9050,10 @@ static int prepare_display_buf(struct hevc_state_s *hevc, struct PIC_s *pic)
                        vf->pts = 0;
                        vf->pts_us64 = 0;
                }
+               if (!vdec->vbuf.use_ptsserv && vdec_stream_based(vdec)) {
+                       vf->pts_us64 = stream_offset;
+                       vf->pts = 0;
+               }
                /*
                 *      !!! to do ...
                 *      need move below code to get_new_pic(),
index 62592bf76ec6bd65c9fe91bb3c8f07c427bdd12c..44e238bd6cff5de4d5593a6be57d385a7bdaaa42 100644 (file)
@@ -413,15 +413,21 @@ static irqreturn_t vmjpeg_isr_thread_fn(struct vdec_s *vdec, int irq)
                vf->timestamp = hw->chunk->timestamp;
        } else {
                offset = READ_VREG(MREG_FRAME_OFFSET);
-               if (pts_lookup_offset_us64
-                       (PTS_TYPE_VIDEO, offset, &pts,
-                       &frame_size, 3000,
-                       &pts_us64) == 0) {
-                       vf->pts = pts;
-                       vf->pts_us64 = pts_us64;
-               } else {
+               if ((vdec->vbuf.no_parser == 0) || (vdec->vbuf.use_ptsserv)) {
+                       if (pts_lookup_offset_us64
+                               (PTS_TYPE_VIDEO, offset, &pts,
+                               &frame_size, 3000,
+                               &pts_us64) == 0) {
+                               vf->pts = pts;
+                               vf->pts_us64 = pts_us64;
+                       } else {
+                               vf->pts = 0;
+                               vf->pts_us64 = 0;
+                       }
+               }
+               if (!vdec->vbuf.use_ptsserv && vdec_stream_based(vdec)) {
+                       vf->pts_us64 = offset;
                        vf->pts = 0;
-                       vf->pts_us64 = 0;
                }
        }
        vf->orientation = 0;
index c830960473e1c8c94ed8f5d89f1e540346d118d6..061dedbff71db39dd14920780aece905c0892c67 100644 (file)
@@ -1669,6 +1669,10 @@ static int prepare_display_buf(struct vdec_mpeg12_hw_s *hw,
                        vf->mem_handle =
                                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;
+                       }
                        kfifo_put(&hw->display_q,
                                (const struct vframe_s *)vf);
                        /* if (hw->disp_num == 1) { */
@@ -1964,13 +1968,15 @@ static irqreturn_t vmpeg12_isr_thread_fn(struct vdec_s *vdec, int irq)
                                                "pts invalid\n");
                                }
                        } else {
-                               if (pts_lookup_offset_us64(PTS_TYPE_VIDEO, offset,
-                                       &pts, &frame_size, 0, &pts_us64) == 0) {
-                                       new_pic->pts_valid = true;
-                                       new_pic->pts = pts;
-                                       new_pic->pts64 = pts_us64;
-                               } else
-                                       new_pic->pts_valid = false;
+                               if ((vdec->vbuf.no_parser == 0) || (vdec->vbuf.use_ptsserv)) {
+                                       if (pts_lookup_offset_us64(PTS_TYPE_VIDEO, offset,
+                                               &pts, &frame_size, 0, &pts_us64) == 0) {
+                                               new_pic->pts_valid = true;
+                                               new_pic->pts = pts;
+                                               new_pic->pts64 = pts_us64;
+                                       } else
+                                               new_pic->pts_valid = false;
+                               }
                        }
                } else {
                        if (hw->chunk)
index 6d27c7d25e4431c6cb253c8639bb729e537a6ba1..a30d2503a93a124f7a7901638a8a5c5e45fdadbb 100644 (file)
@@ -209,6 +209,7 @@ struct pic_info_t {
        ulong v4l_ref_buf_addr;
        u32 hw_decode_time;
        u32 frame_size; // For frame base mode;
+       u32 offset;
 };
 
 struct vdec_mpeg4_hw_s {
@@ -706,6 +707,10 @@ static int prepare_display_buf(struct vdec_mpeg4_hw_s * hw,
                        "field0: pts %d, pts64 %lld, w %d, h %d, dur %d\n",
                        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 = 0;
+               }
                if (((hw->first_i_frame_ready == 0) || pb_skip)
                         && (pic->pic_type != I_PICTURE)) {
                        hw->drop_frame_count++;
@@ -728,7 +733,6 @@ static int prepare_display_buf(struct vdec_mpeg4_hw_s * hw,
                        } else
                                vmpeg_vf_put(vmpeg_vf_get(vdec), vdec);
                }
-
                if (kfifo_get(&hw->newframe_q, &vf) == 0) {
                        mmpeg4_debug_print(DECODE_ID(hw), 0,
                                "error, no available buf.\n");
@@ -757,6 +761,12 @@ static int prepare_display_buf(struct vdec_mpeg4_hw_s * hw,
                mmpeg4_debug_print(DECODE_ID(hw), PRINT_FLAG_TIMEINFO,
                        "filed1: pts %d, pts64 %lld, w %d, h %d, dur: %d\n",
                        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 = 0;
+               }
+
                if (((hw->first_i_frame_ready == 0) || pb_skip)
                        && (pic->pic_type != I_PICTURE)) {
                        hw->drop_frame_count++;
@@ -822,6 +832,11 @@ static int prepare_display_buf(struct vdec_mpeg4_hw_s * hw,
                        "prog: pts %d, pts64 %lld, w %d, h %d, dur %d\n",
                        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 = 0;
+               }
+
                if (((hw->first_i_frame_ready == 0) || pb_skip)
                        && (pic->pic_type != I_PICTURE)) {
                        hw->drop_frame_count++;
@@ -1160,15 +1175,18 @@ static irqreturn_t vmpeg4_isr_thread_fn(struct vdec_s *vdec, int irq)
                                dec_pic->pts = hw->chunk->pts;
                                dec_pic->pts64 = hw->chunk->pts64;
                        } else {
-                               if (pts_lookup_offset_us64(PTS_TYPE_VIDEO, offset,
-                                       &pts, &frame_size, 3000, &pts_us64) == 0) {
-                                       dec_pic->pts_valid = true;
-                                       dec_pic->pts = pts;
-                                       dec_pic->pts64 = pts_us64;
-                                       hw->pts_hit++;
-                               } else {
-                                       dec_pic->pts_valid = false;
-                                       hw->pts_missed++;
+                               dec_pic->offset = offset;
+                               if ((vdec->vbuf.no_parser == 0) || (vdec->vbuf.use_ptsserv)) {
+                                       if (pts_lookup_offset_us64(PTS_TYPE_VIDEO, offset,
+                                               &pts, &frame_size, 3000, &pts_us64) == 0) {
+                                               dec_pic->pts_valid = true;
+                                               dec_pic->pts = pts;
+                                               dec_pic->pts64 = pts_us64;
+                                               hw->pts_hit++;
+                                       } else {
+                                               dec_pic->pts_valid = false;
+                                               hw->pts_missed++;
+                                       }
                                }
                        }
                        mmpeg4_debug_print(DECODE_ID(hw), PRINT_FLAG_TIMEINFO,
index a35b657146a292f367afc3ca41638b457bc23c98..0eb146efbfeb04b3e1fa8482499e562f906eec0f 100644 (file)
@@ -2510,6 +2510,12 @@ s32 vdec_init(struct vdec_s *vdec, int is_4k)
                                vdec->vf_receiver_name);
                        snprintf(vdec->vfm_map_id, VDEC_MAP_NAME_SIZE,
                                "vdec-map-%d", vdec->id);
+               } else if (p->frame_base_video_path == FRAME_BASE_PATH_DTV_TUNNEL_MODE) {
+                       snprintf(vdec->vfm_map_chain, VDEC_MAP_NAME_SIZE,
+                               "%s deinterlace %s", vdec->vf_provider_name,
+                               "amvideo");
+                       snprintf(vdec->vfm_map_id, VDEC_MAP_NAME_SIZE,
+                               "vdec-map-%d", vdec->id);
                }
 
                if (vfm_map_add(vdec->vfm_map_id,
index 2e0b5a7ff615ba22422e0870b2a126682698738e..9933e944999c00f67617d862d1ad96745bcbd070 100644 (file)
@@ -7233,23 +7233,25 @@ static int prepare_display_buf(struct VP9Decoder_s *pbi,
                /* if (pts_lookup_offset(PTS_TYPE_VIDEO,
                 *   stream_offset, &vf->pts, 0) != 0) {
                 */
-               if (pts_lookup_offset_us64
-                       (PTS_TYPE_VIDEO, stream_offset, &vf->pts,
-                       &frame_size, 0,
-                       &vf->pts_us64) != 0) {
+               if ((pvdec->vbuf.no_parser == 0) || (pvdec->vbuf.use_ptsserv)) {
+                       if (pts_lookup_offset_us64
+                               (PTS_TYPE_VIDEO, stream_offset, &vf->pts,
+                               &frame_size, 0,
+                               &vf->pts_us64) != 0) {
 #ifdef DEBUG_PTS
-                       pbi->pts_missed++;
+                               pbi->pts_missed++;
 #endif
-                       vf->pts = 0;
-                       vf->pts_us64 = 0;
-                       pts_valid = 0;
-                       pts_us64_valid = 0;
-               } else {
+                               vf->pts = 0;
+                               vf->pts_us64 = 0;
+                               pts_valid = 0;
+                               pts_us64_valid = 0;
+                       } else {
 #ifdef DEBUG_PTS
-                       pbi->pts_hit++;
+                               pbi->pts_hit++;
 #endif
-                       pts_valid = 1;
-                       pts_us64_valid = 1;
+                               pts_valid = 1;
+                               pts_us64_valid = 1;
+                       }
                }
 
                fill_frame_info(pbi, pic_config, frame_size, vf->pts);
@@ -7430,7 +7432,10 @@ static int prepare_display_buf(struct VP9Decoder_s *pbi,
                                vf->duration = 0;
                }
                update_vf_memhandle(pbi, vf, pic_config);
-
+               if (vdec_stream_based(pvdec) && (!pvdec->vbuf.use_ptsserv)) {
+                       vf->pts_us64 = stream_offset;
+                       vf->pts = 0;
+               }
                if (!(pic_config->y_crop_width == 196
                && pic_config->y_crop_height == 196
                && (debug & VP9_DEBUG_NO_TRIGGER_FRAME) == 0
index b204dc6968aabdeb8ee773aefec9f19fb71d2f5c..d40d8a60f228fc0b49a934d64726f3ad2f318af7 100644 (file)
@@ -1638,8 +1638,7 @@ static int amstream_open(struct inode *inode, struct file *file)
                }
        }
        /* force dv frame mode */
-       if ((force_dv_mode & 0x2) &&
-               (get_cpu_major_id() >= AM_MESON_CPU_MAJOR_ID_SC2)) {
+       if (force_dv_mode & 0x2) {
                port->type |= PORT_TYPE_FRAME;
                port->fops = &vframe_fops;
                pr_debug("%s, dobly vision force frame mode.\n", __func__);
@@ -2163,10 +2162,15 @@ static long amstream_ioctl_set(struct port_priv_s *priv, ulong arg)
                else if (this->type & PORT_TYPE_FRAME)
                        r = vdec_set_pts(priv->vdec, parm.data_32);
                else if ((this->type & PORT_TYPE_VIDEO) ||
-                       (this->type & PORT_TYPE_HEVC))
-                       r = es_vpts_checkin(&priv->vdec->vbuf,
-                               parm.data_32);
-               else if (this->type & PORT_TYPE_AUDIO)
+                       (this->type & PORT_TYPE_HEVC)) {
+                       struct stream_buf_s *vbuf = &priv->vdec->vbuf;
+                       if (vbuf->no_parser) {
+                               pts_checkin_offset(PTS_TYPE_VIDEO,
+                                       vbuf->stream_offset, parm.data_32);
+                       } else {
+                               r = es_vpts_checkin(vbuf, parm.data_32);
+                       }
+               } else if (this->type & PORT_TYPE_AUDIO)
                        r = es_apts_checkin(&bufs[BUF_TYPE_AUDIO],
                                parm.data_32);
                break;
@@ -2925,9 +2929,15 @@ static long amstream_do_ioctl_old(struct port_priv_s *priv,
                else if (this->type & PORT_TYPE_FRAME)
                        r = vdec_set_pts(priv->vdec, arg);
                else if ((this->type & PORT_TYPE_VIDEO) ||
-                       (this->type & PORT_TYPE_HEVC))
-                       r = es_vpts_checkin(&priv->vdec->vbuf, arg);
-               else if (this->type & PORT_TYPE_AUDIO)
+                       (this->type & PORT_TYPE_HEVC)) {
+                       struct stream_buf_s *vbuf = &priv->vdec->vbuf;
+                       if (vbuf->no_parser) {
+                               pts_checkin_offset(PTS_TYPE_VIDEO,
+                                       vbuf->stream_offset, arg);
+                       } else {
+                               r = es_vpts_checkin(vbuf, arg);
+                       }
+               } else if (this->type & PORT_TYPE_AUDIO)
                        r = es_apts_checkin(&bufs[BUF_TYPE_AUDIO], arg);
                break;
 
index d436441997f27047e975dc6fcc8cadbe3e8db7cb..6801301a7a5d12c2d8be19035fe6dec7e44356d1 100644 (file)
@@ -116,9 +116,9 @@ void stream_buffer_set_ext_buf(struct stream_buf_s *stbuf,
                               u32 flag)
 {
        stbuf->ext_buf_addr     = addr;
-       stbuf->buf_size         = size;
-       stbuf->is_secure = ((flag & STBUF_META_FLAG_SECURE) != 0);
-
+       stbuf->buf_size         = size;
+       stbuf->is_secure        = ((flag & STBUF_META_FLAG_SECURE) != 0);
+       stbuf->use_ptsserv      = ((flag & STBUF_META_FLAG_PTS_SERV) != 0);
        /*
        pr_debug("%s, addr %lx, size 0x%x, secure %d\n", __func__,
                stbuf->ext_buf_addr, stbuf->buf_size, stbuf->is_secure);
@@ -129,7 +129,20 @@ EXPORT_SYMBOL(stream_buffer_set_ext_buf);
 void stream_buffer_meta_write(struct stream_buf_s *stbuf,
        struct stream_buffer_metainfo *meta)
 {
-       u32 wp;
+       u32 wp = stbuf->ops->get_wp(stbuf);
+
+       if ((stbuf->stream_offset == 0) &&
+               (wp == stbuf->ext_buf_addr) &&
+               (meta->stbuf_pktaddr > stbuf->ext_buf_addr)) {
+               struct stream_buffer_metainfo self_meta;
+
+               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);
+       }
 
        if (meta->stbuf_pktaddr + meta->stbuf_pktsize < stbuf->buf_start + stbuf->buf_size)
                wp = meta->stbuf_pktaddr + meta->stbuf_pktsize;
@@ -137,9 +150,11 @@ void stream_buffer_meta_write(struct stream_buf_s *stbuf,
                wp = meta->stbuf_pktaddr + meta->stbuf_pktsize - stbuf->buf_size;
 
        stbuf->ops->set_wp(stbuf, wp);
+
+       stbuf->stream_offset += meta->stbuf_pktsize;
        /*
-       pr_debug("%s, update wp 0x%x + sz 0x%x --> 0x%x\n",
-               __func__, meta->stbuf_pktaddr, meta->stbuf_pktsize, wp);
+       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);
@@ -177,6 +192,8 @@ ssize_t stream_buffer_write_ex(struct file *file,
        len = min_t(u32, len, count);
 
        r = stbuf->ops->write(stbuf, buf, len);
+       if (r > 0)
+               stbuf->stream_offset += r;
 
        return r;
 }
index e8981ed41816a6a7a01d82fbd871421ba998948e..e6871322b4a98303fbf591fd7264c5a10864d507 100644 (file)
@@ -106,6 +106,7 @@ static int stream_buffer_init(struct stream_buf_s *stbuf, struct vdec_s *vdec)
                        ret = -ENOMEM;
                        goto err;
                }
+               stbuf->use_ptsserv = 1;
        }
        ret = vdec_set_input_buffer(vdec, addr, size);
        if (ret) {
@@ -124,12 +125,14 @@ static int stream_buffer_init(struct stream_buf_s *stbuf, struct vdec_s *vdec)
        stbuf->no_parser        = true;
        stbuf->buf_page_num     = pages;
        stbuf->canusebuf_size   = size;
+       stbuf->stream_offset    = 0;
 
-       if (get_cpu_major_id() < AM_MESON_CPU_MAJOR_ID_SC2) {
-               /* init pts server. parser register w/r inside */
+       if (stbuf->use_ptsserv) {
+               /* init pts server. */
                ret = pts_start(type_to_pts(stbuf->type));
                if (ret < 0) {
                        pr_err("[%d]: pts server failed\n", stbuf->id);
+                       stbuf->use_ptsserv = false;
                        //goto err;//fixme
                }
        }
@@ -167,7 +170,8 @@ static void stream_buffer_release(struct stream_buf_s *stbuf)
        if (stbuf->write_thread)
                threadrw_release(stbuf);
 
-       pts_stop(type_to_pts(stbuf->type));
+       if (stbuf->use_ptsserv)
+               pts_stop(type_to_pts(stbuf->type));
 
        if (stbuf->flag & BUF_FLAG_ALLOC && stbuf->buf_start) {
                if (!stbuf->ext_buf_addr)
index 1c14a59fdd8c0386611adaf9014a25b5547ec24a..6b13519ec83891327930c47a370b522dfe2b977c 100644 (file)
@@ -38,8 +38,9 @@
 #define USER_DATA_SIZE  (8*1024)
 
 /* stream_buffer_metainfo stbuf_flag */
-#define STBUF_META_FLAG_SECURE (1 << 0)
-#define STBUF_META_FLAG_XXX1   (1 << 1)
+#define STBUF_META_FLAG_SECURE         (1 << 0)
+#define STBUF_META_FLAG_PTS_SERV       (1 << 1)        /* use pts server flag */
+#define STBUF_META_FLAG_XXX1           (1 << 2)
 
 struct vdec_s;
 struct stream_buf_s;
@@ -88,9 +89,11 @@ struct stream_buf_s {
        bool no_parser;
        bool is_phybuf;
        bool is_hevc;
+       bool use_ptsserv;
        u32 drm_flag;
        ulong ext_buf_addr;
        atomic_t payload;
+       u32 stream_offset;
        struct parser_args pars;
        struct stream_buf_ops *ops;
 } /*stream_buf_t */;