# HG changeset patch # User michaelni # Date 1039191565 0 # Node ID f9e54ade14a1cc194d2b4da1029dee72ca7ab555 # Parent d3aa313dc3731174f791da8dfa00c6c4feb6e297 aspect ratio encoding for mpeg1 diff -r d3aa313dc373 -r f9e54ade14a1 mpeg12.c --- a/mpeg12.c Fri Dec 06 16:04:30 2002 +0000 +++ b/mpeg12.c Fri Dec 06 16:19:25 2002 +0000 @@ -131,8 +131,12 @@ { unsigned int vbv_buffer_size; unsigned int fps, v; - int n; + int n, i; UINT64 time_code; + float best_aspect_error= 1E10; + float aspect_ratio= s->avctx->aspect_ratio; + + if(aspect_ratio==0.0) aspect_ratio= s->width / (float)s->height; //pixel aspect 1:1 (VGA) if (s->current_picture.key_frame) { /* mpeg1 header repeated every gop */ @@ -154,7 +158,18 @@ put_bits(&s->pb, 12, s->width); put_bits(&s->pb, 12, s->height); - put_bits(&s->pb, 4, 1); /* 1/1 aspect ratio */ + + for(i=1; i<15; i++){ + float error= mpeg1_aspect[i] - s->width/(s->height*aspect_ratio); + error= ABS(error); + + if(error < best_aspect_error){ + best_aspect_error= error; + s->aspect_ratio_info= i; + } + } + + put_bits(&s->pb, 4, s->aspect_ratio_info); put_bits(&s->pb, 4, s->frame_rate_index); v = s->bit_rate / 400; if (v > 0x3ffff)