Commit b8e7e107 by Oliver Woodman

Fix bad pixel w:h ratio calculation in H262 reader.

It appears the spec calculation gives the h:w pixel ratio, where-as
we want w:h. It's pretty easy to convince oneself that this way round
is correct. Consider a video that's 100px by 100px, and setting
aspectRatioCode=3 to achieve this. The pixelWidthHeightRatio needs to
be 16/9 and not 9/16 :).

Issue: #965
parent 18ae955f
...@@ -148,13 +148,13 @@ import java.util.Collections; ...@@ -148,13 +148,13 @@ import java.util.Collections;
int aspectRatioCode = (csdData[7] & 0xF0) >> 4; int aspectRatioCode = (csdData[7] & 0xF0) >> 4;
switch(aspectRatioCode) { switch(aspectRatioCode) {
case 2: case 2:
pixelWidthHeightRatio = (3 * width) / (float) (4 * height); pixelWidthHeightRatio = (4 * height) / (float) (3 * width);
break; break;
case 3: case 3:
pixelWidthHeightRatio = (9 * width) / (float) (16 * height); pixelWidthHeightRatio = (16 * height) / (float) (9 * width);
break; break;
case 4: case 4:
pixelWidthHeightRatio = (100 * width) / (float) (121 * height); pixelWidthHeightRatio = (121 * height) / (float) (100 * width);
break; break;
default: default:
// Do nothing. // Do nothing.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment