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

Unified Diff: media/base/video_frame.cc

Issue 604743005: VideoCapture: Remove deep frame copy in the border to libJingle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: perkj@s comments 2 Created 6 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
« media/base/video_frame.h ('K') | « media/base/video_frame.h ('k') | no next file » | 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 5f0d7282c6e01aedfe0861ee90e55e2cb319b7c1..33b00549db270bf5fc9a2d311e6b02414409f23c 100644
--- a/media/base/video_frame.cc
+++ b/media/base/video_frame.cc
@@ -27,6 +27,12 @@ static inline size_t RoundUp(size_t value, size_t alignment) {
return ((value + (alignment - 1)) & ~(alignment - 1));
}
+static inline size_t RoundDown(size_t value, size_t alignment) {
+ // Check that |alignment| is a power of 2.
+ DCHECK((alignment + (alignment - 1)) == (alignment | (alignment - 1)));
+ return value & ~(alignment - 1);
+}
+
// Rounds up |coded_size| if necessary for |format|.
static gfx::Size AdjustCodedSize(VideoFrame::Format format,
const gfx::Size& coded_size) {
@@ -881,11 +887,40 @@ int VideoFrame::rows(size_t plane) const {
return Rows(plane, format_, coded_size_.height());
}
-uint8* VideoFrame::data(size_t plane) const {
+const uint8* VideoFrame::data(size_t plane) const {
DCHECK(IsValidPlane(plane, format_));
return data_[plane];
}
+uint8* VideoFrame::data(size_t plane) {
+ DCHECK(IsValidPlane(plane, format_));
+ return data_[plane];
+}
+
+const uint8* VideoFrame::visible_data(size_t plane) const {
+ DCHECK(IsValidPlane(plane, format_));
+ const uint8* coded_data = data(plane);
+ const int coded_stride = stride(plane);
+ const int offset_x = RoundDown(visible_rect_.x(), 2);
scherkus (not reviewing) 2014/10/20 19:30:36 could you add a comment briefly explaining the mat
magjed_chromium 2014/10/22 15:16:39 This is removed now. See comment below.
+ const int offset_y = RoundDown(visible_rect_.y(), 2);
+ switch (plane) {
+ case kYPlane:
+ case kAPlane:
+ return coded_data + offset_y * coded_stride + offset_x;
+ case kUPlane:
+ case kVPlane:
+ return coded_data + offset_y / 2 * coded_stride + offset_x / 2;
scherkus (not reviewing) 2014/10/20 19:30:36 are you sure the division-by-two makes sense even
magjed_chromium 2014/10/22 15:16:39 You are right, it does not make sense. It is hardc
+ default:
scherkus (not reviewing) 2014/10/20 19:30:36 can you list these cases explicitly? if we ever ch
magjed_chromium 2014/10/22 15:16:39 Done. Not applicable anymore.
+ NOTIMPLEMENTED();
+ return NULL;
+ }
+}
+
+uint8* VideoFrame::visible_data(size_t plane) {
+ return const_cast<uint8*>(
+ static_cast<const VideoFrame*>(this)->visible_data(plane));
+}
+
const gpu::MailboxHolder* VideoFrame::mailbox_holder() const {
DCHECK_EQ(format_, NATIVE_TEXTURE);
return mailbox_holder_.get();
« media/base/video_frame.h ('K') | « media/base/video_frame.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698