v4l2-uvm-test: add time stamp [1/1]
PD#SWPL-20017
Problem:
No timestamp for testing
Solution:
Add microseconds time stamp
Verify:
U212
Change-Id: Ib4b701f1d38db38c553eb3e7ad2058634866b26b
Signed-off-by: Song Zhao <song.zhao@amlogic.com>
diff --git a/v4l2-uvm-test/src/demux.c b/v4l2-uvm-test/src/demux.c
index dd158cc..c51cccd 100644
--- a/v4l2-uvm-test/src/demux.c
+++ b/v4l2-uvm-test/src/demux.c
@@ -75,16 +75,21 @@
static int demux_packet(AVPacket* pkt)
{
int decoded = pkt->size;
+ int64_t pts_us = 0;
+ AVRational ns_r = {1,DMX_SECOND};
if (pkt->stream_index != video_stream_idx)
return decoded;
+ if (pkt->pts != AV_NOPTS_VALUE)
+ pts_us = av_rescale_q(pkt->pts, video_stream->time_base, ns_r);
+
/* video frame */
video_frame_count++;
#ifdef DEBUG_FRAME
printf("video_frame n:%d pts:%llx size:%x\n",
video_frame_count,
- pkt->pts, pkt->size);
+ pts_us, pkt->size);
#endif
/* refer to ffmpeg hevc_mp4toannexb_filter()
@@ -133,7 +138,7 @@
} else {
dec_cb->write(pkt->data, pkt->size);
}
- dec_cb->frame_done();
+ dec_cb->frame_done(pts_us);
return decoded;
}
@@ -442,8 +447,9 @@
//printf("AV_CODEC_ID_H264:%d AV_CODEC_ID_H265:%d\n", AV_CODEC_ID_H264, AV_CODEC_ID_H265);
- printf("video stream: format:%d %dx%d\n",
- dec_ctx->codec_id, v_data.width, v_data.height);
+ printf("video stream: format:%d %dx%d tu:%d/%d\n ",
+ dec_ctx->codec_id, v_data.width, v_data.height,
+ video_stream->time_base.num, video_stream->time_base.den);
dec_cb->meta_done(&v_data);