Mercurial > libavformat.hg
changeset 3992:36f92f77c85e libavformat
replacing frame_rate and frame_rate_base with an AVRational time_base
author | romansh |
---|---|
date | Tue, 07 Oct 2008 16:59:18 +0000 |
parents | 3cc570fdebbf |
children | 8c5a32f0d479 |
files | dv.c dvenc.c |
diffstat | 2 files changed, 14 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/dv.c Tue Oct 07 16:14:33 2008 +0000 +++ b/dv.c Tue Oct 07 16:59:18 2008 +0000 @@ -241,8 +241,8 @@ 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 @@ 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 @@ { 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 @@ 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; }
--- a/dvenc.c Tue Oct 07 16:14:33 2008 +0000 +++ b/dvenc.c Tue Oct 07 16:59:18 2008 +0000 @@ -77,8 +77,8 @@ 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 @@ 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 @@ 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" ? */