aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2003-03-12 15:16:19 +0000
committerMichael Niedermayer <michaelni@gmx.at>2003-03-12 15:16:19 +0000
commit14bea432f16d7c66f9099e427819028b6b4c3bdc (patch)
treec52726ce14a0265337b9deebd2214e2552d284b0 /libavformat/utils.c
parent586bc7553ca90dee507afd950de64bbd2c6a80b5 (diff)
downloadffmpeg-14bea432f16d7c66f9099e427819028b6b4c3bdc.tar.gz
per context frame_rate_base, this should finally fix frame_rate related av sync issues
Originally committed as revision 1666 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 5642894ec9..1c1c406606 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -614,10 +614,12 @@ int av_find_stream_info(AVFormatContext *ic)
#endif
/* stop after 40 frames */
if (st->codec_info_nb_real_frames >= 40) {
- st->r_frame_rate = (st->codec.frame_rate *
- st->codec_info_nb_real_frames) /
- (st->codec_info_nb_real_frames +
- (st->codec_info_nb_repeat_frames >> 1));
+ av_reduce(
+ &st->r_frame_rate,
+ &st->r_frame_rate_base,
+ (int64_t)st->codec.frame_rate * st->codec_info_nb_real_frames,
+ st->codec_info_nb_real_frames + (st->codec_info_nb_repeat_frames >> 1),
+ 1<<30);
goto close_codec;
}
} else {
@@ -645,8 +647,10 @@ int av_find_stream_info(AVFormatContext *ic)
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
- if (!st->r_frame_rate)
- st->r_frame_rate = st->codec.frame_rate;
+ if (!st->r_frame_rate){
+ st->r_frame_rate = st->codec.frame_rate;
+ st->r_frame_rate_base = st->codec.frame_rate_base;
+ }
}
}
@@ -820,7 +824,7 @@ int av_write_frame(AVFormatContext *s, int stream_index, const uint8_t *buf,
break;
case CODEC_TYPE_VIDEO:
av_frac_add(&st->pts,
- (int64_t)s->pts_den * FRAME_RATE_BASE);
+ (int64_t)s->pts_den * st->codec.frame_rate_base);
break;
default:
break;
@@ -1316,11 +1320,6 @@ void av_frac_add(AVFrac *f, int64_t incr)
f->num = num;
}
-int av_gcd(int a, int b){
- if(b) return av_gcd(b, a%b);
- else return a;
-}
-
/**
* register a new image format
* @param img_fmt Image format descriptor