| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/cast/test/utility/video_utility.h" | 5 #include "media/cast/test/utility/video_utility.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <cstdio> | 8 #include <cstdio> |
| 9 | 9 |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 frame2->stride(VideoFrame::kYPlane), | 52 frame2->stride(VideoFrame::kYPlane), |
| 53 frame2->data(VideoFrame::kUPlane), | 53 frame2->data(VideoFrame::kUPlane), |
| 54 frame2->stride(VideoFrame::kUPlane), | 54 frame2->stride(VideoFrame::kUPlane), |
| 55 frame2->data(VideoFrame::kVPlane), | 55 frame2->data(VideoFrame::kVPlane), |
| 56 frame2->stride(VideoFrame::kVPlane), | 56 frame2->stride(VideoFrame::kVPlane), |
| 57 frame1->coded_size().width(), | 57 frame1->coded_size().width(), |
| 58 frame1->coded_size().height()); | 58 frame1->coded_size().height()); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void PopulateVideoFrame(VideoFrame* frame, int start_value) { | 61 void PopulateVideoFrame(VideoFrame* frame, int start_value) { |
| 62 int height = frame->coded_size().height(); | 62 const gfx::Size frame_size = frame->coded_size(); |
| 63 const int stripe_size = |
| 64 std::max(32, std::min(frame_size.width(), frame_size.height()) / 8) & -2; |
| 65 |
| 66 int height = frame_size.height(); |
| 63 int stride_y = frame->stride(VideoFrame::kYPlane); | 67 int stride_y = frame->stride(VideoFrame::kYPlane); |
| 64 int stride_u = frame->stride(VideoFrame::kUPlane); | 68 int stride_u = frame->stride(VideoFrame::kUPlane); |
| 65 int stride_v = frame->stride(VideoFrame::kVPlane); | 69 int stride_v = frame->stride(VideoFrame::kVPlane); |
| 66 int half_height = (height + 1) / 2; | 70 int half_height = (height + 1) / 2; |
| 67 uint8* y_plane = frame->data(VideoFrame::kYPlane); | 71 uint8* y_plane = frame->data(VideoFrame::kYPlane); |
| 68 uint8* u_plane = frame->data(VideoFrame::kUPlane); | 72 uint8* u_plane = frame->data(VideoFrame::kUPlane); |
| 69 uint8* v_plane = frame->data(VideoFrame::kVPlane); | 73 uint8* v_plane = frame->data(VideoFrame::kVPlane); |
| 70 | 74 |
| 71 // Set Y. | 75 // Set Y. |
| 72 for (int j = 0; j < height; ++j) { | 76 for (int j = 0; j < height; ++j) { |
| 77 const int stripe_j = (j / stripe_size) * stripe_size; |
| 73 for (int i = 0; i < stride_y; ++i) { | 78 for (int i = 0; i < stride_y; ++i) { |
| 74 *y_plane = static_cast<uint8>(start_value + i + j); | 79 const int stripe_i = (i / stripe_size) * stripe_size; |
| 80 *y_plane = static_cast<uint8>(start_value + stripe_i + stripe_j); |
| 75 ++y_plane; | 81 ++y_plane; |
| 76 } | 82 } |
| 77 } | 83 } |
| 78 | 84 |
| 79 // Set U. | 85 // Set U. |
| 80 for (int j = 0; j < half_height; ++j) { | 86 for (int j = 0; j < half_height; ++j) { |
| 87 const int stripe_j = (j / stripe_size) * stripe_size; |
| 81 for (int i = 0; i < stride_u; ++i) { | 88 for (int i = 0; i < stride_u; ++i) { |
| 82 *u_plane = static_cast<uint8>(start_value + i + j); | 89 const int stripe_i = (i / stripe_size) * stripe_size; |
| 90 *u_plane = static_cast<uint8>(start_value + stripe_i + stripe_j); |
| 83 ++u_plane; | 91 ++u_plane; |
| 84 } | 92 } |
| 85 } | 93 } |
| 86 | 94 |
| 87 // Set V. | 95 // Set V. |
| 88 for (int j = 0; j < half_height; ++j) { | 96 for (int j = 0; j < half_height; ++j) { |
| 97 const int stripe_j = (j / stripe_size) * stripe_size; |
| 89 for (int i = 0; i < stride_v; ++i) { | 98 for (int i = 0; i < stride_v; ++i) { |
| 90 *v_plane = static_cast<uint8>(start_value + i + j); | 99 const int stripe_i = (i / stripe_size) * stripe_size; |
| 100 *u_plane = static_cast<uint8>(start_value + stripe_i + stripe_j); |
| 91 ++v_plane; | 101 ++v_plane; |
| 92 } | 102 } |
| 93 } | 103 } |
| 94 } | 104 } |
| 95 | 105 |
| 96 void PopulateVideoFrameWithNoise(VideoFrame* frame) { | 106 void PopulateVideoFrameWithNoise(VideoFrame* frame) { |
| 97 int height = frame->coded_size().height(); | 107 int height = frame->coded_size().height(); |
| 98 int stride_y = frame->stride(VideoFrame::kYPlane); | 108 int stride_y = frame->stride(VideoFrame::kYPlane); |
| 99 int stride_u = frame->stride(VideoFrame::kUPlane); | 109 int stride_u = frame->stride(VideoFrame::kUPlane); |
| 100 int stride_v = frame->stride(VideoFrame::kVPlane); | 110 int stride_v = frame->stride(VideoFrame::kVPlane); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 127 memcpy(u_plane, raw_data + width * height, half_width * half_height); | 137 memcpy(u_plane, raw_data + width * height, half_width * half_height); |
| 128 memcpy(v_plane, | 138 memcpy(v_plane, |
| 129 raw_data + width * height + half_width * half_height, | 139 raw_data + width * height + half_width * half_height, |
| 130 half_width * half_height); | 140 half_width * half_height); |
| 131 delete[] raw_data; | 141 delete[] raw_data; |
| 132 return true; | 142 return true; |
| 133 } | 143 } |
| 134 | 144 |
| 135 } // namespace cast | 145 } // namespace cast |
| 136 } // namespace media | 146 } // namespace media |
| OLD | NEW |