summaryrefslogtreecommitdiffstats
path: root/libavutil
diff options
context:
space:
mode:
authorJason <jason@cpcweb.com>2013-01-22 14:47:58 -0500
committerMichael Niedermayer <michaelni@gmx.at>2013-01-24 21:06:24 +0100
commit77b740ac0ac4d6f7a011594ae116d5c85384bc68 (patch)
treecf8ddf2bb2ae518ae9ea3f9d9ead98391539a2fe /libavutil
parenta717fa84ede90b7323db2a64f9309da31b0d378f (diff)
downloadffmpeg-streaming-77b740ac0ac4d6f7a011594ae116d5c85384bc68.zip
ffmpeg-streaming-77b740ac0ac4d6f7a011594ae116d5c85384bc68.tar.gz
lavu/timecode: fix time code calculation for 60000/1001 drop frame
Reviewed-by: Matthieu Bouron <matthieu.bouron@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/timecode.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/libavutil/timecode.c b/libavutil/timecode.c
index 5f9ebc2..d396032 100644
--- a/libavutil/timecode.c
+++ b/libavutil/timecode.c
@@ -35,18 +35,21 @@ int av_timecode_adjust_ntsc_framenum2(int framenum, int fps)
{
/* only works for NTSC 29.97 and 59.94 */
int drop_frames = 0;
- int d = framenum / 17982;
- int m = framenum % 17982;
+ int d, m, frames_per_10mins;
- if (fps == 30)
+ if (fps == 30) {
drop_frames = 2;
- else if (fps == 60)
+ frames_per_10mins = 17982;
+ } else if (fps == 60) {
drop_frames = 4;
- else
+ frames_per_10mins = 35964;
+ } else
return framenum;
- //if (m < 2) m += 2; /* not needed since -2,-1 / 1798 in C returns 0 */
- return framenum + 9 * drop_frames * d + drop_frames * ((m - 2) / 1798);
+ d = framenum / frames_per_10mins;
+ m = framenum % frames_per_10mins;
+
+ return framenum + 9 * drop_frames * d + drop_frames * ((m - drop_frames) / (frames_per_10mins / 10));
}
uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum)
OpenPOWER on IntegriCloud