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

Side by Side Diff: media/cast/test/utility/video_utility.cc

Issue 899583002: Revert of [Cast] Software encoder support for varying video frame sizes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « media/cast/test/utility/video_utility.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 const gfx::Size frame_size = frame->coded_size(); 62 int height = frame->coded_size().height();
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();
67 int stride_y = frame->stride(VideoFrame::kYPlane); 63 int stride_y = frame->stride(VideoFrame::kYPlane);
68 int stride_u = frame->stride(VideoFrame::kUPlane); 64 int stride_u = frame->stride(VideoFrame::kUPlane);
69 int stride_v = frame->stride(VideoFrame::kVPlane); 65 int stride_v = frame->stride(VideoFrame::kVPlane);
70 int half_height = (height + 1) / 2; 66 int half_height = (height + 1) / 2;
71 uint8* y_plane = frame->data(VideoFrame::kYPlane); 67 uint8* y_plane = frame->data(VideoFrame::kYPlane);
72 uint8* u_plane = frame->data(VideoFrame::kUPlane); 68 uint8* u_plane = frame->data(VideoFrame::kUPlane);
73 uint8* v_plane = frame->data(VideoFrame::kVPlane); 69 uint8* v_plane = frame->data(VideoFrame::kVPlane);
74 70
75 // Set Y. 71 // Set Y.
76 for (int j = 0; j < height; ++j) { 72 for (int j = 0; j < height; ++j) {
77 const int stripe_j = (j / stripe_size) * stripe_size;
78 for (int i = 0; i < stride_y; ++i) { 73 for (int i = 0; i < stride_y; ++i) {
79 const int stripe_i = (i / stripe_size) * stripe_size; 74 *y_plane = static_cast<uint8>(start_value + i + j);
80 *y_plane = static_cast<uint8>(start_value + stripe_i + stripe_j);
81 ++y_plane; 75 ++y_plane;
82 } 76 }
83 } 77 }
84 78
85 // Set U. 79 // Set U.
86 for (int j = 0; j < half_height; ++j) { 80 for (int j = 0; j < half_height; ++j) {
87 const int stripe_j = (j / stripe_size) * stripe_size;
88 for (int i = 0; i < stride_u; ++i) { 81 for (int i = 0; i < stride_u; ++i) {
89 const int stripe_i = (i / stripe_size) * stripe_size; 82 *u_plane = static_cast<uint8>(start_value + i + j);
90 *u_plane = static_cast<uint8>(start_value + stripe_i + stripe_j);
91 ++u_plane; 83 ++u_plane;
92 } 84 }
93 } 85 }
94 86
95 // Set V. 87 // Set V.
96 for (int j = 0; j < half_height; ++j) { 88 for (int j = 0; j < half_height; ++j) {
97 const int stripe_j = (j / stripe_size) * stripe_size;
98 for (int i = 0; i < stride_v; ++i) { 89 for (int i = 0; i < stride_v; ++i) {
99 const int stripe_i = (i / stripe_size) * stripe_size; 90 *v_plane = static_cast<uint8>(start_value + i + j);
100 *u_plane = static_cast<uint8>(start_value + stripe_i + stripe_j);
101 ++v_plane; 91 ++v_plane;
102 } 92 }
103 } 93 }
104 } 94 }
105 95
106 void PopulateVideoFrameWithNoise(VideoFrame* frame) { 96 void PopulateVideoFrameWithNoise(VideoFrame* frame) {
107 int height = frame->coded_size().height(); 97 int height = frame->coded_size().height();
108 int stride_y = frame->stride(VideoFrame::kYPlane); 98 int stride_y = frame->stride(VideoFrame::kYPlane);
109 int stride_u = frame->stride(VideoFrame::kUPlane); 99 int stride_u = frame->stride(VideoFrame::kUPlane);
110 int stride_v = frame->stride(VideoFrame::kVPlane); 100 int stride_v = frame->stride(VideoFrame::kVPlane);
(...skipping 26 matching lines...) Expand all
137 memcpy(u_plane, raw_data + width * height, half_width * half_height); 127 memcpy(u_plane, raw_data + width * height, half_width * half_height);
138 memcpy(v_plane, 128 memcpy(v_plane,
139 raw_data + width * height + half_width * half_height, 129 raw_data + width * height + half_width * half_height,
140 half_width * half_height); 130 half_width * half_height);
141 delete[] raw_data; 131 delete[] raw_data;
142 return true; 132 return true;
143 } 133 }
144 134
145 } // namespace cast 135 } // namespace cast
146 } // namespace media 136 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/test/utility/video_utility.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698