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

Unified Diff: media/cast/test/utility/barcode.cc

Issue 257703002: Cast: Print out AV sync in cast receiver if playing test video (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: vlog(0) -> vlog(2) Created 6 years, 8 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/cast/test/receiver.cc ('K') | « media/cast/test/receiver.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/test/utility/barcode.cc
diff --git a/media/cast/test/utility/barcode.cc b/media/cast/test/utility/barcode.cc
index cf279375b1e444d36791a441d0bbf99cc25fec15..2e5978411223ebb8a30be0e1a9876816bfc0577e 100644
--- a/media/cast/test/utility/barcode.cc
+++ b/media/cast/test/utility/barcode.cc
@@ -79,19 +79,11 @@ bool EncodeBarcode(const std::vector<bool>& bits,
return true;
}
-// Note that "output" is assumed to be the right size already. This
-// could be inferred from the data, but the decoding is more robust
-// if we can assume that we know how many bits we want.
-bool DecodeBarcode(const scoped_refptr<VideoFrame>& frame,
- std::vector<bool>* output) {
- DCHECK(frame->format() == VideoFrame::YV12 ||
- frame->format() == VideoFrame::YV16 ||
- frame->format() == VideoFrame::I420 ||
- frame->format() == VideoFrame::YV12J);
- int min_row = std::max(0, frame->rows(VideoFrame::kYPlane) / 2 - 10);
- int max_row = std::min(frame->rows(VideoFrame::kYPlane),
- frame->rows(VideoFrame::kYPlane) / 2 + 10);
-
+namespace {
+bool DecodeBarCodeRows(const scoped_refptr<VideoFrame>& frame,
+ std::vector<bool>* output,
+ int min_row,
+ int max_row) {
// Do a basic run-length encoding
std::deque<int> runs;
bool is_black = true;
@@ -151,6 +143,34 @@ bool DecodeBarcode(const scoped_refptr<VideoFrame>& frame,
return false;
}
+} // namespace
+
+// Note that "output" is assumed to be the right size already. This
+// could be inferred from the data, but the decoding is more robust
+// if we can assume that we know how many bits we want.
+bool DecodeBarcode(const scoped_refptr<VideoFrame>& frame,
+ std::vector<bool>* output) {
+ DCHECK(frame->format() == VideoFrame::YV12 ||
+ frame->format() == VideoFrame::YV16 ||
+ frame->format() == VideoFrame::I420 ||
+ frame->format() == VideoFrame::YV12J);
+ int rows = frame->rows(VideoFrame::kYPlane);
+ // Middle 10 lines
+ if (DecodeBarCodeRows(frame,
+ output,
+ std::max(0, rows / 2 - 5),
+ std::min(rows, rows / 2 + 5))) {
+ return true;
+ }
+
+ // Top 5 lines
+ if (DecodeBarCodeRows(frame, output, 0, std::min(5, rows))) {
+ return true;
+ }
+
+ return false;
+}
+
} // namespace test
} // namespace cast
} // namespace media
« media/cast/test/receiver.cc ('K') | « media/cast/test/receiver.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698