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

Unified Diff: media/base/video_frame.cc

Issue 48113011: Remove media::VideoFrame from media::VideoCaptureDevice::Client interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@git-svn
Patch Set: ffdbaeb83 Trybot failures. Created 7 years, 1 month 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/android/video_capture_device_android.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 f9f789bdbe0d575ef98853f7e6d78b41a48dbe51..3541e6efa4da95bb3e4b41be61841a5c7e43c4f1 100644
--- a/media/base/video_frame.cc
+++ b/media/base/video_frame.cc
@@ -117,7 +117,7 @@ void VideoFrame::ReadPixelsFromNativeTexture(const SkBitmap& pixels) {
}
// static
-scoped_refptr<VideoFrame> VideoFrame::WrapExternalSharedMemory(
+scoped_refptr<VideoFrame> VideoFrame::WrapExternalPackedMemory(
Format format,
const gfx::Size& coded_size,
const gfx::Rect& visible_rect,
@@ -255,22 +255,53 @@ static inline size_t RoundUp(size_t value, size_t alignment) {
// static
size_t VideoFrame::AllocationSize(Format format, const gfx::Size& coded_size) {
+ size_t total = 0;
+ for (size_t i = 0; i < NumPlanes(format); ++i)
+ total += PlaneAllocationSize(format, i, coded_size);
+ return total;
+}
+
+// static
+size_t VideoFrame::PlaneAllocationSize(Format format,
+ size_t plane,
+ const gfx::Size& coded_size) {
+ const size_t area =
+ RoundUp(coded_size.width(), 2) * RoundUp(coded_size.height(), 2);
switch (format) {
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;
+ switch (plane) {
+ case VideoFrame::kYPlane:
+ return area;
+ case VideoFrame::kUPlane:
+ case VideoFrame::kVPlane:
+ return area / 4;
+ default:
+ break;
+ }
}
case VideoFrame::YV12A: {
- const size_t rounded_size =
- RoundUp(coded_size.width(), 2) * RoundUp(coded_size.height(), 2);
- return rounded_size * 5 / 2;
+ switch (plane) {
+ case VideoFrame::kYPlane:
+ case VideoFrame::kAPlane:
+ return area;
+ case VideoFrame::kUPlane:
+ case VideoFrame::kVPlane:
+ return area / 4;
+ default:
+ break;
+ }
}
case VideoFrame::YV16: {
- const size_t rounded_size =
- RoundUp(coded_size.width(), 2) * RoundUp(coded_size.height(), 2);
- return rounded_size * 2;
+ switch (plane) {
+ case VideoFrame::kYPlane:
+ return area;
+ case VideoFrame::kUPlane:
+ case VideoFrame::kVPlane:
+ return area / 2;
+ default:
+ break;
+ }
}
case VideoFrame::UNKNOWN:
case VideoFrame::NATIVE_TEXTURE:
@@ -280,7 +311,8 @@ size_t VideoFrame::AllocationSize(Format format, const gfx::Size& coded_size) {
#endif
break;
}
- NOTREACHED() << "Unsupported video frame format: " << format;
+ NOTREACHED() << "Unsupported video frame format/plane: "
+ << format << "/" << plane;
return 0;
}
« no previous file with comments | « media/base/video_frame.h ('k') | media/video/capture/android/video_capture_device_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698