From: Zhao Zhili <quinkblack@foxmail.com> To: ffmpeg-devel@ffmpeg.org Cc: lingjiujianke@gmail.com, Zhao Zhili <zhilizhao@tencent.com> Subject: [FFmpeg-devel] [PATCH 2/2] avformat/flvdec: make key frame timestamps more accurate Date: Thu, 14 Jul 2022 12:48:14 +0800 Message-ID: <tencent_A74E9D701F2DAA9A6640579A149F67AB1808@qq.com> (raw) In-Reply-To: <20220714044814.72083-1-quinkblack@foxmail.com> From: Zhao Zhili <zhilizhao@tencent.com> There is an implicit cast from double to int64_t in time unit of second. --- libavformat/flvdec.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index c5d3c63bd0..a78d720295 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -146,9 +146,9 @@ static void add_keyframes_index(AVFormatContext *s) if (ffstream(stream)->nb_index_entries == 0) { for (i = 0; i < flv->keyframe_count; i++) { av_log(s, AV_LOG_TRACE, "keyframe filepositions = %"PRId64" times = %"PRId64"\n", - flv->keyframe_filepositions[i], flv->keyframe_times[i] * 1000); + flv->keyframe_filepositions[i], flv->keyframe_times[i]); av_add_index_entry(stream, flv->keyframe_filepositions[i], - flv->keyframe_times[i] * 1000, 0, 0, AVINDEX_KEYFRAME); + flv->keyframe_times[i], 0, 0, AVINDEX_KEYFRAME); } } else av_log(s, AV_LOG_WARNING, "Skipping duplicate index\n"); @@ -461,9 +461,13 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, int64_t m d = av_int2double(avio_rb64(ioc)); if (isnan(d) || d < INT64_MIN || d > INT64_MAX) goto invalid; - if (current_array == × && (d <= INT64_MIN / 1000 || d >= INT64_MAX / 1000)) - goto invalid; - current_array[0][i] = d; + if (current_array == ×) { + if (d <= INT64_MIN / 1000 || d >= INT64_MAX / 1000) + goto invalid; + current_array[0][i] = d * 1000; + } else { + current_array[0][i] = d; + } } if (times && filepositions) { // All done, exiting at a position allowing amf_parse_object @@ -476,7 +480,7 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, int64_t m if (timeslen == fileposlen && fileposlen>1 && max_pos <= filepositions[0]) { for (i = 0; i < FFMIN(2,fileposlen); i++) { flv->validate_index[i].pos = filepositions[i]; - flv->validate_index[i].dts = times[i] * 1000; + flv->validate_index[i].dts = times[i]; flv->validate_count = i + 1; } flv->keyframe_times = times; -- 2.35.3 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next parent reply other threads:[~2022-07-14 4:48 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <20220714044814.72083-1-quinkblack@foxmail.com> 2022-07-14 4:48 ` Zhao Zhili [this message] 2022-07-14 7:00 ` [FFmpeg-devel] [PATCH 3/3] avformat/flvenc: fix shadowed variable ts Zhao Zhili 2022-07-16 13:53 ` [FFmpeg-devel] [PATCH 2/2] avformat/flvdec: make key frame timestamps more accurate Michael Niedermayer
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=tencent_A74E9D701F2DAA9A6640579A149F67AB1808@qq.com \ --to=quinkblack@foxmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=lingjiujianke@gmail.com \ --cc=zhilizhao@tencent.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git