[FFmpeg-devel] [PATCH] avcodec/vc1: correct aspect ratio calculation

Jerome Borsboom jerome.borsboom at carpalis.nl
Wed Nov 14 18:16:38 EET 2018

>> +    av_reduce(&avctx->sample_aspect_ratio.num,
>> +              &avctx->sample_aspect_ratio.den,
>> +              v->disp_horiz_size * v->aspect_ratio.num * h,
>> +              v->disp_vert_size * v->aspect_ratio.den * w,
>> +              1 << 30);
>> +    ff_set_sar(avctx, avctx->sample_aspect_ratio);
> I would have expected these two statements to be redundant -
> am I wrong?
> Carl Eugen

I am not fully sure that I understand your comment.

av_reduce takes out the greatest common divisor and puts a bound on the
individual fraction numbers. ff_set_sar checks that the SAR makes sense
in relation to the image size. Although, the code is reassigning
avctx->sample_aspect_ratio to itself in ff_set_sar, the different checks
make both statements necessary. In addition, the large values that
results from 'v->disp_horiz_size * v->aspect_ratio.num * h' and
'v->disp_vert_size * v->aspect_ratio.den * w', can in most cases be
efficiently reduced.

These two statements are moved to the entrypoint parser, because the
coded size is an entrypoint element. At the position where the av_reduce
statement was previously located, the v->s.avctx->height and
v->s.avctx->width could contain values from the previous entrypoint
header or be zero when parsing the first sequence header.


More information about the ffmpeg-devel mailing list