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

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: 4969ee91 Initial. Created 7 years, 2 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_frame.cc
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc
index a372889cb55a9f3ff2dedacdaf023e054cf56bf6..52a18f0b2906d3d85df826e6db576cecc1ba3841 100644
--- a/media/base/video_frame.cc
+++ b/media/base/video_frame.cc
@@ -118,7 +118,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,24 +255,64 @@ 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) {
switch (format) {
case VideoFrame::RGB32:
- return coded_size.GetArea() * 4;
+ switch (plane) {
+ case VideoFrame::kRGBPlane:
+ return coded_size.GetArea() * 4;
+ default:
+ break;
+ }
case VideoFrame::YV12:
case VideoFrame::I420: {
- const size_t rounded_size =
+ const size_t area =
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 =
+ const size_t area =
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 =
+ const size_t area =
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::INVALID:
case VideoFrame::EMPTY:
@@ -282,7 +322,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;
}

Powered by Google App Engine
This is Rietveld 408576698