• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

frameworks/av


Commit MetaInfo

Révisionb13fd4a3a09429c7eacf720c5efd40f5f36c06e9 (tree)
l'heure2020-04-14 22:49:59
AuteurChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Message de Log

nuplayer: skip bad SAR values

Historically there are two definitions of SAR:

1. Storage Aspect Ratio
2. Sample Aspect Ratio

The first one is used in MPEG2 terminology, while the second is used
in MPEG4-AVC terminology.

The MPEG2 terminology actually means the real frame dimension (w:h),
while the MPEG4-AVC terminology means the shape of individual pixels.
It's called PAR (Pixel Aspect Ratio) in MPEG2 terminology.

Android apparently uses the second definition as comments in the code.
However, some video files include SAR tags in MPEG2 terminology sense.
For example,

08-14 18:13:45.212 2841 4769 I NuPlayer: int32_t width = 856
08-14 18:13:45.212 2841 4769 I NuPlayer: int32_t height = 480
08-14 18:13:45.212 2841 4769 I NuPlayer: int32_t sar-width = 852
08-14 18:13:45.212 2841 4769 I NuPlayer: int32_t sar-height = 480

That makes Android calculate the DAR (Display Aspect Ratio)
incorrectly, where DAR = FAR (Frame Aspect Ratio) x SAR.
As a result the video is stretched strangely.

To workaround it, skip the SAR tags if they look like the
Storage Aspect Ratio.

Change Summary

Modification

--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -2066,7 +2066,13 @@ void NuPlayer::updateVideoSize(
20662066 && sarWidth > 0 && sarHeight > 0) {
20672067 ALOGV("Sample aspect ratio %d : %d", sarWidth, sarHeight);
20682068
2069- displayWidth = (displayWidth * sarWidth) / sarHeight;
2069+ if (sarWidth == displayWidth) {
2070+ ALOGW("sarWidth(%d) is the same as displayWidth, assume it's Storage Aspect Ratio and skip it!", sarWidth);
2071+ } else if (sarHeight == displayHeight) {
2072+ ALOGW("sarHeight(%d) is the same as displayHeight, assume it's Storage Aspect Ratio and skip it!", sarHeight);
2073+ } else {
2074+ displayWidth = (displayWidth * sarWidth) / sarHeight;
2075+ }
20702076
20712077 ALOGV("display dimensions %d x %d", displayWidth, displayHeight);
20722078 } else {