s->picture.key_frame = 1;
s->picture.pict_type = FF_I_TYPE;
avctx->pix_fmt = s->sys->pix_fmt;
- avctx->time_base = (AVRational){s->sys->frame_rate_base, s->sys->frame_rate};
+ avctx->time_base = s->sys->time_base;
avcodec_set_dimensions(avctx, s->sys->width, s->sys->height);
if(avctx->get_buffer(avctx, &s->picture) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
int frame_size; /* total size of one frame in bytes */
int difseg_size; /* number of DIF segments per DIF channel */
int n_difchan; /* number of DIF channels per frame */
- int frame_rate;
- int frame_rate_base;
+ AVRational time_base; /* 1/framerate */
int ltc_divisor; /* FPS from the LTS standpoint */
int height; /* picture height in pixels */
int width; /* picture width in pixels */
.frame_size = 120000, /* IEC 61834, SMPTE-314M - 525/60 (NTSC) */
.difseg_size = 10,
.n_difchan = 1,
- .frame_rate = 30000,
+ .time_base = { 1001, 30000 },
.ltc_divisor = 30,
- .frame_rate_base = 1001,
.height = 480,
.width = 720,
.sar = {{10, 11}, {40, 33}},
.frame_size = 144000, /* IEC 61834 - 625/50 (PAL) */
.difseg_size = 12,
.n_difchan = 1,
- .frame_rate = 25,
- .frame_rate_base = 1,
+ .time_base = { 1, 25 },
.ltc_divisor = 25,
.height = 576,
.width = 720,
.frame_size = 144000, /* SMPTE-314M - 625/50 (PAL) */
.difseg_size = 12,
.n_difchan = 1,
- .frame_rate = 25,
- .frame_rate_base = 1,
+ .time_base = { 1, 25 },
.ltc_divisor = 25,
.height = 576,
.width = 720,
.frame_size = 240000, /* SMPTE-314M - 525/60 (NTSC) 50 Mbps */
.difseg_size = 10, /* also known as "DVCPRO50" */
.n_difchan = 2,
- .frame_rate = 30000,
+ .time_base = { 1001, 30000 },
.ltc_divisor = 30,
- .frame_rate_base = 1001,
.height = 480,
.width = 720,
.sar = {{10, 11}, {40, 33}},
.frame_size = 288000, /* SMPTE-314M - 625/50 (PAL) 50 Mbps */
.difseg_size = 12, /* also known as "DVCPRO50" */
.n_difchan = 2,
- .frame_rate = 25,
- .frame_rate_base = 1,
+ .time_base = { 1, 25 },
.ltc_divisor = 25,
.height = 576,
.width = 720,
.frame_size = 480000, /* SMPTE-370M - 1080i60 100 Mbps */
.difseg_size = 10, /* also known as "DVCPRO HD" */
.n_difchan = 4,
- .frame_rate = 30000,
+ .time_base = { 1001, 30000 },
.ltc_divisor = 30,
- .frame_rate_base = 1001,
.height = 1080,
.width = 1280,
.sar = {{1, 1}, {1, 1}},
.frame_size = 576000, /* SMPTE-370M - 1080i50 100 Mbps */
.difseg_size = 12, /* also known as "DVCPRO HD" */
.n_difchan = 4,
- .frame_rate = 25,
- .frame_rate_base = 1,
+ .time_base = { 1, 25 },
.ltc_divisor = 25,
.height = 1080,
.width = 1440,
.frame_size = 240000, /* SMPTE-370M - 720p60 100 Mbps */
.difseg_size = 10, /* also known as "DVCPRO HD" */
.n_difchan = 2,
- .frame_rate = 60000,
+ .time_base = { 1001, 60000 },
.ltc_divisor = 60,
- .frame_rate_base = 1001,
.height = 720,
.width = 960,
.sar = {{1, 1}, {1, 1}},
.frame_size = 288000, /* SMPTE-370M - 720p50 100 Mbps */
.difseg_size = 12, /* also known as "DVCPRO HD" */
.n_difchan = 2,
- .frame_rate = 50,
+ .time_base = { 1, 50 },
.ltc_divisor = 50,
- .frame_rate_base = 1,
.height = 720,
.width = 960,
.sar = {{1, 1}, {1, 1}},
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;
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;
{
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;
}
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;
}
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
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" */
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" ? */