[FFmpeg-devel] [PATCH] Print pixel and screen aspect ratios

Michel Bardiaux mbardiaux
Thu Oct 18 14:48:31 CEST 2007


Robert Swain a ?crit :
> Hello,
> 
> On 18 Oct 2007, at 12:49, Michel Bardiaux wrote:
>> Index: libavcodec/utils.c
>> ===================================================================
>> --- libavcodec/utils.c	(revision 10716)
>> +++ libavcodec/utils.c	(working copy)
>> @@ -1075,6 +1075,7 @@
>>      char buf1[32];
>>      char channels_str[100];
>>      int bitrate;
>> +    AVRational screen_aspect_ratio;
>>
>>      if (encode)
>>          p = avcodec_find_encoder(enc->codec_id);
>> @@ -1125,6 +1126,14 @@
>>              snprintf(buf + strlen(buf), buf_size - strlen(buf),
>>                       ", %dx%d",
>>                       enc->width, enc->height);
>> +            av_reduce(&screen_aspect_ratio.num,  
>> &screen_aspect_ratio.den,
>> +                      enc->width*enc->sample_aspect_ratio.num,
>> +                      enc->height*enc->sample_aspect_ratio.den,
>> +                      1024*1024);
>> +            snprintf(buf + strlen(buf), buf_size - strlen(buf),
>> +                     " [PAR %d:%d SAR %d:%d]",
> 
> SAR is a bad choice of nomenclature, one because everyone else calls  
> this the display aspect ratio, as far as I am aware, and two because  
> SAR is an abbreviation for an alternative to PAR (pixel vs sample,  
> same meaning).

Valid point. DAR it is. New patch attached.

BTW: detecting changes of SAR in the video stream would be good, but (1) 
I dont know what would be a good place (avcodec_decode_video?) (2) We 
should also detect changes of width, height, since all 3 may change at 
anytime in digital-TV streaming (and are likely to when HDTV comes!)

> 
>> +                     enc->sample_aspect_ratio.num, enc- 
>>> sample_aspect_ratio.den,
>> +                     screen_aspect_ratio.num,  
>> screen_aspect_ratio.den);
>>              if(av_log_level >= AV_LOG_DEBUG){
>>                  int g= ff_gcd(enc->time_base.num, enc- 
>>> time_base.den);
>>                  snprintf(buf + strlen(buf), buf_size - strlen(buf),


-- 
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:mbardiaux at mediaxim.be

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pixel_aspect_ratio.pat
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20071018/6c341292/attachment.asc>



More information about the ffmpeg-devel mailing list