From 52fd98d876dbc40b47e3ef715da2cabc0ace7f93 Mon Sep 17 00:00:00 2001 From: "pwestin@webrtc.org" Date: Mon, 13 Feb 2012 09:03:53 +0000 Subject: [PATCH] Removing encoder reset. Function did not make sence. Review URL: https://webrtc-codereview.appspot.com/391005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1674 4adac7df-926f-26a2-2b94-8c16560cd09d --- src/modules/utility/source/file_player_impl.cc | 2 +- .../utility/source/file_recorder_impl.cc | 1 - src/modules/utility/source/video_coder.cc | 7 +++---- src/modules/utility/source/video_coder.h | 6 +++--- .../codecs/i420/main/interface/i420.h | 6 ------ .../codecs/i420/main/source/i420.cc | 11 ----------- .../codecs/interface/video_codec_interface.h | 5 ----- .../codecs/test_framework/unit_test.cc | 7 +------ .../codecs/vp8/main/interface/vp8.h | 8 -------- .../video_coding/codecs/vp8/main/source/vp8.cc | 18 ------------------ .../video_coding/main/interface/video_coding.h | 9 +-------- .../main/source/generic_encoder.cc | 11 +---------- .../video_coding/main/source/generic_encoder.h | 6 +----- .../main/source/video_coding_impl.cc | 16 ---------------- .../main/source/video_coding_impl.h | 5 +---- 15 files changed, 12 insertions(+), 106 deletions(-) diff --git a/src/modules/utility/source/file_player_impl.cc b/src/modules/utility/source/file_player_impl.cc index 2c1b504bb..f2162a66b 100644 --- a/src/modules/utility/source/file_player_impl.cc +++ b/src/modules/utility/source/file_player_impl.cc @@ -527,7 +527,7 @@ WebRtc_Word32 VideoFilePlayerImpl::StopPlayingFile() CriticalSectionScoped lock( _critSec); _decodedVideoFrames = 0; - _videoDecoder.Reset(); + _videoDecoder.ResetDecoder(); return FilePlayerImpl::StopPlayingFile(); } diff --git a/src/modules/utility/source/file_recorder_impl.cc b/src/modules/utility/source/file_recorder_impl.cc index 7fff4b4a9..15a447237 100644 --- a/src/modules/utility/source/file_recorder_impl.cc +++ b/src/modules/utility/source/file_recorder_impl.cc @@ -447,7 +447,6 @@ WebRtc_Word32 AviRecorder::StopRecording() _timeEvent.StopTimer(); StopThread(); - _videoEncoder->Reset(); return FileRecorderImpl::StopRecording(); } diff --git a/src/modules/utility/source/video_coder.cc b/src/modules/utility/source/video_coder.cc index 470e6b2f0..e17c3e049 100644 --- a/src/modules/utility/source/video_coder.cc +++ b/src/modules/utility/source/video_coder.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -30,10 +30,9 @@ VideoCoder::~VideoCoder() VideoCodingModule::Destroy(_vcm); } -WebRtc_Word32 VideoCoder::Reset() +WebRtc_Word32 VideoCoder::ResetDecoder() { _vcm->ResetDecoder(); - _vcm->ResetEncoder(); _vcm->InitializeSender(); _vcm->InitializeReceiver(); @@ -108,7 +107,7 @@ WebRtc_Word32 VideoCoder::Encode(const VideoFrame& videoFrame, return 0; } -WebRtc_Word8 VideoCoder::DefaultPayloadType(const WebRtc_Word8* plName) +WebRtc_Word8 VideoCoder::DefaultPayloadType(const char* plName) { VideoCodec tmpCodec; WebRtc_Word32 numberOfCodecs = _vcm->NumberOfCodecs(); diff --git a/src/modules/utility/source/video_coder.h b/src/modules/utility/source/video_coder.h index 049793b71..5c4b0aec8 100644 --- a/src/modules/utility/source/video_coder.h +++ b/src/modules/utility/source/video_coder.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -23,7 +23,7 @@ public: VideoCoder(WebRtc_UWord32 instanceID); ~VideoCoder(); - WebRtc_Word32 Reset(); + WebRtc_Word32 ResetDecoder(); WebRtc_Word32 SetEncodeCodec(VideoCodec& videoCodecInst, WebRtc_UWord32 numberOfCores, @@ -41,7 +41,7 @@ public: WebRtc_Word32 Encode(const VideoFrame& videoFrame, EncodedVideoData& videoEncodedData); - WebRtc_Word8 DefaultPayloadType(const WebRtc_Word8* plName); + WebRtc_Word8 DefaultPayloadType(const char* plName); private: // VCMReceiveCallback function. diff --git a/src/modules/video_coding/codecs/i420/main/interface/i420.h b/src/modules/video_coding/codecs/i420/main/interface/i420.h index 7c36fe840..fb4ba8c1c 100644 --- a/src/modules/video_coding/codecs/i420/main/interface/i420.h +++ b/src/modules/video_coding/codecs/i420/main/interface/i420.h @@ -65,12 +65,6 @@ public: // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. virtual WebRtc_Word32 Release(); -// Reset encoder state and prepare for a new call. -// -// Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. -// <0 - Error - virtual WebRtc_Word32 Reset(); - virtual WebRtc_Word32 SetRates(WebRtc_UWord32 /*newBitRate*/, WebRtc_UWord32 /*frameRate*/) {return WEBRTC_VIDEO_CODEC_OK;} diff --git a/src/modules/video_coding/codecs/i420/main/source/i420.cc b/src/modules/video_coding/codecs/i420/main/source/i420.cc index 460a021e2..b73a00a72 100644 --- a/src/modules/video_coding/codecs/i420/main/source/i420.cc +++ b/src/modules/video_coding/codecs/i420/main/source/i420.cc @@ -45,17 +45,6 @@ I420Encoder::Release() return WEBRTC_VIDEO_CODEC_OK; } -WebRtc_Word32 -I420Encoder::Reset() -{ - if (!_inited) - { - return WEBRTC_VIDEO_CODEC_UNINITIALIZED; - } - return WEBRTC_VIDEO_CODEC_OK; - -} - WebRtc_Word32 I420Encoder::InitEncode(const VideoCodec* codecSettings, WebRtc_Word32 /*numberOfCores*/, diff --git a/src/modules/video_coding/codecs/interface/video_codec_interface.h b/src/modules/video_coding/codecs/interface/video_codec_interface.h index 1c73469c6..9aa5cb77e 100644 --- a/src/modules/video_coding/codecs/interface/video_codec_interface.h +++ b/src/modules/video_coding/codecs/interface/video_codec_interface.h @@ -115,11 +115,6 @@ public: // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. virtual WebRtc_Word32 Release() = 0; - // Reset encoder state and prepare for a new call. - // - // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. - virtual WebRtc_Word32 Reset() = 0; - // Inform the encoder about the packet loss and round trip time on the // network used to decide the best pattern and signaling. // diff --git a/src/modules/video_coding/codecs/test_framework/unit_test.cc b/src/modules/video_coding/codecs/test_framework/unit_test.cc index 1ded40172..99bd7fbf8 100644 --- a/src/modules/video_coding/codecs/test_framework/unit_test.cc +++ b/src/modules/video_coding/codecs/test_framework/unit_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -373,7 +373,6 @@ UnitTest::Perform() VideoBufferToRawImage(_inputVideoBuffer, inputImage); EXPECT_TRUE(_encoder->Encode(inputImage, NULL, &videoFrameType ) == WEBRTC_VIDEO_CODEC_UNINITIALIZED); - EXPECT_TRUE(_encoder->Reset() == WEBRTC_VIDEO_CODEC_UNINITIALIZED); //-- InitEncode() errors -- // Null pointer. @@ -475,7 +474,6 @@ UnitTest::Perform() EXPECT_TRUE(_encoder->Encode(inputImage, NULL, &videoFrameType) == WEBRTC_VIDEO_CODEC_OK); WaitForEncodedFrame(); - EXPECT_TRUE(_encoder->Reset() == WEBRTC_VIDEO_CODEC_OK); EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK); _encoder->Encode(inputImage, NULL, &videoFrameType); frameLength = WaitForEncodedFrame(); @@ -679,7 +677,6 @@ UnitTest::Perform() _inst.maxBitrate = 0; //-- Timestamp propagation -- - EXPECT_TRUE(_encoder->Reset() == WEBRTC_VIDEO_CODEC_OK); EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK); EXPECT_TRUE(_decoder->Reset() == WEBRTC_VIDEO_CODEC_OK); EXPECT_TRUE(_decoder->InitDecode(&_inst, 1) == WEBRTC_VIDEO_CODEC_OK); @@ -745,7 +742,6 @@ UnitTest::RateControlTests() // Do not specify maxBitRate (as in ViE). _inst.maxBitrate = 0; //-- Verify rate control -- - EXPECT_TRUE(_encoder->Reset() == WEBRTC_VIDEO_CODEC_OK); EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK); EXPECT_TRUE(_decoder->Reset() == WEBRTC_VIDEO_CODEC_OK); EXPECT_TRUE(_decoder->InitDecode(&_inst, 1) == WEBRTC_VIDEO_CODEC_OK); @@ -759,7 +755,6 @@ UnitTest::RateControlTests() { _bitRate = bitRate[i]; int totalBytes = 0; - _encoder->Reset(); _inst.startBitrate = _bitRate; _encoder->InitEncode(&_inst, 4, 1440); _decoder->Reset(); diff --git a/src/modules/video_coding/codecs/vp8/main/interface/vp8.h b/src/modules/video_coding/codecs/vp8/main/interface/vp8.h index 652991d33..c274e4c69 100644 --- a/src/modules/video_coding/codecs/vp8/main/interface/vp8.h +++ b/src/modules/video_coding/codecs/vp8/main/interface/vp8.h @@ -39,14 +39,6 @@ class VP8Encoder : public VideoEncoder { // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. virtual int Release(); - // Reset encoder state and prepare for a new call. - // - // Return value : WEBRTC_VIDEO_CODEC_OK if OK, < 0 otherwise. - // <0 - Errors: - // WEBRTC_VIDEO_CODEC_ERR_PARAMETER - // WEBRTC_VIDEO_CODEC_ERROR - virtual int Reset(); - // Initialize the encoder with the information from the codecSettings // // Input: diff --git a/src/modules/video_coding/codecs/vp8/main/source/vp8.cc b/src/modules/video_coding/codecs/vp8/main/source/vp8.cc index 599d3a53f..9a0141762 100644 --- a/src/modules/video_coding/codecs/vp8/main/source/vp8.cc +++ b/src/modules/video_coding/codecs/vp8/main/source/vp8.cc @@ -91,24 +91,6 @@ int VP8Encoder::Release() { return WEBRTC_VIDEO_CODEC_OK; } -int VP8Encoder::Reset() { - if (!inited_) { - return WEBRTC_VIDEO_CODEC_UNINITIALIZED; - } - if (encoder_ != NULL) { - if (vpx_codec_destroy(encoder_)) { - return WEBRTC_VIDEO_CODEC_MEMORY; - } - delete encoder_; - encoder_ = NULL; - } - timestamp_ = 0; - encoder_ = new vpx_codec_ctx_t; - rps_->Init(); - - return InitAndSetControlSettings(); -} - int VP8Encoder::SetRates(uint32_t new_bitrate_kbit, uint32_t new_framerate) { if (!inited_) { return WEBRTC_VIDEO_CODEC_UNINITIALIZED; diff --git a/src/modules/video_coding/main/interface/video_coding.h b/src/modules/video_coding/main/interface/video_coding.h index 87d04fb9e..38d35f3a8 100644 --- a/src/modules/video_coding/main/interface/video_coding.h +++ b/src/modules/video_coding/main/interface/video_coding.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -91,13 +91,6 @@ public: // < 0, on error. virtual WebRtc_Word32 InitializeSender() = 0; - // Resets the encoder state to the same state as when the encoder - // was created. - // - // Return value : VCM_OK, on success. - // < 0, on error. - virtual WebRtc_Word32 ResetEncoder() = 0; - // Registers a codec to be used for encoding. Calling this // API multiple times overwrites any previously registered codecs. // diff --git a/src/modules/video_coding/main/source/generic_encoder.cc b/src/modules/video_coding/main/source/generic_encoder.cc index 9cf149f9f..58cdd99ec 100644 --- a/src/modules/video_coding/main/source/generic_encoder.cc +++ b/src/modules/video_coding/main/source/generic_encoder.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -33,15 +33,6 @@ VCMGenericEncoder::~VCMGenericEncoder() { } -WebRtc_Word32 -VCMGenericEncoder::Reset() -{ - _bitRate = 0; - _frameRate = 0; - _VCMencodedFrameCallback = NULL; - return _encoder.Reset(); -} - WebRtc_Word32 VCMGenericEncoder::Release() { _bitRate = 0; diff --git a/src/modules/video_coding/main/source/generic_encoder.h b/src/modules/video_coding/main/source/generic_encoder.h index f851c87db..99c2ce960 100644 --- a/src/modules/video_coding/main/source/generic_encoder.h +++ b/src/modules/video_coding/main/source/generic_encoder.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -81,10 +81,6 @@ public: VCMGenericEncoder(VideoEncoder& encoder, bool internalSource = false); ~VCMGenericEncoder(); /** - * Reset the encoder state, prepare for a new call - */ - WebRtc_Word32 Reset(); - /** * Free encoder memory */ WebRtc_Word32 Release(); diff --git a/src/modules/video_coding/main/source/video_coding_impl.cc b/src/modules/video_coding/main/source/video_coding_impl.cc index d5e8bf123..2dc43d672 100644 --- a/src/modules/video_coding/main/source/video_coding_impl.cc +++ b/src/modules/video_coding/main/source/video_coding_impl.cc @@ -344,22 +344,6 @@ VideoCodingModuleImpl::InitializeSender() return VCM_OK; } -// Makes sure the encoder is in its initial state. -WebRtc_Word32 -VideoCodingModuleImpl::ResetEncoder() -{ - WEBRTC_TRACE(webrtc::kTraceModuleCall, - webrtc::kTraceVideoCoding, - VCMId(_id), - "ResetEncoder()"); - CriticalSectionScoped cs(_sendCritSect); - if (_encoder != NULL) - { - return _encoder->Reset(); - } - return VCM_OK; -} - // Register the send codec to be used. WebRtc_Word32 VideoCodingModuleImpl::RegisterSendCodec(const VideoCodec* sendCodec, diff --git a/src/modules/video_coding/main/source/video_coding_impl.h b/src/modules/video_coding/main/source/video_coding_impl.h index 4e21fa0e8..5ce95719f 100644 --- a/src/modules/video_coding/main/source/video_coding_impl.h +++ b/src/modules/video_coding/main/source/video_coding_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -81,9 +81,6 @@ public: // Initialize send codec virtual WebRtc_Word32 InitializeSender(); - // Makes sure the encoder is in its initial state. - virtual WebRtc_Word32 ResetEncoder(); - // Register the send codec to be used. virtual WebRtc_Word32 RegisterSendCodec(const VideoCodec* sendCodec, WebRtc_UWord32 numberOfCores,