Remove the useless dummy state parameter to WebRtcG711_*

R=henrik.lundin@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/27029004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7609 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
kwiberg@webrtc.org 2014-11-04 13:23:36 +00:00
parent b5d045e94d
commit c78cf97ecb
8 changed files with 22 additions and 61 deletions

View File

@ -82,8 +82,7 @@ bool AudioEncoderPcm::Encode(uint32_t timestamp,
int16_t AudioEncoderPcmA::EncodeCall(const int16_t* audio,
size_t input_len,
uint8_t* encoded) {
return WebRtcG711_EncodeA(NULL,
const_cast<int16_t*>(audio),
return WebRtcG711_EncodeA(const_cast<int16_t*>(audio),
static_cast<int16_t>(input_len),
reinterpret_cast<int16_t*>(encoded));
}
@ -91,8 +90,7 @@ int16_t AudioEncoderPcmA::EncodeCall(const int16_t* audio,
int16_t AudioEncoderPcmU::EncodeCall(const int16_t* audio,
size_t input_len,
uint8_t* encoded) {
return WebRtcG711_EncodeU(NULL,
const_cast<int16_t*>(audio),
return WebRtcG711_EncodeU(const_cast<int16_t*>(audio),
static_cast<int16_t>(input_len),
reinterpret_cast<int16_t*>(encoded));
}

View File

@ -12,16 +12,12 @@
#include "g711_interface.h"
#include "webrtc/typedefs.h"
int16_t WebRtcG711_EncodeA(void* state,
int16_t* speechIn,
int16_t WebRtcG711_EncodeA(int16_t* speechIn,
int16_t len,
int16_t* encoded) {
int n;
uint16_t tempVal, tempVal2;
// Set and discard to avoid getting warnings
(void)(state = NULL);
// Sanity check of input length
if (len < 0) {
return (-1);
@ -50,16 +46,12 @@ int16_t WebRtcG711_EncodeA(void* state,
return (len);
}
int16_t WebRtcG711_EncodeU(void* state,
int16_t* speechIn,
int16_t WebRtcG711_EncodeU(int16_t* speechIn,
int16_t len,
int16_t* encoded) {
int n;
uint16_t tempVal;
// Set and discard to avoid getting warnings
(void)(state = NULL);
// Sanity check of input length
if (len < 0) {
return (-1);
@ -86,17 +78,13 @@ int16_t WebRtcG711_EncodeU(void* state,
return (len);
}
int16_t WebRtcG711_DecodeA(void* state,
int16_t* encoded,
int16_t WebRtcG711_DecodeA(int16_t* encoded,
int16_t len,
int16_t* decoded,
int16_t* speechType) {
int n;
uint16_t tempVal;
// Set and discard to avoid getting warnings
(void)(state = NULL);
// Sanity check of input length
if (len < 0) {
return (-1);
@ -123,17 +111,13 @@ int16_t WebRtcG711_DecodeA(void* state,
return (len);
}
int16_t WebRtcG711_DecodeU(void* state,
int16_t* encoded,
int16_t WebRtcG711_DecodeU(int16_t* encoded,
int16_t len,
int16_t* decoded,
int16_t* speechType) {
int n;
uint16_t tempVal;
// Set and discard to avoid getting warnings
(void)(state = NULL);
// Sanity check of input length
if (len < 0) {
return (-1);
@ -160,10 +144,8 @@ int16_t WebRtcG711_DecodeU(void* state,
return (len);
}
int WebRtcG711_DurationEst(void* state,
const uint8_t* payload,
int WebRtcG711_DurationEst(const uint8_t* payload,
int payload_length_bytes) {
(void) state;
(void) payload;
/* G.711 is one byte per sample, so we can just return the number of bytes. */
return payload_length_bytes;

View File

@ -28,8 +28,6 @@ extern "C" {
* Input speech length has be of any length.
*
* Input:
* - state : Dummy state to make this codec look more like
* other codecs
* - speechIn : Input speech vector
* - len : Samples in speechIn
*
@ -40,8 +38,7 @@ extern "C" {
* -1 - Error
*/
int16_t WebRtcG711_EncodeA(void* state,
int16_t* speechIn,
int16_t WebRtcG711_EncodeA(int16_t* speechIn,
int16_t len,
int16_t* encoded);
@ -52,8 +49,6 @@ int16_t WebRtcG711_EncodeA(void* state,
* Input speech length has be of any length.
*
* Input:
* - state : Dummy state to make this codec look more like
* other codecs
* - speechIn : Input speech vector
* - len : Samples in speechIn
*
@ -64,8 +59,7 @@ int16_t WebRtcG711_EncodeA(void* state,
* -1 - Error
*/
int16_t WebRtcG711_EncodeU(void* state,
int16_t* speechIn,
int16_t WebRtcG711_EncodeU(int16_t* speechIn,
int16_t len,
int16_t* encoded);
@ -75,8 +69,6 @@ int16_t WebRtcG711_EncodeU(void* state,
* This function decodes a packet G711 A-law frame.
*
* Input:
* - state : Dummy state to make this codec look more like
* other codecs
* - encoded : Encoded data
* - len : Bytes in encoded vector
*
@ -90,8 +82,7 @@ int16_t WebRtcG711_EncodeU(void* state,
* -1 - Error
*/
int16_t WebRtcG711_DecodeA(void* state,
int16_t* encoded,
int16_t WebRtcG711_DecodeA(int16_t* encoded,
int16_t len,
int16_t* decoded,
int16_t* speechType);
@ -102,8 +93,6 @@ int16_t WebRtcG711_DecodeA(void* state,
* This function decodes a packet G711 U-law frame.
*
* Input:
* - state : Dummy state to make this codec look more like
* other codecs
* - encoded : Encoded data
* - len : Bytes in encoded vector
*
@ -117,8 +106,7 @@ int16_t WebRtcG711_DecodeA(void* state,
* -1 - Error
*/
int16_t WebRtcG711_DecodeU(void* state,
int16_t* encoded,
int16_t WebRtcG711_DecodeU(int16_t* encoded,
int16_t len,
int16_t* decoded,
int16_t* speechType);
@ -129,8 +117,6 @@ int16_t WebRtcG711_DecodeU(void* state,
* This function estimates the duration of a G711 packet in samples.
*
* Input:
* - state : Dummy state to make this codec look more like
* other codecs
* - payload : Encoded data
* - payloadLengthBytes : Bytes in encoded vector
*
@ -139,8 +125,7 @@ int16_t WebRtcG711_DecodeU(void* state,
* byte per sample.
*/
int WebRtcG711_DurationEst(void* state,
const uint8_t* payload,
int WebRtcG711_DurationEst(const uint8_t* payload,
int payload_length_bytes);
/**********************************************************************

View File

@ -127,7 +127,7 @@ int main(int argc, char* argv[]) {
/* G.711 encoding */
if (!strcmp(law, "A")) {
/* A-law encoding */
stream_len = WebRtcG711_EncodeA(NULL, shortdata, framelength, streamdata);
stream_len = WebRtcG711_EncodeA(shortdata, framelength, streamdata);
if (argc == 6) {
/* Write bits to file */
if (fwrite(streamdata, sizeof(unsigned char), stream_len, bitp) !=
@ -135,11 +135,11 @@ int main(int argc, char* argv[]) {
return -1;
}
}
err = WebRtcG711_DecodeA(NULL, streamdata, stream_len, decoded,
err = WebRtcG711_DecodeA(streamdata, stream_len, decoded,
speechType);
} else if (!strcmp(law, "u")) {
/* u-law encoding */
stream_len = WebRtcG711_EncodeU(NULL, shortdata, framelength, streamdata);
stream_len = WebRtcG711_EncodeU(shortdata, framelength, streamdata);
if (argc == 6) {
/* Write bits to file */
if (fwrite(streamdata, sizeof(unsigned char), stream_len, bitp) !=
@ -147,8 +147,7 @@ int main(int argc, char* argv[]) {
return -1;
}
}
err = WebRtcG711_DecodeU(NULL, streamdata, stream_len, decoded,
speechType);
err = WebRtcG711_DecodeU(streamdata, stream_len, decoded, speechType);
} else {
printf("Wrong law mode\n");
exit(1);

View File

@ -27,7 +27,7 @@ ACMPCMA::~ACMPCMA() { return; }
int16_t ACMPCMA::InternalEncode(uint8_t* bitstream,
int16_t* bitstream_len_byte) {
*bitstream_len_byte = WebRtcG711_EncodeA(
NULL, &in_audio_[in_audio_ix_read_], frame_len_smpl_ * num_channels_,
&in_audio_[in_audio_ix_read_], frame_len_smpl_ * num_channels_,
reinterpret_cast<int16_t*>(bitstream));
// Increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer.

View File

@ -27,7 +27,7 @@ ACMPCMU::~ACMPCMU() {}
int16_t ACMPCMU::InternalEncode(uint8_t* bitstream,
int16_t* bitstream_len_byte) {
*bitstream_len_byte = WebRtcG711_EncodeU(
NULL, &in_audio_[in_audio_ix_read_], frame_len_smpl_ * num_channels_,
&in_audio_[in_audio_ix_read_], frame_len_smpl_ * num_channels_,
reinterpret_cast<int16_t*>(bitstream));
// Increment the read index this tell the caller that how far

View File

@ -45,7 +45,7 @@ int AudioDecoderPcmU::Decode(const uint8_t* encoded, size_t encoded_len,
int16_t* decoded, SpeechType* speech_type) {
int16_t temp_type = 1; // Default is speech.
int16_t ret = WebRtcG711_DecodeU(
state_, reinterpret_cast<int16_t*>(const_cast<uint8_t*>(encoded)),
reinterpret_cast<int16_t*>(const_cast<uint8_t*>(encoded)),
static_cast<int16_t>(encoded_len), decoded, &temp_type);
*speech_type = ConvertSpeechType(temp_type);
return ret;
@ -62,7 +62,7 @@ int AudioDecoderPcmA::Decode(const uint8_t* encoded, size_t encoded_len,
int16_t* decoded, SpeechType* speech_type) {
int16_t temp_type = 1; // Default is speech.
int16_t ret = WebRtcG711_DecodeA(
state_, reinterpret_cast<int16_t*>(const_cast<uint8_t*>(encoded)),
reinterpret_cast<int16_t*>(const_cast<uint8_t*>(encoded)),
static_cast<int16_t>(encoded_len), decoded, &temp_type);
*speech_type = ConvertSpeechType(temp_type);
return ret;

View File

@ -235,9 +235,6 @@ WebRtcVadInst *VAD_inst[2];
#ifdef CODEC_CELT_32
CELT_encinst_t *CELT32enc_inst[2];
#endif
#ifdef CODEC_G711
void *G711state[2]={NULL, NULL};
#endif
int main(int argc, char* argv[])
@ -1602,12 +1599,12 @@ int NetEQTest_encode(int coder, int16_t *indata, int frameLen, unsigned char * e
/* Encode with the selected coder type */
if (coder==webrtc::kDecoderPCMu) { /*g711 u-law */
#ifdef CODEC_G711
cdlen = WebRtcG711_EncodeU(G711state[k], indata, frameLen, (int16_t*) encoded);
cdlen = WebRtcG711_EncodeU(indata, frameLen, (int16_t*) encoded);
#endif
}
else if (coder==webrtc::kDecoderPCMa) { /*g711 A-law */
#ifdef CODEC_G711
cdlen = WebRtcG711_EncodeA(G711state[k], indata, frameLen, (int16_t*) encoded);
cdlen = WebRtcG711_EncodeA(indata, frameLen, (int16_t*) encoded);
}
#endif
#ifdef CODEC_PCM16B