Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(888)

Unified Diff: media/base/video_util.cc

Issue 10830110: Remove VideoDecoderConfig::aspect_ratio_xxx methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/base/video_util.cc
diff --git a/media/base/video_util.cc b/media/base/video_util.cc
index 4476e6d0693e3934ec99f75392fcf610eba15ea1..db0e2d734bd0bde8f2a947e66f792d1ef3a4cb9c 100644
--- a/media/base/video_util.cc
+++ b/media/base/video_util.cc
@@ -4,11 +4,31 @@
#include "media/base/video_util.h"
+#include <cmath>
+
#include "base/logging.h"
#include "media/base/video_frame.h"
namespace media {
+gfx::Size GetNaturalSize(const gfx::Rect& visible_rect,
+ int aspect_ratio_numerator,
+ int aspect_ratio_denominator) {
+ if (aspect_ratio_denominator == 0)
+ return gfx::Size();
+
+ // Calculate the natural size given the aspect ratio and visible rect.
+ double aspect_ratio = aspect_ratio_numerator /
+ static_cast<double>(aspect_ratio_denominator);
+
+ int width = floor(visible_rect.width() * aspect_ratio + 0.5);
+ int height = visible_rect.height();
+
+ // An even width makes things easier for YV12 and appears to be the behavior
+ // expected by WebKit layout tests.
+ return gfx::Size(width & ~1, height);
+}
+
static void CopyPlane(size_t plane, const uint8* source, int stride, int rows,
VideoFrame* frame) {
uint8* dest = frame->data(plane);

Powered by Google App Engine
This is Rietveld 408576698