From 5221e9d5db85328e9d49d86152dd387cb23ff75b Mon Sep 17 00:00:00 2001 From: Zhizhong Zhang Date: Thu, 12 Mar 2020 12:48:10 +0800 Subject: [PATCH] avsync: Use the video start pts to init pcr [3/3] PD#SWPL-21670 Problem: Play from beginning,it will get stuck for a while Solution: Use the video start pts to init pcr if audio invalid Verify: Verified ok on patch-build Change-Id: I0673d811889cb6b9ae3301355f09b268725d472d Signed-off-by: Zhizhong Zhang --- drivers/amlogic/media/frame_sync/tsync_pcr.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/amlogic/media/frame_sync/tsync_pcr.c b/drivers/amlogic/media/frame_sync/tsync_pcr.c index fe3b28e6c499..449b5ca59449 100644 --- a/drivers/amlogic/media/frame_sync/tsync_pcr.c +++ b/drivers/amlogic/media/frame_sync/tsync_pcr.c @@ -380,6 +380,7 @@ u32 tsync_pcr_get_ref_pcr(void) u32 ref_pcr = 0; uint64_t audio_cache_pts = 0; uint64_t video_cache_pts = 0; + uint64_t pts_cache_tmp = 0; int audio_cache_ms = 0; int video_cache_ms = 0; int diff = 0; @@ -393,20 +394,25 @@ u32 tsync_pcr_get_ref_pcr(void) first_apts = first_checkin_apts; if (!first_vpts) first_vpts = first_checkin_vpts; + /*Use the firs output vpts to calc buffer cache and init pcr*/ + if (tsync_pcr_vstart_flag == 1) { + first_vpts = tsync_pcr_first_video_frame_pts; + pr_info("Video Start, first vpts:0x%x\n", first_vpts); + } cur_checkin_vpts = get_last_checkin_pts(PTS_TYPE_VIDEO); cur_checkin_apts = get_last_checkin_pts(PTS_TYPE_AUDIO); video_cache_pts = cur_checkin_vpts - first_vpts; audio_cache_pts = cur_checkin_apts - first_apts; if ((first_apts == 0) && (cur_checkin_apts == 0xffffffff)) audio_cache_pts = 0; + pts_cache_tmp = audio_cache_pts; #ifdef CONFIG_64BIT audio_cache_ms = audio_cache_pts / 90; video_cache_ms = video_cache_pts / 90; #else - do_div(audio_cache_pts, 90); - do_div(video_cache_pts, 90); - audio_cache_ms = audio_cache_pts; - video_cache_ms = video_cache_pts; + audio_cache_ms = do_div(pts_cache_tmp, 90); + pts_cache_tmp = video_cache_pts; + video_cache_ms = do_div(pts_cache_tmp, 90); #endif pr_info("get_ref_pcr:apts(%x,%x,%x,cache:%dms),vpts(%x,%x,%x,cache:%dms)\n",