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

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

Issue 558623002: Video capture: Refactor GetBestMatchedFormat from Win to OS independent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 3 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 ce5c354e290eed22fef06f69a067b4cf2d01265c..56671df9f2972a99d39ebcea0a5917566032b7ba 100644
--- a/media/video/capture/video_capture_types.cc
+++ b/media/video/capture/video_capture_types.cc
@@ -4,6 +4,8 @@
#include "media/video/capture/video_capture_types.h"
+#include <cmath>
+
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "media/base/limits.h"
@@ -69,4 +71,17 @@ std::string VideoCaptureFormat::PixelFormatToString(VideoPixelFormat format) {
VideoCaptureParams::VideoCaptureParams()
: resolution_change_policy(RESOLUTION_POLICY_FIXED) {}
+
+int DiffVideoCaptureFormat(const VideoCaptureFormat& lhs,
+ const VideoCaptureFormat& rhs) {
+ // Distinguish between rational frames rates by multiplying with
+ // kFrameRatePrecision. Multiply frame size as well to make it have
+ // precedence over frame rate.
mcasas 2014/09/23 12:34:57 This comment doesn't read clearly to me, can you p
+ return kFrameRatePrecision *
+ (std::abs(lhs.frame_size.width() - rhs.frame_size.width()) +
+ std::abs(lhs.frame_size.height() - rhs.frame_size.height())) +
+ static_cast<int>(kFrameRatePrecision *
+ std::fabs(lhs.frame_rate - rhs.frame_rate));
mcasas 2014/09/23 12:34:57 what about: return kFrameRatePrecision * (st
magjed_chromium 2014/09/23 14:39:54 The reason for not factoring kFrameRatePrecision i
+}
+
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698