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",
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
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;
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
+ }
}
}
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,
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,
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,
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",
/*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++;
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 {
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(),
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;
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) { */
"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)
ulong v4l_ref_buf_addr;
u32 hw_decode_time;
u32 frame_size; // For frame base mode;
+ u32 offset;
};
struct vdec_mpeg4_hw_s {
"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++;
} 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");
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++;
"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++;
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,
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,
/* 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);
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
}
}
/* 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__);
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;
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;
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);
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;
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);
len = min_t(u32, len, count);
r = stbuf->ops->write(stbuf, buf, len);
+ if (r > 0)
+ stbuf->stream_offset += r;
return r;
}
ret = -ENOMEM;
goto err;
}
+ stbuf->use_ptsserv = 1;
}
ret = vdec_set_input_buffer(vdec, addr, size);
if (ret) {
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
}
}
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)
#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;
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 */;