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

Unified Diff: media/video/capture/video_capture_types.cc

Issue 897483002: Refactored pixel format resize operations in media/video/capture into a function called VideoCaptu… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed operator spacing. Created 5 years, 11 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/video/capture/video_capture_types.cc
diff --git a/media/video/capture/video_capture_types.cc b/media/video/capture/video_capture_types.cc
index 2cddeee9cbac36cc2d321ae1e54fec02d402f854..902e458c9deaa1f58045c2dc8ae004f54c84d570 100644
--- a/media/video/capture/video_capture_types.cc
+++ b/media/video/capture/video_capture_types.cc
@@ -31,6 +31,33 @@ bool VideoCaptureFormat::IsValid() const {
(pixel_format < PIXEL_FORMAT_MAX);
}
+size_t VideoCaptureFormat::ImageAllocationSize() const {
+ size_t result_frame_size = frame_size.GetArea();
+ switch (pixel_format) {
+ case PIXEL_FORMAT_I420:
+ case PIXEL_FORMAT_YV12:
+ case PIXEL_FORMAT_NV12:
+ case PIXEL_FORMAT_NV21:
+ result_frame_size = result_frame_size * 3 / 2;
+ break;
+ case PIXEL_FORMAT_UYVY:
+ case PIXEL_FORMAT_YUY2:
+ result_frame_size *= 2;
+ break;
+ case PIXEL_FORMAT_RGB24:
+ result_frame_size *= 3;
+ break;
+ case PIXEL_FORMAT_MJPEG:
+ result_frame_size = 0;
+ break;
+ default: // Sizes for the rest of the formats are unknown.
+ NOTREACHED() << "Invalid VideoPixelFormat provided for "
+ "GetSizeForVideoPixelFormat(): " << pixel_format;
mcasas 2015/02/04 17:00:02 Function name is outdated. I'd suggest using __FUN
+ break;
+ }
+ return result_frame_size;
+}
+
std::string VideoCaptureFormat::ToString() const {
return base::StringPrintf("resolution: %s, fps: %.3f, pixel format: %s",
frame_size.ToString().c_str(),

Powered by Google App Engine
This is Rietveld 408576698