[FFmpeg-devel] Fix for bug #2689

Frederic Turmel me at fredt.org
Fri May 16 03:05:38 CEST 2014

Hi, here’s the patch for bug 2689. This will prevent ffmpeg from reporting wrong aspect ratio information in the mpeg 2 sequence header.

The problem was that when the input aspect ratio match exactly an “mpeg2 aspect ratio”(16:9,4:3), the error/delta = 0 which means that the for loop that iterates through the possible aspect ratio will select the previous best error difference instead of a perfect match. This is because the initial error is set to zero.

Example if the input aspect ratio is 16:9 the algorithm will not select 16:9 but 1:1 because the first iteration will give an initial error of 0 due to the if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO || i <= 1). It will then set the aspect ratio to 1:1, so we need to allow finding a next best match that can have an error of zero. When there is a perfect match the error will be equal to zero again. By adding the equal sign it will allow the for loop to select the best aspect ratio.

if (error <= best_aspect_error) {
    best_aspect_error    = error;
    s->aspect_ratio_info = i;

PS: I’m not familiar with the patch submission system for open source in general. This is a first for me. Sorry if I don’t have the right reporting format but I’m willing to learn. I will appreciate if somebody can guide me for the next step.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-fix-2689.patch
Type: application/octet-stream
Size: 740 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140515/070770ea/attachment.obj>

More information about the ffmpeg-devel mailing list