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

Side by Side Diff: webrtc/modules/video_coding/generic_decoder.cc

Issue 1490703002: Revert of Add _decoder CHECK to VCMGenericDecoder constructor. (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
« no previous file with comments | « webrtc/modules/video_coding/generic_decoder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/base/checks.h"
12 #include "webrtc/base/logging.h" 11 #include "webrtc/base/logging.h"
13 #include "webrtc/base/trace_event.h" 12 #include "webrtc/base/trace_event.h"
13 #include "webrtc/modules/video_coding/include/video_coding.h"
14 #include "webrtc/modules/video_coding/generic_decoder.h" 14 #include "webrtc/modules/video_coding/generic_decoder.h"
15 #include "webrtc/modules/video_coding/include/video_coding.h"
16 #include "webrtc/modules/video_coding/internal_defines.h" 15 #include "webrtc/modules/video_coding/internal_defines.h"
17 #include "webrtc/system_wrappers/include/clock.h" 16 #include "webrtc/system_wrappers/include/clock.h"
18 17
19 namespace webrtc { 18 namespace webrtc {
20 19
21 VCMDecodedFrameCallback::VCMDecodedFrameCallback(VCMTiming& timing, 20 VCMDecodedFrameCallback::VCMDecodedFrameCallback(VCMTiming& timing,
22 Clock* clock) 21 Clock* clock)
23 : 22 :
24 _critSect(CriticalSectionWrapper::CreateCriticalSection()), 23 _critSect(CriticalSectionWrapper::CreateCriticalSection()),
25 _clock(clock), 24 _clock(clock),
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 int32_t VCMDecodedFrameCallback::Pop(uint32_t timestamp) 124 int32_t VCMDecodedFrameCallback::Pop(uint32_t timestamp)
126 { 125 {
127 CriticalSectionScoped cs(_critSect); 126 CriticalSectionScoped cs(_critSect);
128 if (_timestampMap.Pop(timestamp) == NULL) 127 if (_timestampMap.Pop(timestamp) == NULL)
129 { 128 {
130 return VCM_GENERAL_ERROR; 129 return VCM_GENERAL_ERROR;
131 } 130 }
132 return VCM_OK; 131 return VCM_OK;
133 } 132 }
134 133
135 VCMGenericDecoder::VCMGenericDecoder(VideoDecoder* decoder, bool isExternal) 134 VCMGenericDecoder::VCMGenericDecoder(VideoDecoder& decoder, bool isExternal)
136 : _callback(NULL), 135 :
137 _frameInfos(), 136 _callback(NULL),
138 _nextFrameInfoIdx(0), 137 _frameInfos(),
139 _decoder(decoder), 138 _nextFrameInfoIdx(0),
140 _codecType(kVideoCodecUnknown), 139 _decoder(decoder),
141 _isExternal(isExternal), 140 _codecType(kVideoCodecUnknown),
142 _keyFrameDecoded(false) { 141 _isExternal(isExternal),
143 RTC_CHECK(_decoder); 142 _keyFrameDecoded(false)
143 {
144 } 144 }
145 145
146 VCMGenericDecoder::~VCMGenericDecoder() 146 VCMGenericDecoder::~VCMGenericDecoder()
147 { 147 {
148 } 148 }
149 149
150 int32_t VCMGenericDecoder::InitDecode(const VideoCodec* settings, 150 int32_t VCMGenericDecoder::InitDecode(const VideoCodec* settings,
151 int32_t numberOfCores) 151 int32_t numberOfCores)
152 { 152 {
153 TRACE_EVENT0("webrtc", "VCMGenericDecoder::InitDecode"); 153 TRACE_EVENT0("webrtc", "VCMGenericDecoder::InitDecode");
154 _codecType = settings->codecType; 154 _codecType = settings->codecType;
155 155
156 return _decoder->InitDecode(settings, numberOfCores); 156 return _decoder.InitDecode(settings, numberOfCores);
157 } 157 }
158 158
159 int32_t VCMGenericDecoder::Decode(const VCMEncodedFrame& frame, int64_t nowMs) { 159 int32_t VCMGenericDecoder::Decode(const VCMEncodedFrame& frame, int64_t nowMs) {
160 TRACE_EVENT1("webrtc", "VCMGenericDecoder::Decode", "timestamp", 160 TRACE_EVENT1("webrtc", "VCMGenericDecoder::Decode", "timestamp",
161 frame.EncodedImage()._timeStamp); 161 frame.EncodedImage()._timeStamp);
162 _frameInfos[_nextFrameInfoIdx].decodeStartTimeMs = nowMs; 162 _frameInfos[_nextFrameInfoIdx].decodeStartTimeMs = nowMs;
163 _frameInfos[_nextFrameInfoIdx].renderTimeMs = frame.RenderTimeMs(); 163 _frameInfos[_nextFrameInfoIdx].renderTimeMs = frame.RenderTimeMs();
164 _frameInfos[_nextFrameInfoIdx].rotation = frame.rotation(); 164 _frameInfos[_nextFrameInfoIdx].rotation = frame.rotation();
165 _callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]); 165 _callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]);
166 166
167 _nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength; 167 _nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength;
168 int32_t ret = _decoder->Decode(frame.EncodedImage(), 168 int32_t ret = _decoder.Decode(frame.EncodedImage(),
169 frame.MissingFrame(), 169 frame.MissingFrame(),
170 frame.FragmentationHeader(), 170 frame.FragmentationHeader(),
171 frame.CodecSpecific(), 171 frame.CodecSpecific(),
172 frame.RenderTimeMs()); 172 frame.RenderTimeMs());
173 173
174 if (ret < WEBRTC_VIDEO_CODEC_OK) 174 if (ret < WEBRTC_VIDEO_CODEC_OK)
175 { 175 {
176 LOG(LS_WARNING) << "Failed to decode frame with timestamp " 176 LOG(LS_WARNING) << "Failed to decode frame with timestamp "
177 << frame.TimeStamp() << ", error code: " << ret; 177 << frame.TimeStamp() << ", error code: " << ret;
178 _callback->Pop(frame.TimeStamp()); 178 _callback->Pop(frame.TimeStamp());
179 return ret; 179 return ret;
180 } 180 }
181 else if (ret == WEBRTC_VIDEO_CODEC_NO_OUTPUT || 181 else if (ret == WEBRTC_VIDEO_CODEC_NO_OUTPUT ||
182 ret == WEBRTC_VIDEO_CODEC_REQUEST_SLI) 182 ret == WEBRTC_VIDEO_CODEC_REQUEST_SLI)
183 { 183 {
184 // No output 184 // No output
185 _callback->Pop(frame.TimeStamp()); 185 _callback->Pop(frame.TimeStamp());
186 } 186 }
187 return ret; 187 return ret;
188 } 188 }
189 189
190 int32_t 190 int32_t
191 VCMGenericDecoder::Release() 191 VCMGenericDecoder::Release()
192 { 192 {
193 return _decoder->Release(); 193 return _decoder.Release();
194 } 194 }
195 195
196 int32_t VCMGenericDecoder::Reset() 196 int32_t VCMGenericDecoder::Reset()
197 { 197 {
198 return _decoder->Reset(); 198 return _decoder.Reset();
199 } 199 }
200 200
201 int32_t VCMGenericDecoder::RegisterDecodeCompleteCallback(VCMDecodedFrameCallbac k* callback) 201 int32_t VCMGenericDecoder::RegisterDecodeCompleteCallback(VCMDecodedFrameCallbac k* callback)
202 { 202 {
203 _callback = callback; 203 _callback = callback;
204 return _decoder->RegisterDecodeCompleteCallback(callback); 204 return _decoder.RegisterDecodeCompleteCallback(callback);
205 } 205 }
206 206
207 bool VCMGenericDecoder::External() const 207 bool VCMGenericDecoder::External() const
208 { 208 {
209 return _isExternal; 209 return _isExternal;
210 } 210 }
211 211
212 } // namespace 212 } // namespace
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/generic_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698