comparison mpeg12.c @ 1550:fca47124001d libavcodec

mpeg2 aspect ratio encoding fixed
author michael
date Mon, 20 Oct 2003 23:24:39 +0000
parents dd544554ed42
children 628bf341e099
comparison
equal deleted inserted replaced
1549:5e643dd7e889 1550:fca47124001d
217 217
218 put_bits(&s->pb, 12, s->width); 218 put_bits(&s->pb, 12, s->width);
219 put_bits(&s->pb, 12, s->height); 219 put_bits(&s->pb, 12, s->height);
220 220
221 for(i=1; i<15; i++){ 221 for(i=1; i<15; i++){
222 float error= mpeg1_aspect[i] - aspect_ratio; 222 float error= aspect_ratio;
223 if(s->codec_id == CODEC_ID_MPEG1VIDEO || i <=1)
224 error-= mpeg1_aspect[i];
225 else
226 error-= av_q2d(mpeg2_aspect[i])*s->height/s->width;
227
223 error= ABS(error); 228 error= ABS(error);
224 229
225 if(error < best_aspect_error){ 230 if(error < best_aspect_error){
226 best_aspect_error= error; 231 best_aspect_error= error;
227 s->aspect_ratio_info= i; 232 s->aspect_ratio_info= i;
2250 width = get_bits(&s->gb, 12); 2255 width = get_bits(&s->gb, 12);
2251 height = get_bits(&s->gb, 12); 2256 height = get_bits(&s->gb, 12);
2252 s->aspect_ratio_info= get_bits(&s->gb, 4); 2257 s->aspect_ratio_info= get_bits(&s->gb, 4);
2253 if(s->codec_id == CODEC_ID_MPEG1VIDEO){ 2258 if(s->codec_id == CODEC_ID_MPEG1VIDEO){
2254 aspect= mpeg1_aspect[s->aspect_ratio_info]; 2259 aspect= mpeg1_aspect[s->aspect_ratio_info];
2255 if(aspect!=0.0) avctx->sample_aspect_ratio= av_d2q(aspect, 30000); 2260 if(aspect!=0.0) avctx->sample_aspect_ratio= av_d2q(aspect, 255);
2256 } 2261 }
2257 2262
2258 s->frame_rate_index = get_bits(&s->gb, 4); 2263 s->frame_rate_index = get_bits(&s->gb, 4);
2259 if (s->frame_rate_index == 0) 2264 if (s->frame_rate_index == 0)
2260 return -1; 2265 return -1;