aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2003-03-08 14:29:12 +0000
committerMichael Niedermayer <michaelni@gmx.at>2003-03-08 14:29:12 +0000
commit0bf79c2fcd37c4ceb421eed878aa0468830a53e4 (patch)
tree1a2792b07f071bd8f134c4a8ba00e15d52e3fece /libavformat
parent8a7b1b18e25bf03220145ca90fe57038b9675df4 (diff)
downloadffmpeg-0bf79c2fcd37c4ceb421eed878aa0468830a53e4.tar.gz
fixing frame_rate accuracy
Originally committed as revision 1652 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/ffm.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/libavformat/ffm.c b/libavformat/ffm.c
index 425155d15b..f2615673af 100644
--- a/libavformat/ffm.c
+++ b/libavformat/ffm.c
@@ -140,6 +140,8 @@ static int ffm_write_header(AVFormatContext *s)
/* list of streams */
for(i=0;i<s->nb_streams;i++) {
+ int gcd;
+
st = s->streams[i];
fst = av_mallocz(sizeof(FFMStream));
if (!fst)
@@ -156,7 +158,9 @@ static int ffm_write_header(AVFormatContext *s)
/* specific info */
switch(codec->codec_type) {
case CODEC_TYPE_VIDEO:
- put_be32(pb, (codec->frame_rate * 1000) / FRAME_RATE_BASE);
+ gcd= av_gcd(FRAME_RATE_BASE, codec->frame_rate);
+ put_be32(pb, FRAME_RATE_BASE / gcd);
+ put_be32(pb, codec->frame_rate / gcd);
put_be16(pb, codec->width);
put_be16(pb, codec->height);
put_be16(pb, codec->gop_size);
@@ -390,6 +394,7 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
/* read each stream */
for(i=0;i<s->nb_streams;i++) {
char rc_eq_buf[128];
+ int rate, scale;
st = av_mallocz(sizeof(AVStream));
if (!st)
@@ -411,7 +416,9 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
/* specific info */
switch(codec->codec_type) {
case CODEC_TYPE_VIDEO:
- codec->frame_rate = ((int64_t)get_be32(pb) * FRAME_RATE_BASE) / 1000;
+ scale= get_be32(pb);
+ rate= get_be32(pb);
+ codec->frame_rate = (rate * (int64_t)FRAME_RATE_BASE) / scale;
codec->width = get_be16(pb);
codec->height = get_be16(pb);
codec->gop_size = get_be16(pb);