| 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;
|
| + }
|
| }
|
| }
|
| }
|
|
|