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

Side by Side Diff: webrtc/modules/video_coding/codecs/i420/i420.cc

Issue 2278883002: Move MutableDataY{,U,V} methods to I420Buffer only. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Delete unused variable. Created 4 years, 3 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 (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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 return buffer; 130 return buffer;
131 } 131 }
132 132
133 int I420Encoder::RegisterEncodeCompleteCallback( 133 int I420Encoder::RegisterEncodeCompleteCallback(
134 EncodedImageCallback* callback) { 134 EncodedImageCallback* callback) {
135 _encodedCompleteCallback = callback; 135 _encodedCompleteCallback = callback;
136 return WEBRTC_VIDEO_CODEC_OK; 136 return WEBRTC_VIDEO_CODEC_OK;
137 } 137 }
138 138
139 I420Decoder::I420Decoder() 139 I420Decoder::I420Decoder()
140 : _decodedImage(), 140 : _width(0),
141 _width(0),
142 _height(0), 141 _height(0),
143 _inited(false), 142 _inited(false),
144 _decodeCompleteCallback(NULL) {} 143 _decodeCompleteCallback(NULL) {}
145 144
146 I420Decoder::~I420Decoder() { 145 I420Decoder::~I420Decoder() {
147 Release(); 146 Release();
148 } 147 }
149 148
150 int I420Decoder::InitDecode(const VideoCodec* codecSettings, 149 int I420Decoder::InitDecode(const VideoCodec* codecSettings,
151 int /*numberOfCores */) { 150 int /*numberOfCores */) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 _height = height; 191 _height = height;
193 192
194 // Verify that the available length is sufficient: 193 // Verify that the available length is sufficient:
195 size_t req_length = CalcBufferSize(kI420, _width, _height) + kI420HeaderSize; 194 size_t req_length = CalcBufferSize(kI420, _width, _height) + kI420HeaderSize;
196 195
197 if (req_length > inputImage._length) { 196 if (req_length > inputImage._length) {
198 return WEBRTC_VIDEO_CODEC_ERROR; 197 return WEBRTC_VIDEO_CODEC_ERROR;
199 } 198 }
200 // Set decoded image parameters. 199 // Set decoded image parameters.
201 int half_width = (_width + 1) / 2; 200 int half_width = (_width + 1) / 2;
202 _decodedImage.CreateEmptyFrame(_width, _height, _width, half_width, 201 rtc::scoped_refptr<webrtc::I420Buffer> frame_buffer =
203 half_width); 202 I420Buffer::Create(_width, _height, _width, half_width, half_width);
204 // Converting from buffer to plane representation. 203
204 // Converting from raw buffer I420Buffer.
205 int ret = ConvertToI420(kI420, buffer, 0, 0, _width, _height, 0, 205 int ret = ConvertToI420(kI420, buffer, 0, 0, _width, _height, 0,
206 kVideoRotation_0, &_decodedImage); 206 kVideoRotation_0, frame_buffer.get());
207 if (ret < 0) { 207 if (ret < 0) {
208 return WEBRTC_VIDEO_CODEC_MEMORY; 208 return WEBRTC_VIDEO_CODEC_MEMORY;
209 } 209 }
210 _decodedImage.set_timestamp(inputImage._timeStamp);
211 210
212 _decodeCompleteCallback->Decoded(_decodedImage); 211 VideoFrame decoded_image(frame_buffer, inputImage._timeStamp, 0,
212 webrtc::kVideoRotation_0);
213 _decodeCompleteCallback->Decoded(decoded_image);
213 return WEBRTC_VIDEO_CODEC_OK; 214 return WEBRTC_VIDEO_CODEC_OK;
214 } 215 }
215 216
216 const uint8_t* I420Decoder::ExtractHeader(const uint8_t* buffer, 217 const uint8_t* I420Decoder::ExtractHeader(const uint8_t* buffer,
217 uint16_t* width, 218 uint16_t* width,
218 uint16_t* height) { 219 uint16_t* height) {
219 *width = static_cast<uint16_t>(*buffer++) << 8; 220 *width = static_cast<uint16_t>(*buffer++) << 8;
220 *width |= *buffer++; 221 *width |= *buffer++;
221 *height = static_cast<uint16_t>(*buffer++) << 8; 222 *height = static_cast<uint16_t>(*buffer++) << 8;
222 *height |= *buffer++; 223 *height |= *buffer++;
223 224
224 return buffer; 225 return buffer;
225 } 226 }
226 227
227 int I420Decoder::RegisterDecodeCompleteCallback( 228 int I420Decoder::RegisterDecodeCompleteCallback(
228 DecodedImageCallback* callback) { 229 DecodedImageCallback* callback) {
229 _decodeCompleteCallback = callback; 230 _decodeCompleteCallback = callback;
230 return WEBRTC_VIDEO_CODEC_OK; 231 return WEBRTC_VIDEO_CODEC_OK;
231 } 232 }
232 233
233 int I420Decoder::Release() { 234 int I420Decoder::Release() {
234 _inited = false; 235 _inited = false;
235 return WEBRTC_VIDEO_CODEC_OK; 236 return WEBRTC_VIDEO_CODEC_OK;
236 } 237 }
237 } // namespace webrtc 238 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698