changeset 1550:fca47124001d libavcodec

mpeg2 aspect ratio encoding fixed
author michael
date Mon, 20 Oct 2003 23:24:39 +0000
parents 5e643dd7e889
children 85028cd13cf1
files mpeg12.c
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mpeg12.c	Mon Oct 20 22:33:53 2003 +0000
+++ b/mpeg12.c	Mon Oct 20 23:24:39 2003 +0000
@@ -219,7 +219,12 @@
             put_bits(&s->pb, 12, s->height);
             
             for(i=1; i<15; i++){
-                float error= mpeg1_aspect[i] - aspect_ratio;
+                float error= aspect_ratio;
+                if(s->codec_id == CODEC_ID_MPEG1VIDEO || i <=1)
+                    error-= mpeg1_aspect[i];
+                else
+                    error-= av_q2d(mpeg2_aspect[i])*s->height/s->width;
+             
                 error= ABS(error);
                 
                 if(error < best_aspect_error){
@@ -2252,7 +2257,7 @@
     s->aspect_ratio_info= get_bits(&s->gb, 4);
     if(s->codec_id == CODEC_ID_MPEG1VIDEO){
         aspect= mpeg1_aspect[s->aspect_ratio_info];
-        if(aspect!=0.0) avctx->sample_aspect_ratio= av_d2q(aspect, 30000);
+        if(aspect!=0.0) avctx->sample_aspect_ratio= av_d2q(aspect, 255);
     }
 
     s->frame_rate_index = get_bits(&s->gb, 4);