Chromium Code Reviews

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

Issue 1412573010: Trace encoding/decoding time in a generic way. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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/logging.h" 11 #include "webrtc/base/logging.h"
12 #include "webrtc/base/trace_event.h"
12 #include "webrtc/modules/video_coding/main/interface/video_coding.h" 13 #include "webrtc/modules/video_coding/main/interface/video_coding.h"
13 #include "webrtc/modules/video_coding/main/source/generic_decoder.h" 14 #include "webrtc/modules/video_coding/main/source/generic_decoder.h"
14 #include "webrtc/modules/video_coding/main/source/internal_defines.h" 15 #include "webrtc/modules/video_coding/main/source/internal_defines.h"
15 #include "webrtc/system_wrappers/include/clock.h" 16 #include "webrtc/system_wrappers/include/clock.h"
16 17
17 namespace webrtc { 18 namespace webrtc {
18 19
19 VCMDecodedFrameCallback::VCMDecodedFrameCallback(VCMTiming& timing, 20 VCMDecodedFrameCallback::VCMDecodedFrameCallback(VCMTiming& timing,
20 Clock* clock) 21 Clock* clock)
21 : 22 :
(...skipping 23 matching lines...)
45 CriticalSectionScoped cs(_critSect); 46 CriticalSectionScoped cs(_critSect);
46 return _receiveCallback; 47 return _receiveCallback;
47 } 48 }
48 49
49 int32_t VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage) { 50 int32_t VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage) {
50 return Decoded(decodedImage, -1); 51 return Decoded(decodedImage, -1);
51 } 52 }
52 53
53 int32_t VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage, 54 int32_t VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage,
54 int64_t decode_time_ms) { 55 int64_t decode_time_ms) {
56 TRACE_EVENT_INSTANT1("webrtc", "VCMDecodedFrameCallback::Decoded",
57 "timestamp", decodedImage.timestamp());
55 // TODO(holmer): We should improve this so that we can handle multiple 58 // TODO(holmer): We should improve this so that we can handle multiple
56 // callbacks from one call to Decode(). 59 // callbacks from one call to Decode().
57 VCMFrameInformation* frameInfo; 60 VCMFrameInformation* frameInfo;
58 VCMReceiveCallback* callback; 61 VCMReceiveCallback* callback;
59 { 62 {
60 CriticalSectionScoped cs(_critSect); 63 CriticalSectionScoped cs(_critSect);
61 frameInfo = _timestampMap.Pop(decodedImage.timestamp()); 64 frameInfo = _timestampMap.Pop(decodedImage.timestamp());
62 callback = _receiveCallback; 65 callback = _receiveCallback;
63 } 66 }
64 67
(...skipping 75 matching lines...)
140 { 143 {
141 } 144 }
142 145
143 VCMGenericDecoder::~VCMGenericDecoder() 146 VCMGenericDecoder::~VCMGenericDecoder()
144 { 147 {
145 } 148 }
146 149
147 int32_t VCMGenericDecoder::InitDecode(const VideoCodec* settings, 150 int32_t VCMGenericDecoder::InitDecode(const VideoCodec* settings,
148 int32_t numberOfCores) 151 int32_t numberOfCores)
149 { 152 {
153 TRACE_EVENT0("webrtc", "VCMGenericDecoder::InitDecode");
150 _codecType = settings->codecType; 154 _codecType = settings->codecType;
151 155
152 return _decoder.InitDecode(settings, numberOfCores); 156 return _decoder.InitDecode(settings, numberOfCores);
153 } 157 }
154 158
155 int32_t VCMGenericDecoder::Decode(const VCMEncodedFrame& frame, 159 int32_t VCMGenericDecoder::Decode(const VCMEncodedFrame& frame, int64_t nowMs) {
156 int64_t nowMs) 160 TRACE_EVENT1("webrtc", "VCMGenericDecoder::Decode", "timestamp",
157 { 161 frame.EncodedImage()._timeStamp);
158 _frameInfos[_nextFrameInfoIdx].decodeStartTimeMs = nowMs; 162 _frameInfos[_nextFrameInfoIdx].decodeStartTimeMs = nowMs;
159 _frameInfos[_nextFrameInfoIdx].renderTimeMs = frame.RenderTimeMs(); 163 _frameInfos[_nextFrameInfoIdx].renderTimeMs = frame.RenderTimeMs();
160 _frameInfos[_nextFrameInfoIdx].rotation = frame.rotation(); 164 _frameInfos[_nextFrameInfoIdx].rotation = frame.rotation();
161 _callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]); 165 _callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]);
162 166
163 _nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength; 167 _nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength;
164 int32_t ret = _decoder.Decode(frame.EncodedImage(), 168 int32_t ret = _decoder.Decode(frame.EncodedImage(),
165 frame.MissingFrame(), 169 frame.MissingFrame(),
166 frame.FragmentationHeader(), 170 frame.FragmentationHeader(),
167 frame.CodecSpecific(), 171 frame.CodecSpecific(),
(...skipping 31 matching lines...)
199 _callback = callback; 203 _callback = callback;
200 return _decoder.RegisterDecodeCompleteCallback(callback); 204 return _decoder.RegisterDecodeCompleteCallback(callback);
201 } 205 }
202 206
203 bool VCMGenericDecoder::External() const 207 bool VCMGenericDecoder::External() const
204 { 208 {
205 return _isExternal; 209 return _isExternal;
206 } 210 }
207 211
208 } // namespace 212 } // namespace
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc ('k') | webrtc/modules/video_coding/main/source/generic_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine