summaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorRoman Shaposhnik <roman@shaposhnik.org>2008-10-07 16:59:18 +0000
committerRoman Shaposhnik <roman@shaposhnik.org>2008-10-07 16:59:18 +0000
commit4e92dabf6048870e4d2064c5db6decb231840af0 (patch)
treefeb01f4d15df5753550665bc699493c4d7546eda /libavformat
parenta53621fca8d0250bc5b21a688232985b8146e77f (diff)
downloadffmpeg-streaming-4e92dabf6048870e4d2064c5db6decb231840af0.zip
ffmpeg-streaming-4e92dabf6048870e4d2064c5db6decb231840af0.tar.gz
replacing frame_rate and frame_rate_base with an AVRational time_base
Originally committed as revision 15584 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/dv.c19
-rw-r--r--libavformat/dvenc.c12
2 files changed, 14 insertions, 17 deletions
diff --git a/libavformat/dv.c b/libavformat/dv.c
index b745882..95b3988 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -241,8 +241,8 @@ static int dv_extract_video_info(DVDemuxContext *c, uint8_t* frame)
if (c->sys) {
avctx = c->vst->codec;
- av_set_pts_info(c->vst, 64, c->sys->frame_rate_base, c->sys->frame_rate);
- avctx->time_base= (AVRational){c->sys->frame_rate_base, c->sys->frame_rate};
+ av_set_pts_info(c->vst, 64, c->sys->time_base.num, c->sys->time_base.den);
+ avctx->time_base= c->sys->time_base;
if(!avctx->width){
avctx->width = c->sys->width;
avctx->height = c->sys->height;
@@ -255,9 +255,8 @@ static int dv_extract_video_info(DVDemuxContext *c, uint8_t* frame)
is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 ||
(!apt && (vsc_pack[2] & 0x07) == 0x07)));
c->vst->sample_aspect_ratio = c->sys->sar[is16_9];
- avctx->bit_rate = av_rescale(c->sys->frame_size * 8,
- c->sys->frame_rate,
- c->sys->frame_rate_base);
+ avctx->bit_rate = av_rescale_q(c->sys->frame_size, (AVRational){8,1},
+ c->sys->time_base);
size = c->sys->frame_size;
}
return size;
@@ -379,9 +378,8 @@ void dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
{
c->frames= frame_offset;
if (c->ach)
- c->abytes= av_rescale(c->frames,
- c->ast[0]->codec->bit_rate * (int64_t)c->sys->frame_rate_base,
- 8*c->sys->frame_rate);
+ c->abytes= av_rescale_q(c->frames, c->sys->time_base,
+ (AVRational){8, c->ast[0]->codec->bit_rate});
c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
}
@@ -414,9 +412,8 @@ static int dv_read_header(AVFormatContext *s,
return -1;
}
- s->bit_rate = av_rescale(c->dv_demux->sys->frame_size * 8,
- c->dv_demux->sys->frame_rate,
- c->dv_demux->sys->frame_rate_base);
+ s->bit_rate = av_rescale_q(c->dv_demux->sys->frame_size, (AVRational){8,1},
+ c->dv_demux->sys->time_base);
return 0;
}
diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c
index 468fed3..9da313a 100644
--- a/libavformat/dvenc.c
+++ b/libavformat/dvenc.c
@@ -77,8 +77,8 @@ static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t* bu
buf[0] = (uint8_t)pack_id;
switch (pack_id) {
case dv_timecode:
- ct = (time_t)(c->frames / ((float)c->sys->frame_rate /
- (float)c->sys->frame_rate_base));
+ ct = (time_t)av_rescale_rnd(c->frames, c->sys->time_base.num, c->sys->time_base.den,
+ AV_ROUND_DOWN);
brktimegm(ct, &tc);
/*
* LTC drop-frame frame counter drops two frames (0 and 1) every
@@ -138,8 +138,8 @@ static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t* bu
break;
case dv_audio_recdate:
case dv_video_recdate: /* VAUX recording date */
- ct = c->start_time + (time_t)(c->frames /
- ((float)c->sys->frame_rate / (float)c->sys->frame_rate_base));
+ ct = c->start_time + av_rescale_rnd(c->frames, c->sys->time_base.num,
+ c->sys->time_base.den, AV_ROUND_DOWN);
brktimegm(ct, &tc);
buf[1] = 0xff; /* ds, tm, tens of time zone, units of time zone */
/* 0xff is very likely to be "unknown" */
@@ -154,8 +154,8 @@ static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t* bu
break;
case dv_audio_rectime: /* AAUX recording time */
case dv_video_rectime: /* VAUX recording time */
- ct = c->start_time + (time_t)(c->frames /
- ((float)c->sys->frame_rate / (float)c->sys->frame_rate_base));
+ ct = c->start_time + av_rescale_rnd(c->frames, c->sys->time_base.num,
+ c->sys->time_base.den, AV_ROUND_DOWN);
brktimegm(ct, &tc);
buf[1] = (3 << 6) | /* reserved -- always 1 */
0x3f; /* tens of frame, units of frame: 0x3f - "unknown" ? */
OpenPOWER on IntegriCloud