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

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

Issue 906403006: [Cast] Size-Adaptable platform video encoders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed hubbe's comments. 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/cast/test/utility/default_config.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/video_utility.cc
diff --git a/media/cast/test/utility/video_utility.cc b/media/cast/test/utility/video_utility.cc
index ff050dafcb5e3208113d668d8f1bb3774687dc3c..46469563e5c48d5c8793a2130963d3afb616e5e1 100644
--- a/media/cast/test/utility/video_utility.cc
+++ b/media/cast/test/utility/video_utility.cc
@@ -63,16 +63,10 @@ void PopulateVideoFrame(VideoFrame* frame, int start_value) {
const int stripe_size =
std::max(32, std::min(frame_size.width(), frame_size.height()) / 8) & -2;
- int height = frame_size.height();
- int stride_y = frame->stride(VideoFrame::kYPlane);
- int stride_u = frame->stride(VideoFrame::kUPlane);
- int stride_v = frame->stride(VideoFrame::kVPlane);
- int half_height = (height + 1) / 2;
- uint8* y_plane = frame->data(VideoFrame::kYPlane);
- uint8* u_plane = frame->data(VideoFrame::kUPlane);
- uint8* v_plane = frame->data(VideoFrame::kVPlane);
-
// Set Y.
+ const int height = frame_size.height();
+ const int stride_y = frame->stride(VideoFrame::kYPlane);
+ uint8* y_plane = frame->data(VideoFrame::kYPlane);
for (int j = 0; j < height; ++j) {
const int stripe_j = (j / stripe_size) * stripe_size;
for (int i = 0; i < stride_y; ++i) {
@@ -82,23 +76,45 @@ void PopulateVideoFrame(VideoFrame* frame, int start_value) {
}
}
- // Set U.
- for (int j = 0; j < half_height; ++j) {
- const int stripe_j = (j / stripe_size) * stripe_size;
- for (int i = 0; i < stride_u; ++i) {
- const int stripe_i = (i / stripe_size) * stripe_size;
- *u_plane = static_cast<uint8>(start_value + stripe_i + stripe_j);
- ++u_plane;
+ const int half_height = (height + 1) / 2;
+ if (frame->format() == VideoFrame::NV12) {
+ const int stride_uv = frame->stride(VideoFrame::kUVPlane);
+ uint8* uv_plane = frame->data(VideoFrame::kUVPlane);
+
+ // Set U and V.
+ for (int j = 0; j < half_height; ++j) {
+ const int stripe_j = (j / stripe_size) * stripe_size;
+ for (int i = 0; i < stride_uv; i += 2) {
+ const int stripe_i = (i / stripe_size) * stripe_size;
+ *uv_plane = *(uv_plane + 1) =
+ static_cast<uint8>(start_value + stripe_i + stripe_j);
+ uv_plane += 2;
+ }
+ }
+ } else { // I420, YV12, etc.
+ const int stride_u = frame->stride(VideoFrame::kUPlane);
+ const int stride_v = frame->stride(VideoFrame::kVPlane);
+ uint8* u_plane = frame->data(VideoFrame::kUPlane);
+ uint8* v_plane = frame->data(VideoFrame::kVPlane);
+
+ // Set U.
+ for (int j = 0; j < half_height; ++j) {
+ const int stripe_j = (j / stripe_size) * stripe_size;
+ for (int i = 0; i < stride_u; ++i) {
+ const int stripe_i = (i / stripe_size) * stripe_size;
+ *u_plane = static_cast<uint8>(start_value + stripe_i + stripe_j);
+ ++u_plane;
+ }
}
- }
- // Set V.
- for (int j = 0; j < half_height; ++j) {
- const int stripe_j = (j / stripe_size) * stripe_size;
- for (int i = 0; i < stride_v; ++i) {
- const int stripe_i = (i / stripe_size) * stripe_size;
- *u_plane = static_cast<uint8>(start_value + stripe_i + stripe_j);
- ++v_plane;
+ // Set V.
+ for (int j = 0; j < half_height; ++j) {
+ const int stripe_j = (j / stripe_size) * stripe_size;
+ for (int i = 0; i < stride_v; ++i) {
+ const int stripe_i = (i / stripe_size) * stripe_size;
+ *u_plane = static_cast<uint8>(start_value + stripe_i + stripe_j);
+ ++v_plane;
+ }
}
}
}
« no previous file with comments | « media/cast/test/utility/default_config.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698