comparison mpeg12.c @ 2637:ef44d24680d1 libavcodec

switch to native time bases
author michael
date Sat, 30 Apr 2005 21:43:59 +0000
parents 511e3afc43e1
children d1609cfeb1d0
comparison
equal deleted inserted replaced
2636:2344c6713011 2637:ef44d24680d1
199 int i; 199 int i;
200 int64_t dmin= INT64_MAX; 200 int64_t dmin= INT64_MAX;
201 int64_t d; 201 int64_t d;
202 202
203 for(i=1;i<14;i++) { 203 for(i=1;i<14;i++) {
204 int64_t n0= 1001LL/frame_rate_tab[i].den*frame_rate_tab[i].num*s->avctx->frame_rate_base; 204 int64_t n0= 1001LL/frame_rate_tab[i].den*frame_rate_tab[i].num*s->avctx->time_base.num;
205 int64_t n1= 1001LL*s->avctx->frame_rate; 205 int64_t n1= 1001LL*s->avctx->time_base.den;
206 if(s->avctx->strict_std_compliance >= 0 && i>=9) break; 206 if(s->avctx->strict_std_compliance >= 0 && i>=9) break;
207 207
208 d = ABS(n0 - n1); 208 d = ABS(n0 - n1);
209 if(d < dmin){ 209 if(d < dmin){
210 dmin=d; 210 dmin=d;
224 if(MPV_encode_init(avctx) < 0) 224 if(MPV_encode_init(avctx) < 0)
225 return -1; 225 return -1;
226 226
227 if(find_frame_rate_index(s) < 0){ 227 if(find_frame_rate_index(s) < 0){
228 if(s->strict_std_compliance >=0){ 228 if(s->strict_std_compliance >=0){
229 av_log(avctx, AV_LOG_ERROR, "MPEG1/2 does not support %d/%d fps\n", avctx->frame_rate, avctx->frame_rate_base); 229 av_log(avctx, AV_LOG_ERROR, "MPEG1/2 does not support %d/%d fps\n", avctx->time_base.den, avctx->time_base.num);
230 return -1; 230 return -1;
231 }else{ 231 }else{
232 av_log(avctx, AV_LOG_INFO, "MPEG1/2 does not support %d/%d fps, there may be AV sync issues\n", avctx->frame_rate, avctx->frame_rate_base); 232 av_log(avctx, AV_LOG_INFO, "MPEG1/2 does not support %d/%d fps, there may be AV sync issues\n", avctx->time_base.den, avctx->time_base.num);
233 } 233 }
234 } 234 }
235 235
236 return 0; 236 return 0;
237 } 237 }
2097 //that behave like P frames 2097 //that behave like P frames
2098 avctx->has_b_frames = !(s->low_delay); 2098 avctx->has_b_frames = !(s->low_delay);
2099 2099
2100 if(avctx->sub_id==1){//s->codec_id==avctx->codec_id==CODEC_ID 2100 if(avctx->sub_id==1){//s->codec_id==avctx->codec_id==CODEC_ID
2101 //mpeg1 fps 2101 //mpeg1 fps
2102 avctx->frame_rate = frame_rate_tab[s->frame_rate_index].num; 2102 avctx->time_base.den = frame_rate_tab[s->frame_rate_index].num;
2103 avctx->frame_rate_base= frame_rate_tab[s->frame_rate_index].den; 2103 avctx->time_base.num= frame_rate_tab[s->frame_rate_index].den;
2104 //mpeg1 aspect 2104 //mpeg1 aspect
2105 avctx->sample_aspect_ratio= av_d2q( 2105 avctx->sample_aspect_ratio= av_d2q(
2106 1.0/mpeg1_aspect[s->aspect_ratio_info], 255); 2106 1.0/mpeg1_aspect[s->aspect_ratio_info], 255);
2107 2107
2108 }else{//mpeg2 2108 }else{//mpeg2
2109 //mpeg2 fps 2109 //mpeg2 fps
2110 av_reduce( 2110 av_reduce(
2111 &s->avctx->frame_rate, 2111 &s->avctx->time_base.den,
2112 &s->avctx->frame_rate_base, 2112 &s->avctx->time_base.num,
2113 frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num, 2113 frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num,
2114 frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den, 2114 frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den,
2115 1<<30); 2115 1<<30);
2116 //mpeg2 aspect 2116 //mpeg2 aspect
2117 if(s->aspect_ratio_info > 1){ 2117 if(s->aspect_ratio_info > 1){