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

Side by Side Diff: webrtc/api/java/jni/native_handle_impl.cc

Issue 1973873003: Delete AndroidVideoCapturer::FrameFactory. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Delete left-over prototype. Revert a comment change. Created 4 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 sum += a[k * 4 + j] * b[i * 4 + k]; 68 sum += a[k * 4 + j] * b[i * 4 + k];
69 } 69 }
70 result[i * 4 + j] = sum; 70 result[i * 4 + j] = sum;
71 } 71 }
72 } 72 }
73 } 73 }
74 74
75 // Center crop by keeping xFraction of the width and yFraction of the height, 75 // Center crop by keeping xFraction of the width and yFraction of the height,
76 // so e.g. cropping from 640x480 to 640x360 would use 76 // so e.g. cropping from 640x480 to 640x360 would use
77 // xFraction=1, yFraction=360/480. 77 // xFraction=1, yFraction=360/480.
78 void CropMatrix(float a[16], float xFraction, float yFraction) { 78 void CropMatrix(float a[16], float xFraction, float yFraction,
79 // Move cropped area to the center of the frame by offsetting half the 79 float xOffset, float yOffset) {
80 // removed area.
81 const float xOffset = (1 - xFraction) / 2;
82 const float yOffset = (1 - yFraction) / 2;
83 const float crop_matrix[16] = { 80 const float crop_matrix[16] = {
84 xFraction, 0, 0, 0, 81 xFraction, 0, 0, 0,
85 0, yFraction, 0, 0, 82 0, yFraction, 0, 0,
86 0, 0, 1, 0, 83 0, 0, 1, 0,
87 xOffset, yOffset, 0, 1}; 84 xOffset, yOffset, 0, 1};
88 float mul_result[16]; 85 float mul_result[16];
89 MultiplyMatrix(crop_matrix, a, mul_result); 86 MultiplyMatrix(crop_matrix, a, mul_result);
90 memcpy(a, mul_result, sizeof(mul_result)); 87 memcpy(a, mul_result, sizeof(mul_result));
91 } 88 }
92 89
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 byte_buffer, width(), height(), stride, 169 byte_buffer, width(), height(), stride,
173 native_handle_.oes_texture_id, sampling_matrix); 170 native_handle_.oes_texture_id, sampling_matrix);
174 CHECK_EXCEPTION(jni) << "textureToYUV throwed an exception"; 171 CHECK_EXCEPTION(jni) << "textureToYUV throwed an exception";
175 172
176 return copy; 173 return copy;
177 } 174 }
178 175
179 rtc::scoped_refptr<AndroidTextureBuffer> 176 rtc::scoped_refptr<AndroidTextureBuffer>
180 AndroidTextureBuffer::CropScaleAndRotate(int cropped_width, 177 AndroidTextureBuffer::CropScaleAndRotate(int cropped_width,
181 int cropped_height, 178 int cropped_height,
179 int crop_x,
180 int crop_y,
182 int dst_width, 181 int dst_width,
183 int dst_height, 182 int dst_height,
184 webrtc::VideoRotation rotation) { 183 webrtc::VideoRotation rotation) {
185 if (cropped_width == dst_width && cropped_height == dst_height && 184 if (cropped_width == dst_width && cropped_height == dst_height &&
186 width() == dst_width && height() == dst_height && 185 width() == dst_width && height() == dst_height &&
187 rotation == webrtc::kVideoRotation_0) { 186 rotation == webrtc::kVideoRotation_0) {
188 return this; 187 return this;
189 } 188 }
190 int rotated_width = (rotation % 180 == 0) ? dst_width : dst_height; 189 int rotated_width = (rotation % 180 == 0) ? dst_width : dst_height;
191 int rotated_height = (rotation % 180 == 0) ? dst_height : dst_width; 190 int rotated_height = (rotation % 180 == 0) ? dst_height : dst_width;
192 191
193 // Here we use Bind magic to add a reference count to |this| until the newly 192 // Here we use Bind magic to add a reference count to |this| until the newly
194 // created AndroidTextureBuffer is destructed 193 // created AndroidTextureBuffer is destructed
195 rtc::scoped_refptr<AndroidTextureBuffer> buffer( 194 rtc::scoped_refptr<AndroidTextureBuffer> buffer(
196 new rtc::RefCountedObject<AndroidTextureBuffer>( 195 new rtc::RefCountedObject<AndroidTextureBuffer>(
197 rotated_width, rotated_height, native_handle_, 196 rotated_width, rotated_height, native_handle_,
198 surface_texture_helper_, rtc::KeepRefUntilDone(this))); 197 surface_texture_helper_, rtc::KeepRefUntilDone(this)));
199 198
200 if (cropped_width != width() || cropped_height != height()) { 199 if (cropped_width != width() || cropped_height != height()) {
201 CropMatrix(buffer->native_handle_.sampling_matrix, 200 CropMatrix(buffer->native_handle_.sampling_matrix,
202 cropped_width / static_cast<float>(width()), 201 cropped_width / static_cast<float>(width()),
203 cropped_height / static_cast<float>(height())); 202 cropped_height / static_cast<float>(height()),
203 crop_x / static_cast<float>(width()),
204 crop_y / static_cast<float>(height()));
204 } 205 }
205 RotateMatrix(buffer->native_handle_.sampling_matrix, rotation); 206 RotateMatrix(buffer->native_handle_.sampling_matrix, rotation);
206 return buffer; 207 return buffer;
207 } 208 }
208 209
209 } // namespace webrtc_jni 210 } // namespace webrtc_jni
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698