summaryrefslogtreecommitdiffstats
path: root/media/ffmpeg
diff options
context:
space:
mode:
authorscottfr@chromium.org <scottfr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-02 03:01:07 +0000
committerscottfr@chromium.org <scottfr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-02 03:01:07 +0000
commitf649bf548e4cbc6bfa0ab853ea2b0a9d8183fa2b (patch)
treeda830829da42937075575e9140803f66578921b5 /media/ffmpeg
parent32d017b5eae0c4b39370f57b09a6395b468ad6ef (diff)
downloadchromium_src-f649bf548e4cbc6bfa0ab853ea2b0a9d8183fa2b.zip
chromium_src-f649bf548e4cbc6bfa0ab853ea2b0a9d8183fa2b.tar.gz
chromium_src-f649bf548e4cbc6bfa0ab853ea2b0a9d8183fa2b.tar.bz2
Respect pixel aspect ratio of video if it contains one.
BUG=18941 TEST=Check correct AR on http://people.xiph.org/~giles/2009/celt-aspect.html Alternately, fix 59412 and run media/video-display-aspect-ratio layout test Review URL: http://codereview.chromium.org/7086002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87578 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/ffmpeg')
-rw-r--r--media/ffmpeg/ffmpeg_common.cc21
-rw-r--r--media/ffmpeg/ffmpeg_common.h6
2 files changed, 27 insertions, 0 deletions
diff --git a/media/ffmpeg/ffmpeg_common.cc b/media/ffmpeg/ffmpeg_common.cc
index dedc40c..2ccd4eb 100644
--- a/media/ffmpeg/ffmpeg_common.cc
+++ b/media/ffmpeg/ffmpeg_common.cc
@@ -185,4 +185,25 @@ bool GetStreamByteCountOverRange(AVStream* stream,
return true;
}
+int GetSurfaceHeight(AVStream* stream) {
+ return stream->codec->coded_height;
+}
+
+int GetSurfaceWidth(AVStream* stream) {
+ double aspect_ratio;
+
+ if (stream->sample_aspect_ratio.num)
+ aspect_ratio = av_q2d(stream->sample_aspect_ratio);
+ else if (stream->codec->sample_aspect_ratio.num)
+ aspect_ratio = av_q2d(stream->codec->sample_aspect_ratio);
+ else
+ aspect_ratio = 1.0;
+
+ int width = floor(stream->codec->coded_width * aspect_ratio + 0.5);
+
+ // An even width makes things easier for YV12 and appears to be the behavior
+ // expected by WebKit layout tests.
+ return width & ~1;
+}
+
} // namespace media
diff --git a/media/ffmpeg/ffmpeg_common.h b/media/ffmpeg/ffmpeg_common.h
index 3d39d52..07daae1 100644
--- a/media/ffmpeg/ffmpeg_common.h
+++ b/media/ffmpeg/ffmpeg_common.h
@@ -103,6 +103,12 @@ bool GetStreamByteCountOverRange(AVStream* stream,
int64* bytes,
base::TimeDelta* range_start,
base::TimeDelta* range_end);
+
+// Calculates the width and height of the video surface using the video's
+// encoded dimensions and sample_aspect_ratio.
+int GetSurfaceHeight(AVStream* stream);
+int GetSurfaceWidth(AVStream* stream);
+
} // namespace media
#endif // MEDIA_FFMPEG_FFMPEG_COMMON_H_