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

Unified Diff: media/base/video_frame.cc

Issue 406893002: Fix DCHECKs in V4l2VideoDevice. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments Created 6 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
« 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 456cf6e9d887bc089e4c899db1cb84d9e99fd3d3..6b3427db1aa936c1707b507f13e1070ed33710b0 100644
--- a/media/base/video_frame.cc
+++ b/media/base/video_frame.cc
@@ -689,19 +689,20 @@ VideoFrame::~VideoFrame() {
base::ResetAndReturn(&no_longer_needed_cb_).Run();
}
-bool VideoFrame::IsValidPlane(size_t plane) const {
- return (plane < NumPlanes(format_));
+// static
+bool VideoFrame::IsValidPlane(size_t plane, VideoFrame::Format format) {
+ return (plane < NumPlanes(format));
}
int VideoFrame::stride(size_t plane) const {
- DCHECK(IsValidPlane(plane));
+ DCHECK(IsValidPlane(plane, format_));
return strides_[plane];
}
-int VideoFrame::row_bytes(size_t plane) const {
- DCHECK(IsValidPlane(plane));
- int width = coded_size_.width();
- switch (format_) {
+// static
+int VideoFrame::RowBytes(size_t plane, VideoFrame::Format format, int width) {
+ DCHECK(IsValidPlane(plane, format));
+ switch (format) {
case VideoFrame::YV24:
switch (plane) {
case kYPlane:
@@ -754,13 +755,17 @@ int VideoFrame::row_bytes(size_t plane) const {
case VideoFrame::NATIVE_TEXTURE:
break;
}
- NOTREACHED() << "Unsupported video frame format/plane: "
- << format_ << "/" << plane;
+ NOTREACHED() << "Unsupported video frame format/plane: " << format << "/"
+ << plane;
return 0;
}
+int VideoFrame::row_bytes(size_t plane) const {
+ return RowBytes(plane, format_, coded_size_.width());
+}
+
int VideoFrame::rows(size_t plane) const {
- DCHECK(IsValidPlane(plane));
+ DCHECK(IsValidPlane(plane, format_));
int height = coded_size_.height();
switch (format_) {
case VideoFrame::YV24:
@@ -822,7 +827,7 @@ int VideoFrame::rows(size_t plane) const {
}
uint8* VideoFrame::data(size_t plane) const {
- DCHECK(IsValidPlane(plane));
+ DCHECK(IsValidPlane(plane, format_));
return data_[plane];
}
@@ -854,7 +859,7 @@ int VideoFrame::dmabuf_fd(size_t plane) const {
void VideoFrame::HashFrameForTesting(base::MD5Context* context) {
for (int plane = 0; plane < kMaxPlanes; ++plane) {
- if (!IsValidPlane(plane))
+ if (!IsValidPlane(plane, format_))
break;
for (int row = 0; row < rows(plane); ++row) {
base::MD5Update(context, base::StringPiece(
« 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