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

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

Issue 2685783014: Replace NULL with nullptr in all C++ files. (Closed)
Patch Set: Fixing android. Created 3 years, 10 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
11 #include "webrtc/modules/video_coding/codecs/i420/include/i420.h" 11 #include "webrtc/modules/video_coding/codecs/i420/include/i420.h"
12 12
13 #include <limits> 13 #include <limits>
14 #include <string> 14 #include <string>
15 15
16 #include "webrtc/api/video/i420_buffer.h" 16 #include "webrtc/api/video/i420_buffer.h"
17 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 17 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
18 18
19 namespace { 19 namespace {
20 const size_t kI420HeaderSize = 4; 20 const size_t kI420HeaderSize = 4;
21 } 21 }
22 22
23 namespace webrtc { 23 namespace webrtc {
24 24
25 I420Encoder::I420Encoder() 25 I420Encoder::I420Encoder()
26 : _inited(false), _encodedImage(), _encodedCompleteCallback(NULL) {} 26 : _inited(false), _encodedImage(), _encodedCompleteCallback(nullptr) {}
27 27
28 I420Encoder::~I420Encoder() { 28 I420Encoder::~I420Encoder() {
29 _inited = false; 29 _inited = false;
30 delete[] _encodedImage._buffer; 30 delete[] _encodedImage._buffer;
31 } 31 }
32 32
33 int I420Encoder::Release() { 33 int I420Encoder::Release() {
34 // Should allocate an encoded frame and then release it here, for that we 34 // Should allocate an encoded frame and then release it here, for that we
35 // actually need an init flag. 35 // actually need an init flag.
36 if (_encodedImage._buffer != NULL) { 36 if (_encodedImage._buffer != nullptr) {
37 delete[] _encodedImage._buffer; 37 delete[] _encodedImage._buffer;
38 _encodedImage._buffer = NULL; 38 _encodedImage._buffer = nullptr;
39 } 39 }
40 _inited = false; 40 _inited = false;
41 return WEBRTC_VIDEO_CODEC_OK; 41 return WEBRTC_VIDEO_CODEC_OK;
42 } 42 }
43 43
44 int I420Encoder::InitEncode(const VideoCodec* codecSettings, 44 int I420Encoder::InitEncode(const VideoCodec* codecSettings,
45 int /*numberOfCores*/, 45 int /*numberOfCores*/,
46 size_t /*maxPayloadSize */) { 46 size_t /*maxPayloadSize */) {
47 if (codecSettings == NULL) { 47 if (codecSettings == nullptr) {
48 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 48 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
49 } 49 }
50 if (codecSettings->width < 1 || codecSettings->height < 1) { 50 if (codecSettings->width < 1 || codecSettings->height < 1) {
51 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 51 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
52 } 52 }
53 53
54 // Allocating encoded memory. 54 // Allocating encoded memory.
55 if (_encodedImage._buffer != NULL) { 55 if (_encodedImage._buffer != nullptr) {
56 delete[] _encodedImage._buffer; 56 delete[] _encodedImage._buffer;
57 _encodedImage._buffer = NULL; 57 _encodedImage._buffer = nullptr;
58 _encodedImage._size = 0; 58 _encodedImage._size = 0;
59 } 59 }
60 const size_t newSize = 60 const size_t newSize =
61 CalcBufferSize(kI420, codecSettings->width, codecSettings->height) + 61 CalcBufferSize(kI420, codecSettings->width, codecSettings->height) +
62 kI420HeaderSize; 62 kI420HeaderSize;
63 uint8_t* newBuffer = new uint8_t[newSize]; 63 uint8_t* newBuffer = new uint8_t[newSize];
64 if (newBuffer == NULL) { 64 if (newBuffer == nullptr) {
65 return WEBRTC_VIDEO_CODEC_MEMORY; 65 return WEBRTC_VIDEO_CODEC_MEMORY;
66 } 66 }
67 _encodedImage._size = newSize; 67 _encodedImage._size = newSize;
68 _encodedImage._buffer = newBuffer; 68 _encodedImage._buffer = newBuffer;
69 69
70 // If no memory allocation, no point to init. 70 // If no memory allocation, no point to init.
71 _inited = true; 71 _inited = true;
72 return WEBRTC_VIDEO_CODEC_OK; 72 return WEBRTC_VIDEO_CODEC_OK;
73 } 73 }
74 74
75 int I420Encoder::Encode(const VideoFrame& inputImage, 75 int I420Encoder::Encode(const VideoFrame& inputImage,
76 const CodecSpecificInfo* /*codecSpecificInfo*/, 76 const CodecSpecificInfo* /*codecSpecificInfo*/,
77 const std::vector<FrameType>* /*frame_types*/) { 77 const std::vector<FrameType>* /*frame_types*/) {
78 if (!_inited) { 78 if (!_inited) {
79 return WEBRTC_VIDEO_CODEC_UNINITIALIZED; 79 return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
80 } 80 }
81 if (_encodedCompleteCallback == NULL) { 81 if (_encodedCompleteCallback == nullptr) {
82 return WEBRTC_VIDEO_CODEC_UNINITIALIZED; 82 return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
83 } 83 }
84 84
85 _encodedImage._frameType = kVideoFrameKey; 85 _encodedImage._frameType = kVideoFrameKey;
86 _encodedImage._timeStamp = inputImage.timestamp(); 86 _encodedImage._timeStamp = inputImage.timestamp();
87 _encodedImage._encodedHeight = inputImage.height(); 87 _encodedImage._encodedHeight = inputImage.height();
88 _encodedImage._encodedWidth = inputImage.width(); 88 _encodedImage._encodedWidth = inputImage.width();
89 89
90 int width = inputImage.width(); 90 int width = inputImage.width();
91 if (width > std::numeric_limits<uint16_t>::max()) { 91 if (width > std::numeric_limits<uint16_t>::max()) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 return buffer; 132 return buffer;
133 } 133 }
134 134
135 int I420Encoder::RegisterEncodeCompleteCallback( 135 int I420Encoder::RegisterEncodeCompleteCallback(
136 EncodedImageCallback* callback) { 136 EncodedImageCallback* callback) {
137 _encodedCompleteCallback = callback; 137 _encodedCompleteCallback = callback;
138 return WEBRTC_VIDEO_CODEC_OK; 138 return WEBRTC_VIDEO_CODEC_OK;
139 } 139 }
140 140
141 I420Decoder::I420Decoder() 141 I420Decoder::I420Decoder()
142 : _width(0), 142 : _width(0), _height(0), _inited(false), _decodeCompleteCallback(nullptr) {}
143 _height(0),
144 _inited(false),
145 _decodeCompleteCallback(NULL) {}
146 143
147 I420Decoder::~I420Decoder() { 144 I420Decoder::~I420Decoder() {
148 Release(); 145 Release();
149 } 146 }
150 147
151 int I420Decoder::InitDecode(const VideoCodec* codecSettings, 148 int I420Decoder::InitDecode(const VideoCodec* codecSettings,
152 int /*numberOfCores */) { 149 int /*numberOfCores */) {
153 if (codecSettings == NULL) { 150 if (codecSettings == nullptr) {
154 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 151 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
155 } else if (codecSettings->width < 1 || codecSettings->height < 1) { 152 } else if (codecSettings->width < 1 || codecSettings->height < 1) {
156 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 153 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
157 } 154 }
158 _width = codecSettings->width; 155 _width = codecSettings->width;
159 _height = codecSettings->height; 156 _height = codecSettings->height;
160 _inited = true; 157 _inited = true;
161 return WEBRTC_VIDEO_CODEC_OK; 158 return WEBRTC_VIDEO_CODEC_OK;
162 } 159 }
163 160
164 int I420Decoder::Decode(const EncodedImage& inputImage, 161 int I420Decoder::Decode(const EncodedImage& inputImage,
165 bool /*missingFrames*/, 162 bool /*missingFrames*/,
166 const RTPFragmentationHeader* /*fragmentation*/, 163 const RTPFragmentationHeader* /*fragmentation*/,
167 const CodecSpecificInfo* /*codecSpecificInfo*/, 164 const CodecSpecificInfo* /*codecSpecificInfo*/,
168 int64_t /*renderTimeMs*/) { 165 int64_t /*renderTimeMs*/) {
169 if (inputImage._buffer == NULL) { 166 if (inputImage._buffer == nullptr) {
170 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 167 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
171 } 168 }
172 if (_decodeCompleteCallback == NULL) { 169 if (_decodeCompleteCallback == nullptr) {
173 return WEBRTC_VIDEO_CODEC_UNINITIALIZED; 170 return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
174 } 171 }
175 if (inputImage._length <= 0) { 172 if (inputImage._length <= 0) {
176 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 173 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
177 } 174 }
178 if (inputImage._completeFrame == false) { 175 if (inputImage._completeFrame == false) {
179 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 176 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
180 } 177 }
181 if (!_inited) { 178 if (!_inited) {
182 return WEBRTC_VIDEO_CODEC_UNINITIALIZED; 179 return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 DecodedImageCallback* callback) { 228 DecodedImageCallback* callback) {
232 _decodeCompleteCallback = callback; 229 _decodeCompleteCallback = callback;
233 return WEBRTC_VIDEO_CODEC_OK; 230 return WEBRTC_VIDEO_CODEC_OK;
234 } 231 }
235 232
236 int I420Decoder::Release() { 233 int I420Decoder::Release() {
237 _inited = false; 234 _inited = false;
238 return WEBRTC_VIDEO_CODEC_OK; 235 return WEBRTC_VIDEO_CODEC_OK;
239 } 236 }
240 } // namespace webrtc 237 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698