| Index: webrtc/modules/video_coding/generic_decoder.cc
|
| diff --git a/webrtc/modules/video_coding/generic_decoder.cc b/webrtc/modules/video_coding/generic_decoder.cc
|
| index 3c72509c052d978276fe5c964b327ce993453d7e..5cbe0f5ba0e8b102f3d5ed5ba4f060ca150aaf70 100644
|
| --- a/webrtc/modules/video_coding/generic_decoder.cc
|
| +++ b/webrtc/modules/video_coding/generic_decoder.cc
|
| @@ -17,7 +17,7 @@
|
|
|
| namespace webrtc {
|
|
|
| -VCMDecodedFrameCallback::VCMDecodedFrameCallback(VCMTiming& timing,
|
| +VCMDecodedFrameCallback::VCMDecodedFrameCallback(VCMTiming* timing,
|
| Clock* clock)
|
| : _critSect(CriticalSectionWrapper::CreateCriticalSection()),
|
| _clock(clock),
|
| @@ -26,22 +26,19 @@ VCMDecodedFrameCallback::VCMDecodedFrameCallback(VCMTiming& timing,
|
| _timestampMap(kDecoderFrameMemoryLength),
|
| _lastReceivedPictureID(0) {}
|
|
|
| -VCMDecodedFrameCallback::~VCMDecodedFrameCallback()
|
| -{
|
| - delete _critSect;
|
| +VCMDecodedFrameCallback::~VCMDecodedFrameCallback() {
|
| + delete _critSect;
|
| }
|
|
|
| void VCMDecodedFrameCallback::SetUserReceiveCallback(
|
| - VCMReceiveCallback* receiveCallback)
|
| -{
|
| - CriticalSectionScoped cs(_critSect);
|
| - _receiveCallback = receiveCallback;
|
| + VCMReceiveCallback* receiveCallback) {
|
| + CriticalSectionScoped cs(_critSect);
|
| + _receiveCallback = receiveCallback;
|
| }
|
|
|
| -VCMReceiveCallback* VCMDecodedFrameCallback::UserReceiveCallback()
|
| -{
|
| - CriticalSectionScoped cs(_critSect);
|
| - return _receiveCallback;
|
| +VCMReceiveCallback* VCMDecodedFrameCallback::UserReceiveCallback() {
|
| + CriticalSectionScoped cs(_critSect);
|
| + return _receiveCallback;
|
| }
|
|
|
| int32_t VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage) {
|
| @@ -50,66 +47,57 @@ int32_t VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage) {
|
|
|
| int32_t VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage,
|
| int64_t decode_time_ms) {
|
| - TRACE_EVENT_INSTANT1("webrtc", "VCMDecodedFrameCallback::Decoded",
|
| - "timestamp", decodedImage.timestamp());
|
| - // TODO(holmer): We should improve this so that we can handle multiple
|
| - // callbacks from one call to Decode().
|
| - VCMFrameInformation* frameInfo;
|
| - VCMReceiveCallback* callback;
|
| - {
|
| - CriticalSectionScoped cs(_critSect);
|
| - frameInfo = _timestampMap.Pop(decodedImage.timestamp());
|
| - callback = _receiveCallback;
|
| - }
|
| -
|
| - if (frameInfo == NULL) {
|
| - LOG(LS_WARNING) << "Too many frames backed up in the decoder, dropping "
|
| - "this one.";
|
| - return WEBRTC_VIDEO_CODEC_OK;
|
| - }
|
| + TRACE_EVENT_INSTANT1("webrtc", "VCMDecodedFrameCallback::Decoded",
|
| + "timestamp", decodedImage.timestamp());
|
| + // TODO(holmer): We should improve this so that we can handle multiple
|
| + // callbacks from one call to Decode().
|
| + VCMFrameInformation* frameInfo;
|
| + VCMReceiveCallback* callback;
|
| + {
|
| + CriticalSectionScoped cs(_critSect);
|
| + frameInfo = _timestampMap.Pop(decodedImage.timestamp());
|
| + callback = _receiveCallback;
|
| + }
|
|
|
| - const int64_t now_ms = _clock->TimeInMilliseconds();
|
| - if (decode_time_ms < 0) {
|
| - decode_time_ms =
|
| - static_cast<int32_t>(now_ms - frameInfo->decodeStartTimeMs);
|
| - }
|
| - _timing.StopDecodeTimer(
|
| - decodedImage.timestamp(),
|
| - decode_time_ms,
|
| - now_ms,
|
| - frameInfo->renderTimeMs);
|
| -
|
| - if (callback != NULL)
|
| - {
|
| - decodedImage.set_render_time_ms(frameInfo->renderTimeMs);
|
| - decodedImage.set_rotation(frameInfo->rotation);
|
| - callback->FrameToRender(decodedImage);
|
| - }
|
| + if (frameInfo == NULL) {
|
| + LOG(LS_WARNING) << "Too many frames backed up in the decoder, dropping "
|
| + "this one.";
|
| return WEBRTC_VIDEO_CODEC_OK;
|
| + }
|
| +
|
| + const int64_t now_ms = _clock->TimeInMilliseconds();
|
| + if (decode_time_ms < 0) {
|
| + decode_time_ms =
|
| + static_cast<int32_t>(now_ms - frameInfo->decodeStartTimeMs);
|
| + }
|
| + _timing->StopDecodeTimer(decodedImage.timestamp(), decode_time_ms, now_ms,
|
| + frameInfo->renderTimeMs);
|
| +
|
| + if (callback != NULL) {
|
| + decodedImage.set_render_time_ms(frameInfo->renderTimeMs);
|
| + decodedImage.set_rotation(frameInfo->rotation);
|
| + callback->FrameToRender(decodedImage);
|
| + }
|
| + return WEBRTC_VIDEO_CODEC_OK;
|
| +}
|
| +
|
| +int32_t VCMDecodedFrameCallback::ReceivedDecodedReferenceFrame(
|
| + const uint64_t pictureId) {
|
| + CriticalSectionScoped cs(_critSect);
|
| + if (_receiveCallback != NULL) {
|
| + return _receiveCallback->ReceivedDecodedReferenceFrame(pictureId);
|
| + }
|
| + return -1;
|
| }
|
|
|
| -int32_t
|
| -VCMDecodedFrameCallback::ReceivedDecodedReferenceFrame(
|
| - const uint64_t pictureId)
|
| -{
|
| - CriticalSectionScoped cs(_critSect);
|
| - if (_receiveCallback != NULL)
|
| - {
|
| - return _receiveCallback->ReceivedDecodedReferenceFrame(pictureId);
|
| - }
|
| - return -1;
|
| -}
|
| -
|
| -int32_t
|
| -VCMDecodedFrameCallback::ReceivedDecodedFrame(const uint64_t pictureId)
|
| -{
|
| - _lastReceivedPictureID = pictureId;
|
| - return 0;
|
| +int32_t VCMDecodedFrameCallback::ReceivedDecodedFrame(
|
| + const uint64_t pictureId) {
|
| + _lastReceivedPictureID = pictureId;
|
| + return 0;
|
| }
|
|
|
| -uint64_t VCMDecodedFrameCallback::LastReceivedPictureID() const
|
| -{
|
| - return _lastReceivedPictureID;
|
| +uint64_t VCMDecodedFrameCallback::LastReceivedPictureID() const {
|
| + return _lastReceivedPictureID;
|
| }
|
|
|
| void VCMDecodedFrameCallback::OnDecoderImplementationName(
|
| @@ -125,14 +113,12 @@ void VCMDecodedFrameCallback::Map(uint32_t timestamp,
|
| _timestampMap.Add(timestamp, frameInfo);
|
| }
|
|
|
| -int32_t VCMDecodedFrameCallback::Pop(uint32_t timestamp)
|
| -{
|
| - CriticalSectionScoped cs(_critSect);
|
| - if (_timestampMap.Pop(timestamp) == NULL)
|
| - {
|
| - return VCM_GENERAL_ERROR;
|
| - }
|
| - return VCM_OK;
|
| +int32_t VCMDecodedFrameCallback::Pop(uint32_t timestamp) {
|
| + CriticalSectionScoped cs(_critSect);
|
| + if (_timestampMap.Pop(timestamp) == NULL) {
|
| + return VCM_GENERAL_ERROR;
|
| + }
|
| + return VCM_OK;
|
| }
|
|
|
| VCMGenericDecoder::VCMGenericDecoder(VideoDecoder* decoder, bool isExternal)
|
| @@ -147,12 +133,11 @@ VCMGenericDecoder::VCMGenericDecoder(VideoDecoder* decoder, bool isExternal)
|
| VCMGenericDecoder::~VCMGenericDecoder() {}
|
|
|
| int32_t VCMGenericDecoder::InitDecode(const VideoCodec* settings,
|
| - int32_t numberOfCores)
|
| -{
|
| - TRACE_EVENT0("webrtc", "VCMGenericDecoder::InitDecode");
|
| - _codecType = settings->codecType;
|
| + int32_t numberOfCores) {
|
| + TRACE_EVENT0("webrtc", "VCMGenericDecoder::InitDecode");
|
| + _codecType = settings->codecType;
|
|
|
| - return _decoder->InitDecode(settings, numberOfCores);
|
| + return _decoder->InitDecode(settings, numberOfCores);
|
| }
|
|
|
| int32_t VCMGenericDecoder::Decode(const VCMEncodedFrame& frame, int64_t nowMs) {
|
| @@ -169,16 +154,13 @@ int32_t VCMGenericDecoder::Decode(const VCMEncodedFrame& frame, int64_t nowMs) {
|
| frame.CodecSpecific(), frame.RenderTimeMs());
|
|
|
| _callback->OnDecoderImplementationName(_decoder->ImplementationName());
|
| - if (ret < WEBRTC_VIDEO_CODEC_OK)
|
| - {
|
| + if (ret < WEBRTC_VIDEO_CODEC_OK) {
|
| LOG(LS_WARNING) << "Failed to decode frame with timestamp "
|
| << frame.TimeStamp() << ", error code: " << ret;
|
| _callback->Pop(frame.TimeStamp());
|
| return ret;
|
| - }
|
| - else if (ret == WEBRTC_VIDEO_CODEC_NO_OUTPUT ||
|
| - ret == WEBRTC_VIDEO_CODEC_REQUEST_SLI)
|
| - {
|
| + } else if (ret == WEBRTC_VIDEO_CODEC_NO_OUTPUT ||
|
| + ret == WEBRTC_VIDEO_CODEC_REQUEST_SLI) {
|
| // No output
|
| _callback->Pop(frame.TimeStamp());
|
| }
|
| @@ -207,4 +189,4 @@ bool VCMGenericDecoder::PrefersLateDecoding() const {
|
| return _decoder->PrefersLateDecoding();
|
| }
|
|
|
| -} // namespace
|
| +} // namespace webrtc
|
|
|