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

Side by Side Diff: webrtc/common_video/video_frame.cc

Issue 1492053003: Add unit test for stand-alone denoiser and fixed some bugs. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years 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 (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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
11 #include "webrtc/video_frame.h" 11 #include "webrtc/video_frame.h"
12 12
13 #include <string.h> 13 #include <string.h>
14 14
15 #include <algorithm> // swap 15 #include <algorithm> // swap
16 16
17 #include "webrtc/base/bind.h" 17 #include "webrtc/base/bind.h"
18 #include "webrtc/base/checks.h" 18 #include "webrtc/base/checks.h"
19 19
20 namespace webrtc { 20 namespace webrtc {
21 21
22 bool EqualPlane(const uint8_t* data1,
23 const uint8_t* data2,
24 int stride,
25 int width,
26 int height) {
27 for (int y = 0; y < height; ++y) {
28 if (memcmp(data1, data2, width) != 0)
29 return false;
30 data1 += stride;
31 data2 += stride;
32 }
33 return true;
34 }
35
36 int ExpectedSize(int plane_stride, int image_height, PlaneType type) {
37 if (type == kYPlane) {
38 return (plane_stride * image_height);
39 } else {
40 int half_height = (image_height + 1) / 2;
41 return (plane_stride * half_height);
42 }
43 }
44
22 VideoFrame::VideoFrame() { 45 VideoFrame::VideoFrame() {
23 // Intentionally using Reset instead of initializer list so that any missed 46 // Intentionally using Reset instead of initializer list so that any missed
24 // fields in Reset will be caught by memory checkers. 47 // fields in Reset will be caught by memory checkers.
25 Reset(); 48 Reset();
26 } 49 }
27 50
28 VideoFrame::VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer, 51 VideoFrame::VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
29 uint32_t timestamp, 52 uint32_t timestamp,
30 int64_t render_time_ms, 53 int64_t render_time_ms,
31 VideoRotation rotation) 54 VideoRotation rotation)
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 218 }
196 219
197 VideoFrame VideoFrame::ConvertNativeToI420Frame() const { 220 VideoFrame VideoFrame::ConvertNativeToI420Frame() const {
198 RTC_DCHECK(native_handle()); 221 RTC_DCHECK(native_handle());
199 VideoFrame frame; 222 VideoFrame frame;
200 frame.ShallowCopy(*this); 223 frame.ShallowCopy(*this);
201 frame.set_video_frame_buffer(video_frame_buffer_->NativeToI420Buffer()); 224 frame.set_video_frame_buffer(video_frame_buffer_->NativeToI420Buffer());
202 return frame; 225 return frame;
203 } 226 }
204 227
228 bool VideoFrame::EqualFrames(const VideoFrame& frame) const {
stefan-webrtc 2015/12/17 10:07:47 Rename to just Equals() or EqualsFrame()
jackychen 2015/12/18 07:32:01 Done.
229 if ((this->width() != frame.width()) ||
230 (this->height() != frame.height()) ||
231 (this->stride(kYPlane) != frame.stride(kYPlane)) ||
232 (this->stride(kUPlane) != frame.stride(kUPlane)) ||
233 (this->stride(kVPlane) != frame.stride(kVPlane)) ||
234 (this->timestamp() != frame.timestamp()) ||
235 (this->ntp_time_ms() != frame.ntp_time_ms()) ||
236 (this->render_time_ms() != frame.render_time_ms())) {
237 return false;
238 }
239 const int half_width = (this->width() + 1) / 2;
240 const int half_height = (this->height() + 1) / 2;
241 return EqualPlane(this->buffer(kYPlane), frame.buffer(kYPlane),
242 this->stride(kYPlane), this->width(), this->height()) &&
243 EqualPlane(this->buffer(kUPlane), frame.buffer(kUPlane),
244 this->stride(kUPlane), half_width, half_height) &&
245 EqualPlane(this->buffer(kVPlane), frame.buffer(kVPlane),
246 this->stride(kVPlane), half_width, half_height);
247 }
248
205 } // namespace webrtc 249 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698