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

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: Added checks for unsupported pixel formats. Created 5 years, 10 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
« no previous file with comments | « media/video/capture/video_capture_types.h ('k') | media/video/capture/win/sink_input_pin_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a20ea4faf729504910e9a0d2d7e4add28435813e 100644
--- a/media/video/capture/video_capture_types.cc
+++ b/media/video/capture/video_capture_types.cc
@@ -31,6 +31,36 @@ 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_ARGB:
+ result_frame_size *= 4;
+ break;
+ case PIXEL_FORMAT_MJPEG:
+ case PIXEL_FORMAT_TEXTURE:
+ result_frame_size = 0;
+ break;
+ default: // Sizes for the rest of the formats are unknown.
+ NOTREACHED() << "Unknown pixel format provided.";
+ 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(),
« no previous file with comments | « media/video/capture/video_capture_types.h ('k') | media/video/capture/win/sink_input_pin_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698