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

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: 8c5b9836 Nits. 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
Index: media/base/video_frame.cc
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc
index f9f789bdbe0d575ef98853f7e6d78b41a48dbe51..490dd784f0db13ae564473533db409dc4079021c 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,57 @@ 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::YV12:
case VideoFrame::I420: {
- const size_t rounded_size =
+ const size_t area =
RoundUp(coded_size.width(), 2) * RoundUp(coded_size.height(), 2);
Ami GONE FROM CHROMIUM 2013/11/19 21:01:52 Any reason for this not to be outside the outer sw
ncarter (slow) 2013/11/19 21:32:22 Making the switch statement RoundUp-ready would no
sheu 2013/11/19 21:35:16 communicate with care
- 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::UNKNOWN:
case VideoFrame::NATIVE_TEXTURE:
@@ -280,7 +315,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