Quality optimization concerning Cropping and De-Anamorphing
Posted: Fri May 28, 2010 1:25 am
Consider the following thoughts. Comments/corrections are very welcome!
Note: I have limited English vocabulary in the fields of Mathematics and Logic, I hope you can nevertheless understand my reasoning.
CROPPING
1) If your source video contains a "letterbox" or "pillarbox" or even worse both of them aka "postage-stamping" you very likely want to crop it, as:
a) this unnecessary information would just waste storage space (if you have set an average bitrate) or decrease quality (if you have set a fixed target size).
b) the handling of this files is complicated in many SW/HW media players (auto fullscreen fill functions won't work as expected).
So you will crop it, but at the same time, you want to achieve the optimal ratio of quality/storage-requirement!
As far as I know from the documentation:
a) To fully utilize the codec, the picture size must be a multiple of the codec's macroblock size (16x16 for MPEG formats).
b) The anamorphic settings "loose" and "none" ensure that the picture size is a macroblock multiple.
Assuming this I conclude the following:
1.1) If you need to crop your picture, and want to achieve the best result with the rescaling algorithm, which also follows the rules of mathematics, then crop to a size of:
a) Best, as this needs least or only little interpolation: "2^n * m"
b) Still ok, needs little interpolation: "n * m" Except of course those which match (a)
c) Less good, needs much interpolation: "n" Except of course those which match (a) or (b)
Legend:
n = Positive integer = 0,1,2,3,...
m = Macroblock size = 16
DE-ANAMORPHING (Achieve a video file native 1:1 PAR)
2) If you intend to mainly use the video file on computer monitors then I strongly prefer a 1:1 PAR rather than an anamorphic PAR because:
a) Computer display devices mostly use native 1:1 pixel aspect ratios, no stretching/compression processing at runtime needed (even if that anyhow happens on the GPU).
b) So why not bring the video into a PAR of 1:1 ONCE AND ONLY while its initial generation process, compared to EACH RUNTIME if you open it in your media playing software, which needs to un-distort it for usage within your 1:1 PAR medium? I think the first one is far more efficient!
2.1) Hence you will use "Anamorphic: None" and as well you likely want to "Keep aspect ratio: Yes".
If you then use certain crop sizes in combination with certain picture sizes, this necessarily results in a slight distortion compared to the original aspect ratio.
The smaller the target picture size, the more distortion recognisable, as the worst possible ratio of the jump intervals (= macroblock size) to the picture dimensions grows.
The larger the target picture size, the less distortion recognisable, as the worst possible ratio of the jump intervals (= macroblock size) to the picture dimensions shrinks then.
FEATURE SUGGESTION
2.2) Currently Handbrake shows this in the preview window:
Source: NxN, Output: NxN
For informing the user better, how far s/he manipulates the aspect ratio under the current settings, it would be nice if Handbrake would showt:
Source: NxN, Output: NxN, Output PAR: 1:1.xxxx, Difference to original PAR: None | +X.XX% (to fat) | -X.XX% (to thin)
Note: I have limited English vocabulary in the fields of Mathematics and Logic, I hope you can nevertheless understand my reasoning.
CROPPING
1) If your source video contains a "letterbox" or "pillarbox" or even worse both of them aka "postage-stamping" you very likely want to crop it, as:
a) this unnecessary information would just waste storage space (if you have set an average bitrate) or decrease quality (if you have set a fixed target size).
b) the handling of this files is complicated in many SW/HW media players (auto fullscreen fill functions won't work as expected).
So you will crop it, but at the same time, you want to achieve the optimal ratio of quality/storage-requirement!
As far as I know from the documentation:
a) To fully utilize the codec, the picture size must be a multiple of the codec's macroblock size (16x16 for MPEG formats).
b) The anamorphic settings "loose" and "none" ensure that the picture size is a macroblock multiple.
Assuming this I conclude the following:
1.1) If you need to crop your picture, and want to achieve the best result with the rescaling algorithm, which also follows the rules of mathematics, then crop to a size of:
a) Best, as this needs least or only little interpolation: "2^n * m"
b) Still ok, needs little interpolation: "n * m" Except of course those which match (a)
c) Less good, needs much interpolation: "n" Except of course those which match (a) or (b)
Legend:
n = Positive integer = 0,1,2,3,...
m = Macroblock size = 16
DE-ANAMORPHING (Achieve a video file native 1:1 PAR)
2) If you intend to mainly use the video file on computer monitors then I strongly prefer a 1:1 PAR rather than an anamorphic PAR because:
a) Computer display devices mostly use native 1:1 pixel aspect ratios, no stretching/compression processing at runtime needed (even if that anyhow happens on the GPU).
b) So why not bring the video into a PAR of 1:1 ONCE AND ONLY while its initial generation process, compared to EACH RUNTIME if you open it in your media playing software, which needs to un-distort it for usage within your 1:1 PAR medium? I think the first one is far more efficient!
2.1) Hence you will use "Anamorphic: None" and as well you likely want to "Keep aspect ratio: Yes".
If you then use certain crop sizes in combination with certain picture sizes, this necessarily results in a slight distortion compared to the original aspect ratio.
The smaller the target picture size, the more distortion recognisable, as the worst possible ratio of the jump intervals (= macroblock size) to the picture dimensions grows.
The larger the target picture size, the less distortion recognisable, as the worst possible ratio of the jump intervals (= macroblock size) to the picture dimensions shrinks then.
FEATURE SUGGESTION
2.2) Currently Handbrake shows this in the preview window:
Source: NxN, Output: NxN
For informing the user better, how far s/he manipulates the aspect ratio under the current settings, it would be nice if Handbrake would showt:
Source: NxN, Output: NxN, Output PAR: 1:1.xxxx, Difference to original PAR: None | +X.XX% (to fat) | -X.XX% (to thin)