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

Unified Diff: media/base/video_frame.cc

Issue 22875047: EVEA cleanup: use video utility functions in media::* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@git-svn
Patch Set: b2b1b2ee Last comments. Created 7 years, 4 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
« no previous file with comments | « media/base/video_frame.h ('k') | media/video/capture/fake_video_capture_device.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/video_frame.cc
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc
index 08e7e1ad7a236f3ab29d5e7ee6fc9da2098fb630..a372889cb55a9f3ff2dedacdaf023e054cf56bf6 100644
--- a/media/base/video_frame.cc
+++ b/media/base/video_frame.cc
@@ -124,9 +124,13 @@ scoped_refptr<VideoFrame> VideoFrame::WrapExternalSharedMemory(
const gfx::Rect& visible_rect,
const gfx::Size& natural_size,
uint8* data,
+ size_t data_size,
base::SharedMemoryHandle handle,
base::TimeDelta timestamp,
const base::Closure& no_longer_needed_cb) {
+ if (data_size < AllocationSize(format, coded_size))
+ return NULL;
+
switch (format) {
case I420: {
scoped_refptr<VideoFrame> frame(new VideoFrame(
@@ -249,6 +253,39 @@ static inline size_t RoundUp(size_t value, size_t alignment) {
return ((value + (alignment - 1)) & ~(alignment-1));
}
+// static
+size_t VideoFrame::AllocationSize(Format format, const gfx::Size& coded_size) {
+ switch (format) {
+ case VideoFrame::RGB32:
+ return coded_size.GetArea() * 4;
+ case VideoFrame::YV12:
+ case VideoFrame::I420: {
+ const size_t rounded_size =
+ RoundUp(coded_size.width(), 2) * RoundUp(coded_size.height(), 2);
+ return rounded_size * 3 / 2;
+ }
+ case VideoFrame::YV12A: {
+ const size_t rounded_size =
+ RoundUp(coded_size.width(), 2) * RoundUp(coded_size.height(), 2);
+ return rounded_size * 5 / 2;
+ }
+ case VideoFrame::YV16: {
+ const size_t rounded_size =
+ RoundUp(coded_size.width(), 2) * RoundUp(coded_size.height(), 2);
+ return rounded_size * 2;
+ }
+ case VideoFrame::INVALID:
+ case VideoFrame::EMPTY:
+ case VideoFrame::NATIVE_TEXTURE:
+#if defined(GOOGLE_TV)
+ case VideoFrame::HOLE:
+#endif
+ break;
+ }
+ NOTREACHED() << "Unsupported video frame format: " << format;
+ return 0;
+}
+
// Release data allocated by AllocateRGB() or AllocateYUV().
static void ReleaseData(uint8* data) {
DCHECK(data);
« no previous file with comments | « media/base/video_frame.h ('k') | media/video/capture/fake_video_capture_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698