Index: media/base/video_util.cc |
diff --git a/media/base/video_util.cc b/media/base/video_util.cc |
index 4476e6d0693e3934ec99f75392fcf610eba15ea1..4bef0adc88b1e92a17ff0e3e9fe3543ac646fce9 100644 |
--- a/media/base/video_util.cc |
+++ b/media/base/video_util.cc |
@@ -4,11 +4,32 @@ |
#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::Size& visible_size, |
+ int aspect_ratio_numerator, |
+ int aspect_ratio_denominator) { |
+ if (aspect_ratio_denominator == 0 || |
+ aspect_ratio_numerator < 0 || |
+ aspect_ratio_denominator < 0) |
+ return gfx::Size(); |
+ |
+ double aspect_ratio = aspect_ratio_numerator / |
+ static_cast<double>(aspect_ratio_denominator); |
+ |
+ int width = floor(visible_size.width() * aspect_ratio + 0.5); |
+ int height = visible_size.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); |