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

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

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

Powered by Google App Engine
This is Rietveld 408576698