Commit 4e92dabf authored by Roman Shaposhnik's avatar Roman Shaposhnik

replacing frame_rate and frame_rate_base with an AVRational time_base

Originally committed as revision 15584 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent a53621fc
...@@ -1048,7 +1048,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, ...@@ -1048,7 +1048,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx,
s->picture.key_frame = 1; s->picture.key_frame = 1;
s->picture.pict_type = FF_I_TYPE; s->picture.pict_type = FF_I_TYPE;
avctx->pix_fmt = s->sys->pix_fmt; 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); avcodec_set_dimensions(avctx, s->sys->width, s->sys->height);
if(avctx->get_buffer(avctx, &s->picture) < 0) { if(avctx->get_buffer(avctx, &s->picture) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
......
...@@ -42,8 +42,7 @@ typedef struct DVprofile { ...@@ -42,8 +42,7 @@ typedef struct DVprofile {
int frame_size; /* total size of one frame in bytes */ int frame_size; /* total size of one frame in bytes */
int difseg_size; /* number of DIF segments per DIF channel */ int difseg_size; /* number of DIF segments per DIF channel */
int n_difchan; /* number of DIF channels per frame */ int n_difchan; /* number of DIF channels per frame */
int frame_rate; AVRational time_base; /* 1/framerate */
int frame_rate_base;
int ltc_divisor; /* FPS from the LTS standpoint */ int ltc_divisor; /* FPS from the LTS standpoint */
int height; /* picture height in pixels */ int height; /* picture height in pixels */
int width; /* picture width in pixels */ int width; /* picture width in pixels */
...@@ -6166,9 +6165,8 @@ static const DVprofile dv_profiles[] = { ...@@ -6166,9 +6165,8 @@ static const DVprofile dv_profiles[] = {
.frame_size = 120000, /* IEC 61834, SMPTE-314M - 525/60 (NTSC) */ .frame_size = 120000, /* IEC 61834, SMPTE-314M - 525/60 (NTSC) */
.difseg_size = 10, .difseg_size = 10,
.n_difchan = 1, .n_difchan = 1,
.frame_rate = 30000, .time_base = { 1001, 30000 },
.ltc_divisor = 30, .ltc_divisor = 30,
.frame_rate_base = 1001,
.height = 480, .height = 480,
.width = 720, .width = 720,
.sar = {{10, 11}, {40, 33}}, .sar = {{10, 11}, {40, 33}},
...@@ -6186,8 +6184,7 @@ static const DVprofile dv_profiles[] = { ...@@ -6186,8 +6184,7 @@ static const DVprofile dv_profiles[] = {
.frame_size = 144000, /* IEC 61834 - 625/50 (PAL) */ .frame_size = 144000, /* IEC 61834 - 625/50 (PAL) */
.difseg_size = 12, .difseg_size = 12,
.n_difchan = 1, .n_difchan = 1,
.frame_rate = 25, .time_base = { 1, 25 },
.frame_rate_base = 1,
.ltc_divisor = 25, .ltc_divisor = 25,
.height = 576, .height = 576,
.width = 720, .width = 720,
...@@ -6206,8 +6203,7 @@ static const DVprofile dv_profiles[] = { ...@@ -6206,8 +6203,7 @@ static const DVprofile dv_profiles[] = {
.frame_size = 144000, /* SMPTE-314M - 625/50 (PAL) */ .frame_size = 144000, /* SMPTE-314M - 625/50 (PAL) */
.difseg_size = 12, .difseg_size = 12,
.n_difchan = 1, .n_difchan = 1,
.frame_rate = 25, .time_base = { 1, 25 },
.frame_rate_base = 1,
.ltc_divisor = 25, .ltc_divisor = 25,
.height = 576, .height = 576,
.width = 720, .width = 720,
...@@ -6226,9 +6222,8 @@ static const DVprofile dv_profiles[] = { ...@@ -6226,9 +6222,8 @@ static const DVprofile dv_profiles[] = {
.frame_size = 240000, /* SMPTE-314M - 525/60 (NTSC) 50 Mbps */ .frame_size = 240000, /* SMPTE-314M - 525/60 (NTSC) 50 Mbps */
.difseg_size = 10, /* also known as "DVCPRO50" */ .difseg_size = 10, /* also known as "DVCPRO50" */
.n_difchan = 2, .n_difchan = 2,
.frame_rate = 30000, .time_base = { 1001, 30000 },
.ltc_divisor = 30, .ltc_divisor = 30,
.frame_rate_base = 1001,
.height = 480, .height = 480,
.width = 720, .width = 720,
.sar = {{10, 11}, {40, 33}}, .sar = {{10, 11}, {40, 33}},
...@@ -6246,8 +6241,7 @@ static const DVprofile dv_profiles[] = { ...@@ -6246,8 +6241,7 @@ static const DVprofile dv_profiles[] = {
.frame_size = 288000, /* SMPTE-314M - 625/50 (PAL) 50 Mbps */ .frame_size = 288000, /* SMPTE-314M - 625/50 (PAL) 50 Mbps */
.difseg_size = 12, /* also known as "DVCPRO50" */ .difseg_size = 12, /* also known as "DVCPRO50" */
.n_difchan = 2, .n_difchan = 2,
.frame_rate = 25, .time_base = { 1, 25 },
.frame_rate_base = 1,
.ltc_divisor = 25, .ltc_divisor = 25,
.height = 576, .height = 576,
.width = 720, .width = 720,
...@@ -6266,9 +6260,8 @@ static const DVprofile dv_profiles[] = { ...@@ -6266,9 +6260,8 @@ static const DVprofile dv_profiles[] = {
.frame_size = 480000, /* SMPTE-370M - 1080i60 100 Mbps */ .frame_size = 480000, /* SMPTE-370M - 1080i60 100 Mbps */
.difseg_size = 10, /* also known as "DVCPRO HD" */ .difseg_size = 10, /* also known as "DVCPRO HD" */
.n_difchan = 4, .n_difchan = 4,
.frame_rate = 30000, .time_base = { 1001, 30000 },
.ltc_divisor = 30, .ltc_divisor = 30,
.frame_rate_base = 1001,
.height = 1080, .height = 1080,
.width = 1280, .width = 1280,
.sar = {{1, 1}, {1, 1}}, .sar = {{1, 1}, {1, 1}},
...@@ -6286,8 +6279,7 @@ static const DVprofile dv_profiles[] = { ...@@ -6286,8 +6279,7 @@ static const DVprofile dv_profiles[] = {
.frame_size = 576000, /* SMPTE-370M - 1080i50 100 Mbps */ .frame_size = 576000, /* SMPTE-370M - 1080i50 100 Mbps */
.difseg_size = 12, /* also known as "DVCPRO HD" */ .difseg_size = 12, /* also known as "DVCPRO HD" */
.n_difchan = 4, .n_difchan = 4,
.frame_rate = 25, .time_base = { 1, 25 },
.frame_rate_base = 1,
.ltc_divisor = 25, .ltc_divisor = 25,
.height = 1080, .height = 1080,
.width = 1440, .width = 1440,
...@@ -6306,9 +6298,8 @@ static const DVprofile dv_profiles[] = { ...@@ -6306,9 +6298,8 @@ static const DVprofile dv_profiles[] = {
.frame_size = 240000, /* SMPTE-370M - 720p60 100 Mbps */ .frame_size = 240000, /* SMPTE-370M - 720p60 100 Mbps */
.difseg_size = 10, /* also known as "DVCPRO HD" */ .difseg_size = 10, /* also known as "DVCPRO HD" */
.n_difchan = 2, .n_difchan = 2,
.frame_rate = 60000, .time_base = { 1001, 60000 },
.ltc_divisor = 60, .ltc_divisor = 60,
.frame_rate_base = 1001,
.height = 720, .height = 720,
.width = 960, .width = 960,
.sar = {{1, 1}, {1, 1}}, .sar = {{1, 1}, {1, 1}},
...@@ -6326,9 +6317,8 @@ static const DVprofile dv_profiles[] = { ...@@ -6326,9 +6317,8 @@ static const DVprofile dv_profiles[] = {
.frame_size = 288000, /* SMPTE-370M - 720p50 100 Mbps */ .frame_size = 288000, /* SMPTE-370M - 720p50 100 Mbps */
.difseg_size = 12, /* also known as "DVCPRO HD" */ .difseg_size = 12, /* also known as "DVCPRO HD" */
.n_difchan = 2, .n_difchan = 2,
.frame_rate = 50, .time_base = { 1, 50 },
.ltc_divisor = 50, .ltc_divisor = 50,
.frame_rate_base = 1,
.height = 720, .height = 720,
.width = 960, .width = 960,
.sar = {{1, 1}, {1, 1}}, .sar = {{1, 1}, {1, 1}},
......
...@@ -241,8 +241,8 @@ static int dv_extract_video_info(DVDemuxContext *c, uint8_t* frame) ...@@ -241,8 +241,8 @@ static int dv_extract_video_info(DVDemuxContext *c, uint8_t* frame)
if (c->sys) { if (c->sys) {
avctx = c->vst->codec; avctx = c->vst->codec;
av_set_pts_info(c->vst, 64, 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= (AVRational){c->sys->frame_rate_base, c->sys->frame_rate}; avctx->time_base= c->sys->time_base;
if(!avctx->width){ if(!avctx->width){
avctx->width = c->sys->width; avctx->width = c->sys->width;
avctx->height = c->sys->height; avctx->height = c->sys->height;
...@@ -255,9 +255,8 @@ static int dv_extract_video_info(DVDemuxContext *c, uint8_t* frame) ...@@ -255,9 +255,8 @@ static int dv_extract_video_info(DVDemuxContext *c, uint8_t* frame)
is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 || is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 ||
(!apt && (vsc_pack[2] & 0x07) == 0x07))); (!apt && (vsc_pack[2] & 0x07) == 0x07)));
c->vst->sample_aspect_ratio = c->sys->sar[is16_9]; c->vst->sample_aspect_ratio = c->sys->sar[is16_9];
avctx->bit_rate = av_rescale(c->sys->frame_size * 8, avctx->bit_rate = av_rescale_q(c->sys->frame_size, (AVRational){8,1},
c->sys->frame_rate, c->sys->time_base);
c->sys->frame_rate_base);
size = c->sys->frame_size; size = c->sys->frame_size;
} }
return size; return size;
...@@ -379,9 +378,8 @@ void dv_offset_reset(DVDemuxContext *c, int64_t frame_offset) ...@@ -379,9 +378,8 @@ void dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
{ {
c->frames= frame_offset; c->frames= frame_offset;
if (c->ach) if (c->ach)
c->abytes= av_rescale(c->frames, c->abytes= av_rescale_q(c->frames, c->sys->time_base,
c->ast[0]->codec->bit_rate * (int64_t)c->sys->frame_rate_base, (AVRational){8, c->ast[0]->codec->bit_rate});
8*c->sys->frame_rate);
c->audio_pkt[0].size = c->audio_pkt[1].size = 0; c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
c->audio_pkt[2].size = c->audio_pkt[3].size = 0; c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
} }
...@@ -414,9 +412,8 @@ static int dv_read_header(AVFormatContext *s, ...@@ -414,9 +412,8 @@ static int dv_read_header(AVFormatContext *s,
return -1; return -1;
} }
s->bit_rate = av_rescale(c->dv_demux->sys->frame_size * 8, s->bit_rate = av_rescale_q(c->dv_demux->sys->frame_size, (AVRational){8,1},
c->dv_demux->sys->frame_rate, c->dv_demux->sys->time_base);
c->dv_demux->sys->frame_rate_base);
return 0; return 0;
} }
......
...@@ -77,8 +77,8 @@ static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t* bu ...@@ -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; buf[0] = (uint8_t)pack_id;
switch (pack_id) { switch (pack_id) {
case dv_timecode: case dv_timecode:
ct = (time_t)(c->frames / ((float)c->sys->frame_rate / ct = (time_t)av_rescale_rnd(c->frames, c->sys->time_base.num, c->sys->time_base.den,
(float)c->sys->frame_rate_base)); AV_ROUND_DOWN);
brktimegm(ct, &tc); brktimegm(ct, &tc);
/* /*
* LTC drop-frame frame counter drops two frames (0 and 1) every * 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 ...@@ -138,8 +138,8 @@ static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t* bu
break; break;
case dv_audio_recdate: case dv_audio_recdate:
case dv_video_recdate: /* VAUX recording date */ case dv_video_recdate: /* VAUX recording date */
ct = c->start_time + (time_t)(c->frames / ct = c->start_time + av_rescale_rnd(c->frames, c->sys->time_base.num,
((float)c->sys->frame_rate / (float)c->sys->frame_rate_base)); c->sys->time_base.den, AV_ROUND_DOWN);
brktimegm(ct, &tc); brktimegm(ct, &tc);
buf[1] = 0xff; /* ds, tm, tens of time zone, units of time zone */ buf[1] = 0xff; /* ds, tm, tens of time zone, units of time zone */
/* 0xff is very likely to be "unknown" */ /* 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 ...@@ -154,8 +154,8 @@ static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t* bu
break; break;
case dv_audio_rectime: /* AAUX recording time */ case dv_audio_rectime: /* AAUX recording time */
case dv_video_rectime: /* VAUX recording time */ case dv_video_rectime: /* VAUX recording time */
ct = c->start_time + (time_t)(c->frames / ct = c->start_time + av_rescale_rnd(c->frames, c->sys->time_base.num,
((float)c->sys->frame_rate / (float)c->sys->frame_rate_base)); c->sys->time_base.den, AV_ROUND_DOWN);
brktimegm(ct, &tc); brktimegm(ct, &tc);
buf[1] = (3 << 6) | /* reserved -- always 1 */ buf[1] = (3 << 6) | /* reserved -- always 1 */
0x3f; /* tens of frame, units of frame: 0x3f - "unknown" ? */ 0x3f; /* tens of frame, units of frame: 0x3f - "unknown" ? */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment