| OLD | NEW |
| 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 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 return -1; | 123 return -1; |
| 124 } | 124 } |
| 125 if (PrintPlane(frame.video_frame_buffer()->DataV(), | 125 if (PrintPlane(frame.video_frame_buffer()->DataV(), |
| 126 chroma_width, chroma_height, | 126 chroma_width, chroma_height, |
| 127 frame.video_frame_buffer()->StrideV(), file) < 0) { | 127 frame.video_frame_buffer()->StrideV(), file) < 0) { |
| 128 return -1; | 128 return -1; |
| 129 } | 129 } |
| 130 return 0; | 130 return 0; |
| 131 } | 131 } |
| 132 | 132 |
| 133 int ExtractBuffer(const VideoFrame& input_frame, size_t size, uint8_t* buffer) { | 133 int ExtractBuffer(const rtc::scoped_refptr<VideoFrameBuffer>& input_frame, |
| 134 size_t size, |
| 135 uint8_t* buffer) { |
| 134 assert(buffer); | 136 assert(buffer); |
| 135 if (input_frame.IsZeroSize()) | 137 if (!input_frame) |
| 136 return -1; | 138 return -1; |
| 137 size_t length = | 139 int width = input_frame->width(); |
| 138 CalcBufferSize(kI420, input_frame.width(), input_frame.height()); | 140 int height = input_frame->height(); |
| 141 size_t length = CalcBufferSize(kI420, width, height); |
| 139 if (size < length) { | 142 if (size < length) { |
| 140 return -1; | 143 return -1; |
| 141 } | 144 } |
| 142 | 145 |
| 143 int width = input_frame.video_frame_buffer()->width(); | |
| 144 int height = input_frame.video_frame_buffer()->height(); | |
| 145 int chroma_width = (width + 1) / 2; | 146 int chroma_width = (width + 1) / 2; |
| 146 int chroma_height = (height + 1) / 2; | 147 int chroma_height = (height + 1) / 2; |
| 147 | 148 |
| 148 libyuv::I420Copy(input_frame.video_frame_buffer()->DataY(), | 149 libyuv::I420Copy(input_frame->DataY(), |
| 149 input_frame.video_frame_buffer()->StrideY(), | 150 input_frame->StrideY(), |
| 150 input_frame.video_frame_buffer()->DataU(), | 151 input_frame->DataU(), |
| 151 input_frame.video_frame_buffer()->StrideU(), | 152 input_frame->StrideU(), |
| 152 input_frame.video_frame_buffer()->DataV(), | 153 input_frame->DataV(), |
| 153 input_frame.video_frame_buffer()->StrideV(), | 154 input_frame->StrideV(), |
| 154 buffer, width, | 155 buffer, width, |
| 155 buffer + width*height, chroma_width, | 156 buffer + width*height, chroma_width, |
| 156 buffer + width*height + chroma_width*chroma_height, | 157 buffer + width*height + chroma_width*chroma_height, |
| 157 chroma_width, | 158 chroma_width, |
| 158 width, height); | 159 width, height); |
| 159 | 160 |
| 160 return static_cast<int>(length); | 161 return static_cast<int>(length); |
| 161 } | 162 } |
| 162 | 163 |
| 164 int ExtractBuffer(const VideoFrame& input_frame, size_t size, uint8_t* buffer) { |
| 165 return ExtractBuffer(input_frame.video_frame_buffer(), size, buffer); |
| 166 } |
| 163 | 167 |
| 164 int ConvertNV12ToRGB565(const uint8_t* src_frame, | 168 int ConvertNV12ToRGB565(const uint8_t* src_frame, |
| 165 uint8_t* dst_frame, | 169 uint8_t* dst_frame, |
| 166 int width, int height) { | 170 int width, int height) { |
| 167 int abs_height = (height < 0) ? -height : height; | 171 int abs_height = (height < 0) ? -height : height; |
| 168 const uint8_t* yplane = src_frame; | 172 const uint8_t* yplane = src_frame; |
| 169 const uint8_t* uvInterlaced = src_frame + (width * abs_height); | 173 const uint8_t* uvInterlaced = src_frame + (width * abs_height); |
| 170 | 174 |
| 171 return libyuv::NV12ToRGB565(yplane, width, | 175 return libyuv::NV12ToRGB565(yplane, width, |
| 172 uvInterlaced, (width + 1) >> 1, | 176 uvInterlaced, (width + 1) >> 1, |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 ref_frame->video_frame_buffer()->StrideV(), | 335 ref_frame->video_frame_buffer()->StrideV(), |
| 332 test_frame->video_frame_buffer()->DataY(), | 336 test_frame->video_frame_buffer()->DataY(), |
| 333 test_frame->video_frame_buffer()->StrideY(), | 337 test_frame->video_frame_buffer()->StrideY(), |
| 334 test_frame->video_frame_buffer()->DataU(), | 338 test_frame->video_frame_buffer()->DataU(), |
| 335 test_frame->video_frame_buffer()->StrideU(), | 339 test_frame->video_frame_buffer()->StrideU(), |
| 336 test_frame->video_frame_buffer()->DataV(), | 340 test_frame->video_frame_buffer()->DataV(), |
| 337 test_frame->video_frame_buffer()->StrideV(), | 341 test_frame->video_frame_buffer()->StrideV(), |
| 338 test_frame->width(), test_frame->height()); | 342 test_frame->width(), test_frame->height()); |
| 339 } | 343 } |
| 340 } // namespace webrtc | 344 } // namespace webrtc |
| OLD | NEW |