Revert 7807 "Removing unused opus wrapper APIs."
> Removing unused opus wrapper APIs. > > WebRtcOpus_DecodeNew(), WebRtcOpus_DecoderInitNew() have become the APIs and are ready to replace old WebRtcOpus_Decode() and WebRtcOpus_DecoderInit(). > > WebRtcOpus_DecodePlcMaster/Slave() are also removed. > > BUG= > R=henrik.lundin@webrtc.org > > Review URL: https://webrtc-codereview.appspot.com/28139004 TBR=minyue@webrtc.org Review URL: https://webrtc-codereview.appspot.com/31119004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7809 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
c0991fe606
commit
52bc4f4797
@ -166,7 +166,9 @@ int WebRtcOpus_DecoderChannels(OpusDecInst* inst);
|
|||||||
* Return value : 0 - Success
|
* Return value : 0 - Success
|
||||||
* -1 - Error
|
* -1 - Error
|
||||||
*/
|
*/
|
||||||
|
int16_t WebRtcOpus_DecoderInitNew(OpusDecInst* inst);
|
||||||
int16_t WebRtcOpus_DecoderInit(OpusDecInst* inst);
|
int16_t WebRtcOpus_DecoderInit(OpusDecInst* inst);
|
||||||
|
int16_t WebRtcOpus_DecoderInitSlave(OpusDecInst* inst);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* WebRtcOpus_Decode(...)
|
* WebRtcOpus_Decode(...)
|
||||||
@ -188,12 +190,21 @@ int16_t WebRtcOpus_DecoderInit(OpusDecInst* inst);
|
|||||||
* Return value : >0 - Samples per channel in decoded vector
|
* Return value : >0 - Samples per channel in decoded vector
|
||||||
* -1 - Error
|
* -1 - Error
|
||||||
*/
|
*/
|
||||||
|
int16_t WebRtcOpus_DecodeNew(OpusDecInst* inst, const uint8_t* encoded,
|
||||||
|
int16_t encoded_bytes, int16_t* decoded,
|
||||||
|
int16_t* audio_type);
|
||||||
int16_t WebRtcOpus_Decode(OpusDecInst* inst, const uint8_t* encoded,
|
int16_t WebRtcOpus_Decode(OpusDecInst* inst, const uint8_t* encoded,
|
||||||
int16_t encoded_bytes, int16_t* decoded,
|
int16_t encoded_bytes, int16_t* decoded,
|
||||||
int16_t* audio_type);
|
int16_t* audio_type);
|
||||||
|
int16_t WebRtcOpus_DecodeSlave(OpusDecInst* inst, const uint8_t* encoded,
|
||||||
|
int16_t encoded_bytes, int16_t* decoded,
|
||||||
|
int16_t* audio_type);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* WebRtcOpus_DecodePlc(...)
|
* WebRtcOpus_DecodePlc(...)
|
||||||
|
* TODO(tlegrand): Remove master and slave functions when NetEq4 is in place.
|
||||||
|
* WebRtcOpus_DecodePlcMaster(...)
|
||||||
|
* WebRtcOpus_DecodePlcSlave(...)
|
||||||
*
|
*
|
||||||
* This function processes PLC for opus frame(s).
|
* This function processes PLC for opus frame(s).
|
||||||
* Input:
|
* Input:
|
||||||
@ -208,6 +219,10 @@ int16_t WebRtcOpus_Decode(OpusDecInst* inst, const uint8_t* encoded,
|
|||||||
*/
|
*/
|
||||||
int16_t WebRtcOpus_DecodePlc(OpusDecInst* inst, int16_t* decoded,
|
int16_t WebRtcOpus_DecodePlc(OpusDecInst* inst, int16_t* decoded,
|
||||||
int16_t number_of_lost_frames);
|
int16_t number_of_lost_frames);
|
||||||
|
int16_t WebRtcOpus_DecodePlcMaster(OpusDecInst* inst, int16_t* decoded,
|
||||||
|
int16_t number_of_lost_frames);
|
||||||
|
int16_t WebRtcOpus_DecodePlcSlave(OpusDecInst* inst, int16_t* decoded,
|
||||||
|
int16_t number_of_lost_frames);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* WebRtcOpus_DecodeFec(...)
|
* WebRtcOpus_DecodeFec(...)
|
||||||
|
@ -156,8 +156,10 @@ void OpusFecTest::DecodeABlock(bool lost_previous, bool lost_current) {
|
|||||||
|
|
||||||
if (!lost_current) {
|
if (!lost_current) {
|
||||||
// Decode current frame.
|
// Decode current frame.
|
||||||
value_2 = WebRtcOpus_Decode(opus_decoder_, &bit_stream_[0], encoded_bytes_,
|
value_2 = WebRtcOpus_DecodeNew(opus_decoder_, &bit_stream_[0],
|
||||||
&out_data_[value_1 * channels_], &audio_type);
|
encoded_bytes_,
|
||||||
|
&out_data_[value_1 * channels_],
|
||||||
|
&audio_type);
|
||||||
EXPECT_EQ(block_length_sample_, value_2);
|
EXPECT_EQ(block_length_sample_, value_2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,8 @@ struct WebRtcOpusEncInst {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct WebRtcOpusDecInst {
|
struct WebRtcOpusDecInst {
|
||||||
OpusDecoder* decoder;
|
OpusDecoder* decoder_left;
|
||||||
|
OpusDecoder* decoder_right;
|
||||||
int prev_decoded_samples;
|
int prev_decoded_samples;
|
||||||
int channels;
|
int channels;
|
||||||
};
|
};
|
||||||
|
@ -149,7 +149,8 @@ int16_t WebRtcOpus_SetComplexity(OpusEncInst* inst, int32_t complexity) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int16_t WebRtcOpus_DecoderCreate(OpusDecInst** inst, int channels) {
|
int16_t WebRtcOpus_DecoderCreate(OpusDecInst** inst, int channels) {
|
||||||
int error;
|
int error_l;
|
||||||
|
int error_r;
|
||||||
OpusDecInst* state;
|
OpusDecInst* state;
|
||||||
|
|
||||||
if (inst != NULL) {
|
if (inst != NULL) {
|
||||||
@ -159,9 +160,11 @@ int16_t WebRtcOpus_DecoderCreate(OpusDecInst** inst, int channels) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create new memory, always at 48000 Hz. */
|
/* Create new memory for left and right channel, always at 48000 Hz. */
|
||||||
state->decoder = opus_decoder_create(48000, channels, &error);
|
state->decoder_left = opus_decoder_create(48000, channels, &error_l);
|
||||||
if (error == OPUS_OK && state->decoder != NULL) {
|
state->decoder_right = opus_decoder_create(48000, channels, &error_r);
|
||||||
|
if (error_l == OPUS_OK && error_r == OPUS_OK && state->decoder_left != NULL
|
||||||
|
&& state->decoder_right != NULL) {
|
||||||
/* Creation of memory all ok. */
|
/* Creation of memory all ok. */
|
||||||
state->channels = channels;
|
state->channels = channels;
|
||||||
state->prev_decoded_samples = kWebRtcOpusDefaultFrameSize;
|
state->prev_decoded_samples = kWebRtcOpusDefaultFrameSize;
|
||||||
@ -170,8 +173,11 @@ int16_t WebRtcOpus_DecoderCreate(OpusDecInst** inst, int channels) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If memory allocation was unsuccessful, free the entire state. */
|
/* If memory allocation was unsuccessful, free the entire state. */
|
||||||
if (state->decoder) {
|
if (state->decoder_left) {
|
||||||
opus_decoder_destroy(state->decoder);
|
opus_decoder_destroy(state->decoder_left);
|
||||||
|
}
|
||||||
|
if (state->decoder_right) {
|
||||||
|
opus_decoder_destroy(state->decoder_right);
|
||||||
}
|
}
|
||||||
free(state);
|
free(state);
|
||||||
}
|
}
|
||||||
@ -180,7 +186,8 @@ int16_t WebRtcOpus_DecoderCreate(OpusDecInst** inst, int channels) {
|
|||||||
|
|
||||||
int16_t WebRtcOpus_DecoderFree(OpusDecInst* inst) {
|
int16_t WebRtcOpus_DecoderFree(OpusDecInst* inst) {
|
||||||
if (inst) {
|
if (inst) {
|
||||||
opus_decoder_destroy(inst->decoder);
|
opus_decoder_destroy(inst->decoder_left);
|
||||||
|
opus_decoder_destroy(inst->decoder_right);
|
||||||
free(inst);
|
free(inst);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
@ -192,8 +199,24 @@ int WebRtcOpus_DecoderChannels(OpusDecInst* inst) {
|
|||||||
return inst->channels;
|
return inst->channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16_t WebRtcOpus_DecoderInitNew(OpusDecInst* inst) {
|
||||||
|
int error = opus_decoder_ctl(inst->decoder_left, OPUS_RESET_STATE);
|
||||||
|
if (error == OPUS_OK) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
int16_t WebRtcOpus_DecoderInit(OpusDecInst* inst) {
|
int16_t WebRtcOpus_DecoderInit(OpusDecInst* inst) {
|
||||||
int error = opus_decoder_ctl(inst->decoder, OPUS_RESET_STATE);
|
int error = opus_decoder_ctl(inst->decoder_left, OPUS_RESET_STATE);
|
||||||
|
if (error == OPUS_OK) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t WebRtcOpus_DecoderInitSlave(OpusDecInst* inst) {
|
||||||
|
int error = opus_decoder_ctl(inst->decoder_right, OPUS_RESET_STATE);
|
||||||
if (error == OPUS_OK) {
|
if (error == OPUS_OK) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -233,10 +256,10 @@ static int DecodeFec(OpusDecoder* inst, const uint8_t* encoded,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t WebRtcOpus_Decode(OpusDecInst* inst, const uint8_t* encoded,
|
int16_t WebRtcOpus_DecodeNew(OpusDecInst* inst, const uint8_t* encoded,
|
||||||
int16_t encoded_bytes, int16_t* decoded,
|
int16_t encoded_bytes, int16_t* decoded,
|
||||||
int16_t* audio_type) {
|
int16_t* audio_type) {
|
||||||
int decoded_samples = DecodeNative(inst->decoder,
|
int decoded_samples = DecodeNative(inst->decoder_left,
|
||||||
encoded,
|
encoded,
|
||||||
encoded_bytes,
|
encoded_bytes,
|
||||||
kWebRtcOpusMaxFrameSizePerChannel,
|
kWebRtcOpusMaxFrameSizePerChannel,
|
||||||
@ -252,6 +275,70 @@ int16_t WebRtcOpus_Decode(OpusDecInst* inst, const uint8_t* encoded,
|
|||||||
return decoded_samples;
|
return decoded_samples;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16_t WebRtcOpus_Decode(OpusDecInst* inst, const uint8_t* encoded,
|
||||||
|
int16_t encoded_bytes, int16_t* decoded,
|
||||||
|
int16_t* audio_type) {
|
||||||
|
int decoded_samples;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* If mono case, just do a regular call to the decoder.
|
||||||
|
* If stereo, call to WebRtcOpus_Decode() gives left channel as output, and
|
||||||
|
* calls to WebRtcOpus_Decode_slave() give right channel as output.
|
||||||
|
* This is to make stereo work with the current setup of NetEQ, which
|
||||||
|
* requires two calls to the decoder to produce stereo. */
|
||||||
|
|
||||||
|
decoded_samples = DecodeNative(inst->decoder_left, encoded, encoded_bytes,
|
||||||
|
kWebRtcOpusMaxFrameSizePerChannel, decoded,
|
||||||
|
audio_type);
|
||||||
|
if (decoded_samples < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (inst->channels == 2) {
|
||||||
|
/* The parameter |decoded_samples| holds the number of samples pairs, in
|
||||||
|
* case of stereo. Number of samples in |decoded| equals |decoded_samples|
|
||||||
|
* times 2. */
|
||||||
|
for (i = 0; i < decoded_samples; i++) {
|
||||||
|
/* Take every second sample, starting at the first sample. This gives
|
||||||
|
* the left channel. */
|
||||||
|
decoded[i] = decoded[i * 2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Update decoded sample memory, to be used by the PLC in case of losses. */
|
||||||
|
inst->prev_decoded_samples = decoded_samples;
|
||||||
|
|
||||||
|
return decoded_samples;
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t WebRtcOpus_DecodeSlave(OpusDecInst* inst, const uint8_t* encoded,
|
||||||
|
int16_t encoded_bytes, int16_t* decoded,
|
||||||
|
int16_t* audio_type) {
|
||||||
|
int decoded_samples;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
decoded_samples = DecodeNative(inst->decoder_right, encoded, encoded_bytes,
|
||||||
|
kWebRtcOpusMaxFrameSizePerChannel, decoded,
|
||||||
|
audio_type);
|
||||||
|
if (decoded_samples < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (inst->channels == 2) {
|
||||||
|
/* The parameter |decoded_samples| holds the number of samples pairs, in
|
||||||
|
* case of stereo. Number of samples in |decoded| equals |decoded_samples|
|
||||||
|
* times 2. */
|
||||||
|
for (i = 0; i < decoded_samples; i++) {
|
||||||
|
/* Take every second sample, starting at the second sample. This gives
|
||||||
|
* the right channel. */
|
||||||
|
decoded[i] = decoded[i * 2 + 1];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Decode slave should never be called for mono packets. */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return decoded_samples;
|
||||||
|
}
|
||||||
|
|
||||||
int16_t WebRtcOpus_DecodePlc(OpusDecInst* inst, int16_t* decoded,
|
int16_t WebRtcOpus_DecodePlc(OpusDecInst* inst, int16_t* decoded,
|
||||||
int16_t number_of_lost_frames) {
|
int16_t number_of_lost_frames) {
|
||||||
int16_t audio_type = 0;
|
int16_t audio_type = 0;
|
||||||
@ -264,7 +351,7 @@ int16_t WebRtcOpus_DecodePlc(OpusDecInst* inst, int16_t* decoded,
|
|||||||
plc_samples = number_of_lost_frames * inst->prev_decoded_samples;
|
plc_samples = number_of_lost_frames * inst->prev_decoded_samples;
|
||||||
plc_samples = (plc_samples <= kWebRtcOpusMaxFrameSizePerChannel) ?
|
plc_samples = (plc_samples <= kWebRtcOpusMaxFrameSizePerChannel) ?
|
||||||
plc_samples : kWebRtcOpusMaxFrameSizePerChannel;
|
plc_samples : kWebRtcOpusMaxFrameSizePerChannel;
|
||||||
decoded_samples = DecodeNative(inst->decoder, NULL, 0, plc_samples,
|
decoded_samples = DecodeNative(inst->decoder_left, NULL, 0, plc_samples,
|
||||||
decoded, &audio_type);
|
decoded, &audio_type);
|
||||||
if (decoded_samples < 0) {
|
if (decoded_samples < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -273,6 +360,82 @@ int16_t WebRtcOpus_DecodePlc(OpusDecInst* inst, int16_t* decoded,
|
|||||||
return decoded_samples;
|
return decoded_samples;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16_t WebRtcOpus_DecodePlcMaster(OpusDecInst* inst, int16_t* decoded,
|
||||||
|
int16_t number_of_lost_frames) {
|
||||||
|
int decoded_samples;
|
||||||
|
int16_t audio_type = 0;
|
||||||
|
int plc_samples;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* If mono case, just do a regular call to the decoder.
|
||||||
|
* If stereo, call to WebRtcOpus_DecodePlcMaster() gives left channel as
|
||||||
|
* output, and calls to WebRtcOpus_DecodePlcSlave() give right channel as
|
||||||
|
* output. This is to make stereo work with the current setup of NetEQ, which
|
||||||
|
* requires two calls to the decoder to produce stereo. */
|
||||||
|
|
||||||
|
/* The number of samples we ask for is |number_of_lost_frames| times
|
||||||
|
* |prev_decoded_samples_|. Limit the number of samples to maximum
|
||||||
|
* |kWebRtcOpusMaxFrameSizePerChannel|. */
|
||||||
|
plc_samples = number_of_lost_frames * inst->prev_decoded_samples;
|
||||||
|
plc_samples = (plc_samples <= kWebRtcOpusMaxFrameSizePerChannel) ?
|
||||||
|
plc_samples : kWebRtcOpusMaxFrameSizePerChannel;
|
||||||
|
decoded_samples = DecodeNative(inst->decoder_left, NULL, 0, plc_samples,
|
||||||
|
decoded, &audio_type);
|
||||||
|
if (decoded_samples < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inst->channels == 2) {
|
||||||
|
/* The parameter |decoded_samples| holds the number of sample pairs, in
|
||||||
|
* case of stereo. The original number of samples in |decoded| equals
|
||||||
|
* |decoded_samples| times 2. */
|
||||||
|
for (i = 0; i < decoded_samples; i++) {
|
||||||
|
/* Take every second sample, starting at the first sample. This gives
|
||||||
|
* the left channel. */
|
||||||
|
decoded[i] = decoded[i * 2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return decoded_samples;
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t WebRtcOpus_DecodePlcSlave(OpusDecInst* inst, int16_t* decoded,
|
||||||
|
int16_t number_of_lost_frames) {
|
||||||
|
int decoded_samples;
|
||||||
|
int16_t audio_type = 0;
|
||||||
|
int plc_samples;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Calls to WebRtcOpus_DecodePlcSlave() give right channel as output.
|
||||||
|
* The function should never be called in the mono case. */
|
||||||
|
if (inst->channels != 2) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The number of samples we ask for is |number_of_lost_frames| times
|
||||||
|
* |prev_decoded_samples_|. Limit the number of samples to maximum
|
||||||
|
* |kWebRtcOpusMaxFrameSizePerChannel|. */
|
||||||
|
plc_samples = number_of_lost_frames * inst->prev_decoded_samples;
|
||||||
|
plc_samples = (plc_samples <= kWebRtcOpusMaxFrameSizePerChannel)
|
||||||
|
? plc_samples : kWebRtcOpusMaxFrameSizePerChannel;
|
||||||
|
decoded_samples = DecodeNative(inst->decoder_right, NULL, 0, plc_samples,
|
||||||
|
decoded, &audio_type);
|
||||||
|
if (decoded_samples < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The parameter |decoded_samples| holds the number of sample pairs,
|
||||||
|
* The original number of samples in |decoded| equals |decoded_samples|
|
||||||
|
* times 2. */
|
||||||
|
for (i = 0; i < decoded_samples; i++) {
|
||||||
|
/* Take every second sample, starting at the second sample. This gives
|
||||||
|
* the right channel. */
|
||||||
|
decoded[i] = decoded[i * 2 + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
return decoded_samples;
|
||||||
|
}
|
||||||
|
|
||||||
int16_t WebRtcOpus_DecodeFec(OpusDecInst* inst, const uint8_t* encoded,
|
int16_t WebRtcOpus_DecodeFec(OpusDecInst* inst, const uint8_t* encoded,
|
||||||
int16_t encoded_bytes, int16_t* decoded,
|
int16_t encoded_bytes, int16_t* decoded,
|
||||||
int16_t* audio_type) {
|
int16_t* audio_type) {
|
||||||
@ -285,7 +448,7 @@ int16_t WebRtcOpus_DecodeFec(OpusDecInst* inst, const uint8_t* encoded,
|
|||||||
|
|
||||||
fec_samples = opus_packet_get_samples_per_frame(encoded, 48000);
|
fec_samples = opus_packet_get_samples_per_frame(encoded, 48000);
|
||||||
|
|
||||||
decoded_samples = DecodeFec(inst->decoder, encoded, encoded_bytes,
|
decoded_samples = DecodeFec(inst->decoder_left, encoded, encoded_bytes,
|
||||||
fec_samples, decoded, audio_type);
|
fec_samples, decoded, audio_type);
|
||||||
if (decoded_samples < 0) {
|
if (decoded_samples < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -72,8 +72,8 @@ float OpusSpeedTest::DecodeABlock(const uint8_t* bit_stream,
|
|||||||
int value;
|
int value;
|
||||||
int16_t audio_type;
|
int16_t audio_type;
|
||||||
clock_t clocks = clock();
|
clock_t clocks = clock();
|
||||||
value = WebRtcOpus_Decode(opus_decoder_, bit_stream, encoded_bytes, out_data,
|
value = WebRtcOpus_DecodeNew(opus_decoder_, bit_stream, encoded_bytes,
|
||||||
&audio_type);
|
out_data, &audio_type);
|
||||||
clocks = clock() - clocks;
|
clocks = clock() - clocks;
|
||||||
EXPECT_EQ(output_length_sample_, value);
|
EXPECT_EQ(output_length_sample_, value);
|
||||||
return 1000.0 * clocks / CLOCKS_PER_SEC;
|
return 1000.0 * clocks / CLOCKS_PER_SEC;
|
||||||
|
@ -35,7 +35,9 @@ class OpusTest : public ::testing::Test {
|
|||||||
WebRtcOpusEncInst* opus_mono_encoder_;
|
WebRtcOpusEncInst* opus_mono_encoder_;
|
||||||
WebRtcOpusEncInst* opus_stereo_encoder_;
|
WebRtcOpusEncInst* opus_stereo_encoder_;
|
||||||
WebRtcOpusDecInst* opus_mono_decoder_;
|
WebRtcOpusDecInst* opus_mono_decoder_;
|
||||||
|
WebRtcOpusDecInst* opus_mono_decoder_new_;
|
||||||
WebRtcOpusDecInst* opus_stereo_decoder_;
|
WebRtcOpusDecInst* opus_stereo_decoder_;
|
||||||
|
WebRtcOpusDecInst* opus_stereo_decoder_new_;
|
||||||
|
|
||||||
int16_t speech_data_[kOpusMaxFrameSamples];
|
int16_t speech_data_[kOpusMaxFrameSamples];
|
||||||
int16_t output_data_[kOpusMaxFrameSamples];
|
int16_t output_data_[kOpusMaxFrameSamples];
|
||||||
@ -46,7 +48,9 @@ OpusTest::OpusTest()
|
|||||||
: opus_mono_encoder_(NULL),
|
: opus_mono_encoder_(NULL),
|
||||||
opus_stereo_encoder_(NULL),
|
opus_stereo_encoder_(NULL),
|
||||||
opus_mono_decoder_(NULL),
|
opus_mono_decoder_(NULL),
|
||||||
opus_stereo_decoder_(NULL) {
|
opus_mono_decoder_new_(NULL),
|
||||||
|
opus_stereo_decoder_(NULL),
|
||||||
|
opus_stereo_decoder_new_(NULL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpusTest::SetUp() {
|
void OpusTest::SetUp() {
|
||||||
@ -113,56 +117,91 @@ TEST_F(OpusTest, OpusEncodeDecodeMono) {
|
|||||||
// Create encoder memory.
|
// Create encoder memory.
|
||||||
EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_mono_encoder_, 1));
|
EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_mono_encoder_, 1));
|
||||||
EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_mono_decoder_, 1));
|
EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_mono_decoder_, 1));
|
||||||
|
EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_mono_decoder_new_, 1));
|
||||||
|
|
||||||
// Set bitrate.
|
// Set bitrate.
|
||||||
EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_mono_encoder_, 32000));
|
EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_mono_encoder_, 32000));
|
||||||
|
|
||||||
// Check number of channels for decoder.
|
// Check number of channels for decoder.
|
||||||
EXPECT_EQ(1, WebRtcOpus_DecoderChannels(opus_mono_decoder_));
|
EXPECT_EQ(1, WebRtcOpus_DecoderChannels(opus_mono_decoder_));
|
||||||
|
EXPECT_EQ(1, WebRtcOpus_DecoderChannels(opus_mono_decoder_new_));
|
||||||
|
|
||||||
// Encode & decode.
|
// Encode & decode.
|
||||||
int16_t encoded_bytes;
|
int16_t encoded_bytes;
|
||||||
int16_t audio_type;
|
int16_t audio_type;
|
||||||
|
int16_t output_data_decode_new[kOpusMaxFrameSamples];
|
||||||
int16_t output_data_decode[kOpusMaxFrameSamples];
|
int16_t output_data_decode[kOpusMaxFrameSamples];
|
||||||
encoded_bytes = WebRtcOpus_Encode(opus_mono_encoder_, speech_data_,
|
encoded_bytes = WebRtcOpus_Encode(opus_mono_encoder_, speech_data_,
|
||||||
kOpus20msFrameSamples, kMaxBytes,
|
kOpus20msFrameSamples, kMaxBytes,
|
||||||
bitstream_);
|
bitstream_);
|
||||||
|
EXPECT_EQ(kOpus20msFrameSamples,
|
||||||
|
WebRtcOpus_DecodeNew(opus_mono_decoder_new_, bitstream_,
|
||||||
|
encoded_bytes, output_data_decode_new,
|
||||||
|
&audio_type));
|
||||||
EXPECT_EQ(kOpus20msFrameSamples,
|
EXPECT_EQ(kOpus20msFrameSamples,
|
||||||
WebRtcOpus_Decode(opus_mono_decoder_, bitstream_,
|
WebRtcOpus_Decode(opus_mono_decoder_, bitstream_,
|
||||||
encoded_bytes, output_data_decode,
|
encoded_bytes, output_data_decode,
|
||||||
&audio_type));
|
&audio_type));
|
||||||
|
|
||||||
|
// Data in |output_data_decode_new| should be the same as in
|
||||||
|
// |output_data_decode|.
|
||||||
|
for (int i = 0; i < kOpus20msFrameSamples; i++) {
|
||||||
|
EXPECT_EQ(output_data_decode_new[i], output_data_decode[i]);
|
||||||
|
}
|
||||||
|
|
||||||
// Free memory.
|
// Free memory.
|
||||||
EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_mono_encoder_));
|
EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_mono_encoder_));
|
||||||
EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_mono_decoder_));
|
EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_mono_decoder_));
|
||||||
|
EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_mono_decoder_new_));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(OpusTest, OpusEncodeDecodeStereo) {
|
TEST_F(OpusTest, OpusEncodeDecodeStereo) {
|
||||||
// Create encoder memory.
|
// Create encoder memory.
|
||||||
EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_stereo_encoder_, 2));
|
EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_stereo_encoder_, 2));
|
||||||
EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_stereo_decoder_, 2));
|
EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_stereo_decoder_, 2));
|
||||||
|
EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_stereo_decoder_new_, 2));
|
||||||
|
|
||||||
// Set bitrate.
|
// Set bitrate.
|
||||||
EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_stereo_encoder_, 64000));
|
EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_stereo_encoder_, 64000));
|
||||||
|
|
||||||
// Check number of channels for decoder.
|
// Check number of channels for decoder.
|
||||||
EXPECT_EQ(2, WebRtcOpus_DecoderChannels(opus_stereo_decoder_));
|
EXPECT_EQ(2, WebRtcOpus_DecoderChannels(opus_stereo_decoder_));
|
||||||
|
EXPECT_EQ(2, WebRtcOpus_DecoderChannels(opus_stereo_decoder_new_));
|
||||||
|
|
||||||
// Encode & decode.
|
// Encode & decode.
|
||||||
int16_t encoded_bytes;
|
int16_t encoded_bytes;
|
||||||
int16_t audio_type;
|
int16_t audio_type;
|
||||||
|
int16_t output_data_decode_new[kOpusMaxFrameSamples];
|
||||||
int16_t output_data_decode[kOpusMaxFrameSamples];
|
int16_t output_data_decode[kOpusMaxFrameSamples];
|
||||||
|
int16_t output_data_decode_slave[kOpusMaxFrameSamples];
|
||||||
encoded_bytes = WebRtcOpus_Encode(opus_stereo_encoder_, speech_data_,
|
encoded_bytes = WebRtcOpus_Encode(opus_stereo_encoder_, speech_data_,
|
||||||
kOpus20msFrameSamples, kMaxBytes,
|
kOpus20msFrameSamples, kMaxBytes,
|
||||||
bitstream_);
|
bitstream_);
|
||||||
|
EXPECT_EQ(kOpus20msFrameSamples,
|
||||||
|
WebRtcOpus_DecodeNew(opus_stereo_decoder_new_, bitstream_,
|
||||||
|
encoded_bytes, output_data_decode_new,
|
||||||
|
&audio_type));
|
||||||
EXPECT_EQ(kOpus20msFrameSamples,
|
EXPECT_EQ(kOpus20msFrameSamples,
|
||||||
WebRtcOpus_Decode(opus_stereo_decoder_, bitstream_,
|
WebRtcOpus_Decode(opus_stereo_decoder_, bitstream_,
|
||||||
encoded_bytes, output_data_decode,
|
encoded_bytes, output_data_decode,
|
||||||
&audio_type));
|
&audio_type));
|
||||||
|
EXPECT_EQ(kOpus20msFrameSamples,
|
||||||
|
WebRtcOpus_DecodeSlave(opus_stereo_decoder_, bitstream_,
|
||||||
|
encoded_bytes, output_data_decode_slave,
|
||||||
|
&audio_type));
|
||||||
|
|
||||||
|
// Data in |output_data_decode_new| should be the same as in
|
||||||
|
// |output_data_decode| and |output_data_decode_slave| interleaved to a
|
||||||
|
// stereo signal.
|
||||||
|
for (int i = 0; i < kOpus20msFrameSamples; i++) {
|
||||||
|
EXPECT_EQ(output_data_decode_new[i * 2], output_data_decode[i]);
|
||||||
|
EXPECT_EQ(output_data_decode_new[i * 2 + 1], output_data_decode_slave[i]);
|
||||||
|
}
|
||||||
|
|
||||||
// Free memory.
|
// Free memory.
|
||||||
EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_stereo_encoder_));
|
EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_stereo_encoder_));
|
||||||
EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_stereo_decoder_));
|
EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_stereo_decoder_));
|
||||||
|
EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_stereo_decoder_new_));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(OpusTest, OpusSetBitRate) {
|
TEST_F(OpusTest, OpusSetBitRate) {
|
||||||
@ -210,30 +249,67 @@ TEST_F(OpusTest, OpusDecodeInit) {
|
|||||||
// Create encoder memory.
|
// Create encoder memory.
|
||||||
EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_stereo_encoder_, 2));
|
EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_stereo_encoder_, 2));
|
||||||
EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_stereo_decoder_, 2));
|
EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_stereo_decoder_, 2));
|
||||||
|
EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_stereo_decoder_new_, 2));
|
||||||
|
|
||||||
// Encode & decode.
|
// Encode & decode.
|
||||||
int16_t encoded_bytes;
|
int16_t encoded_bytes;
|
||||||
int16_t audio_type;
|
int16_t audio_type;
|
||||||
|
int16_t output_data_decode_new[kOpusMaxFrameSamples];
|
||||||
int16_t output_data_decode[kOpusMaxFrameSamples];
|
int16_t output_data_decode[kOpusMaxFrameSamples];
|
||||||
|
int16_t output_data_decode_slave[kOpusMaxFrameSamples];
|
||||||
encoded_bytes = WebRtcOpus_Encode(opus_stereo_encoder_, speech_data_,
|
encoded_bytes = WebRtcOpus_Encode(opus_stereo_encoder_, speech_data_,
|
||||||
kOpus20msFrameSamples, kMaxBytes,
|
kOpus20msFrameSamples, kMaxBytes,
|
||||||
bitstream_);
|
bitstream_);
|
||||||
EXPECT_EQ(kOpus20msFrameSamples,
|
EXPECT_EQ(kOpus20msFrameSamples,
|
||||||
WebRtcOpus_Decode(opus_stereo_decoder_, bitstream_,
|
WebRtcOpus_DecodeNew(opus_stereo_decoder_new_, bitstream_,
|
||||||
encoded_bytes, output_data_decode,
|
encoded_bytes, output_data_decode_new,
|
||||||
&audio_type));
|
&audio_type));
|
||||||
|
|
||||||
EXPECT_EQ(0, WebRtcOpus_DecoderInit(opus_stereo_decoder_));
|
|
||||||
|
|
||||||
EXPECT_EQ(kOpus20msFrameSamples,
|
EXPECT_EQ(kOpus20msFrameSamples,
|
||||||
WebRtcOpus_Decode(opus_stereo_decoder_, bitstream_,
|
WebRtcOpus_Decode(opus_stereo_decoder_, bitstream_,
|
||||||
encoded_bytes, output_data_decode,
|
encoded_bytes, output_data_decode,
|
||||||
&audio_type));
|
&audio_type));
|
||||||
|
EXPECT_EQ(kOpus20msFrameSamples,
|
||||||
|
WebRtcOpus_DecodeSlave(opus_stereo_decoder_, bitstream_,
|
||||||
|
encoded_bytes, output_data_decode_slave,
|
||||||
|
&audio_type));
|
||||||
|
|
||||||
|
// Data in |output_data_decode_new| should be the same as in
|
||||||
|
// |output_data_decode| and |output_data_decode_slave| interleaved to a
|
||||||
|
// stereo signal.
|
||||||
|
for (int i = 0; i < kOpus20msFrameSamples; i++) {
|
||||||
|
EXPECT_EQ(output_data_decode_new[i * 2], output_data_decode[i]);
|
||||||
|
EXPECT_EQ(output_data_decode_new[i * 2 + 1], output_data_decode_slave[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPECT_EQ(0, WebRtcOpus_DecoderInitNew(opus_stereo_decoder_new_));
|
||||||
|
EXPECT_EQ(0, WebRtcOpus_DecoderInit(opus_stereo_decoder_));
|
||||||
|
EXPECT_EQ(0, WebRtcOpus_DecoderInitSlave(opus_stereo_decoder_));
|
||||||
|
|
||||||
|
EXPECT_EQ(kOpus20msFrameSamples,
|
||||||
|
WebRtcOpus_DecodeNew(opus_stereo_decoder_new_, bitstream_,
|
||||||
|
encoded_bytes, output_data_decode_new,
|
||||||
|
&audio_type));
|
||||||
|
EXPECT_EQ(kOpus20msFrameSamples,
|
||||||
|
WebRtcOpus_Decode(opus_stereo_decoder_, bitstream_,
|
||||||
|
encoded_bytes, output_data_decode,
|
||||||
|
&audio_type));
|
||||||
|
EXPECT_EQ(kOpus20msFrameSamples,
|
||||||
|
WebRtcOpus_DecodeSlave(opus_stereo_decoder_, bitstream_,
|
||||||
|
encoded_bytes, output_data_decode_slave,
|
||||||
|
&audio_type));
|
||||||
|
|
||||||
|
// Data in |output_data_decode_new| should be the same as in
|
||||||
|
// |output_data_decode| and |output_data_decode_slave| interleaved to a
|
||||||
|
// stereo signal.
|
||||||
|
for (int i = 0; i < kOpus20msFrameSamples; i++) {
|
||||||
|
EXPECT_EQ(output_data_decode_new[i * 2], output_data_decode[i]);
|
||||||
|
EXPECT_EQ(output_data_decode_new[i * 2 + 1], output_data_decode_slave[i]);
|
||||||
|
}
|
||||||
|
|
||||||
// Free memory.
|
// Free memory.
|
||||||
EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_stereo_encoder_));
|
EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_stereo_encoder_));
|
||||||
EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_stereo_decoder_));
|
EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_stereo_decoder_));
|
||||||
|
EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_stereo_decoder_new_));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(OpusTest, OpusEnableDisableFec) {
|
TEST_F(OpusTest, OpusEnableDisableFec) {
|
||||||
@ -306,33 +382,49 @@ TEST_F(OpusTest, OpusDecodePlcMono) {
|
|||||||
// Create encoder memory.
|
// Create encoder memory.
|
||||||
EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_mono_encoder_, 1));
|
EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_mono_encoder_, 1));
|
||||||
EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_mono_decoder_, 1));
|
EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_mono_decoder_, 1));
|
||||||
|
EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_mono_decoder_new_, 1));
|
||||||
|
|
||||||
// Set bitrate.
|
// Set bitrate.
|
||||||
EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_mono_encoder_, 32000));
|
EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_mono_encoder_, 32000));
|
||||||
|
|
||||||
// Check number of channels for decoder.
|
// Check number of channels for decoder.
|
||||||
EXPECT_EQ(1, WebRtcOpus_DecoderChannels(opus_mono_decoder_));
|
EXPECT_EQ(1, WebRtcOpus_DecoderChannels(opus_mono_decoder_));
|
||||||
|
EXPECT_EQ(1, WebRtcOpus_DecoderChannels(opus_mono_decoder_new_));
|
||||||
|
|
||||||
// Encode & decode.
|
// Encode & decode.
|
||||||
int16_t encoded_bytes;
|
int16_t encoded_bytes;
|
||||||
int16_t audio_type;
|
int16_t audio_type;
|
||||||
|
int16_t output_data_decode_new[kOpusMaxFrameSamples];
|
||||||
int16_t output_data_decode[kOpusMaxFrameSamples];
|
int16_t output_data_decode[kOpusMaxFrameSamples];
|
||||||
encoded_bytes = WebRtcOpus_Encode(opus_mono_encoder_, speech_data_,
|
encoded_bytes = WebRtcOpus_Encode(opus_mono_encoder_, speech_data_,
|
||||||
kOpus20msFrameSamples, kMaxBytes,
|
kOpus20msFrameSamples, kMaxBytes,
|
||||||
bitstream_);
|
bitstream_);
|
||||||
|
EXPECT_EQ(kOpus20msFrameSamples,
|
||||||
|
WebRtcOpus_DecodeNew(opus_mono_decoder_new_, bitstream_,
|
||||||
|
encoded_bytes, output_data_decode_new,
|
||||||
|
&audio_type));
|
||||||
EXPECT_EQ(kOpus20msFrameSamples,
|
EXPECT_EQ(kOpus20msFrameSamples,
|
||||||
WebRtcOpus_Decode(opus_mono_decoder_, bitstream_,
|
WebRtcOpus_Decode(opus_mono_decoder_, bitstream_,
|
||||||
encoded_bytes, output_data_decode,
|
encoded_bytes, output_data_decode,
|
||||||
&audio_type));
|
&audio_type));
|
||||||
|
|
||||||
// Call decoder PLC.
|
// Call decoder PLC for both versions of the decoder.
|
||||||
int16_t plc_buffer[kOpusMaxFrameSamples];
|
int16_t plc_buffer[kOpusMaxFrameSamples];
|
||||||
|
int16_t plc_buffer_new[kOpusMaxFrameSamples];
|
||||||
EXPECT_EQ(kOpus20msFrameSamples,
|
EXPECT_EQ(kOpus20msFrameSamples,
|
||||||
WebRtcOpus_DecodePlc(opus_mono_decoder_, plc_buffer, 1));
|
WebRtcOpus_DecodePlcMaster(opus_mono_decoder_, plc_buffer, 1));
|
||||||
|
EXPECT_EQ(kOpus20msFrameSamples,
|
||||||
|
WebRtcOpus_DecodePlc(opus_mono_decoder_new_, plc_buffer_new, 1));
|
||||||
|
|
||||||
|
// Data in |plc_buffer| should be the same as in |plc_buffer_new|.
|
||||||
|
for (int i = 0; i < kOpus20msFrameSamples; i++) {
|
||||||
|
EXPECT_EQ(plc_buffer[i], plc_buffer_new[i]);
|
||||||
|
}
|
||||||
|
|
||||||
// Free memory.
|
// Free memory.
|
||||||
EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_mono_encoder_));
|
EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_mono_encoder_));
|
||||||
EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_mono_decoder_));
|
EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_mono_decoder_));
|
||||||
|
EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_mono_decoder_new_));
|
||||||
}
|
}
|
||||||
|
|
||||||
// PLC in stereo mode.
|
// PLC in stereo mode.
|
||||||
@ -340,33 +432,61 @@ TEST_F(OpusTest, OpusDecodePlcStereo) {
|
|||||||
// Create encoder memory.
|
// Create encoder memory.
|
||||||
EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_stereo_encoder_, 2));
|
EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_stereo_encoder_, 2));
|
||||||
EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_stereo_decoder_, 2));
|
EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_stereo_decoder_, 2));
|
||||||
|
EXPECT_EQ(0, WebRtcOpus_DecoderCreate(&opus_stereo_decoder_new_, 2));
|
||||||
|
|
||||||
// Set bitrate.
|
// Set bitrate.
|
||||||
EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_stereo_encoder_, 64000));
|
EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_stereo_encoder_, 64000));
|
||||||
|
|
||||||
// Check number of channels for decoder.
|
// Check number of channels for decoder.
|
||||||
EXPECT_EQ(2, WebRtcOpus_DecoderChannels(opus_stereo_decoder_));
|
EXPECT_EQ(2, WebRtcOpus_DecoderChannels(opus_stereo_decoder_));
|
||||||
|
EXPECT_EQ(2, WebRtcOpus_DecoderChannels(opus_stereo_decoder_new_));
|
||||||
|
|
||||||
// Encode & decode.
|
// Encode & decode.
|
||||||
int16_t encoded_bytes;
|
int16_t encoded_bytes;
|
||||||
int16_t audio_type;
|
int16_t audio_type;
|
||||||
|
int16_t output_data_decode_new[kOpusMaxFrameSamples];
|
||||||
int16_t output_data_decode[kOpusMaxFrameSamples];
|
int16_t output_data_decode[kOpusMaxFrameSamples];
|
||||||
|
int16_t output_data_decode_slave[kOpusMaxFrameSamples];
|
||||||
encoded_bytes = WebRtcOpus_Encode(opus_stereo_encoder_, speech_data_,
|
encoded_bytes = WebRtcOpus_Encode(opus_stereo_encoder_, speech_data_,
|
||||||
kOpus20msFrameSamples, kMaxBytes,
|
kOpus20msFrameSamples, kMaxBytes,
|
||||||
bitstream_);
|
bitstream_);
|
||||||
|
EXPECT_EQ(kOpus20msFrameSamples,
|
||||||
|
WebRtcOpus_DecodeNew(opus_stereo_decoder_new_, bitstream_,
|
||||||
|
encoded_bytes, output_data_decode_new,
|
||||||
|
&audio_type));
|
||||||
EXPECT_EQ(kOpus20msFrameSamples,
|
EXPECT_EQ(kOpus20msFrameSamples,
|
||||||
WebRtcOpus_Decode(opus_stereo_decoder_, bitstream_,
|
WebRtcOpus_Decode(opus_stereo_decoder_, bitstream_,
|
||||||
encoded_bytes, output_data_decode,
|
encoded_bytes, output_data_decode,
|
||||||
&audio_type));
|
&audio_type));
|
||||||
|
|
||||||
// Call decoder PLC.
|
|
||||||
int16_t plc_buffer[kOpusMaxFrameSamples];
|
|
||||||
EXPECT_EQ(kOpus20msFrameSamples,
|
EXPECT_EQ(kOpus20msFrameSamples,
|
||||||
WebRtcOpus_DecodePlc(opus_stereo_decoder_, plc_buffer, 1));
|
WebRtcOpus_DecodeSlave(opus_stereo_decoder_, bitstream_,
|
||||||
|
encoded_bytes,
|
||||||
|
output_data_decode_slave,
|
||||||
|
&audio_type));
|
||||||
|
|
||||||
|
// Call decoder PLC for both versions of the decoder.
|
||||||
|
int16_t plc_buffer_left[kOpusMaxFrameSamples];
|
||||||
|
int16_t plc_buffer_right[kOpusMaxFrameSamples];
|
||||||
|
int16_t plc_buffer_new[kOpusMaxFrameSamples];
|
||||||
|
EXPECT_EQ(kOpus20msFrameSamples,
|
||||||
|
WebRtcOpus_DecodePlcMaster(opus_stereo_decoder_,
|
||||||
|
plc_buffer_left, 1));
|
||||||
|
EXPECT_EQ(kOpus20msFrameSamples,
|
||||||
|
WebRtcOpus_DecodePlcSlave(opus_stereo_decoder_,
|
||||||
|
plc_buffer_right, 1));
|
||||||
|
EXPECT_EQ(kOpus20msFrameSamples,
|
||||||
|
WebRtcOpus_DecodePlc(opus_stereo_decoder_new_, plc_buffer_new, 1));
|
||||||
|
// Data in |plc_buffer_left| and |plc_buffer_right|should be the same as the
|
||||||
|
// interleaved samples in |plc_buffer_new|.
|
||||||
|
for (int i = 0, j = 0; i < kOpus20msFrameSamples; i++) {
|
||||||
|
EXPECT_EQ(plc_buffer_left[i], plc_buffer_new[j++]);
|
||||||
|
EXPECT_EQ(plc_buffer_right[i], plc_buffer_new[j++]);
|
||||||
|
}
|
||||||
|
|
||||||
// Free memory.
|
// Free memory.
|
||||||
EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_stereo_encoder_));
|
EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_stereo_encoder_));
|
||||||
EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_stereo_decoder_));
|
EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_stereo_decoder_));
|
||||||
|
EXPECT_EQ(0, WebRtcOpus_DecoderFree(opus_stereo_decoder_new_));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Duration estimation.
|
// Duration estimation.
|
||||||
|
@ -85,8 +85,8 @@ void OpusTest::Perform() {
|
|||||||
// Create Opus decoders for mono and stereo for stand-alone testing of Opus.
|
// Create Opus decoders for mono and stereo for stand-alone testing of Opus.
|
||||||
ASSERT_GT(WebRtcOpus_DecoderCreate(&opus_mono_decoder_, 1), -1);
|
ASSERT_GT(WebRtcOpus_DecoderCreate(&opus_mono_decoder_, 1), -1);
|
||||||
ASSERT_GT(WebRtcOpus_DecoderCreate(&opus_stereo_decoder_, 2), -1);
|
ASSERT_GT(WebRtcOpus_DecoderCreate(&opus_stereo_decoder_, 2), -1);
|
||||||
ASSERT_GT(WebRtcOpus_DecoderInit(opus_mono_decoder_), -1);
|
ASSERT_GT(WebRtcOpus_DecoderInitNew(opus_mono_decoder_), -1);
|
||||||
ASSERT_GT(WebRtcOpus_DecoderInit(opus_stereo_decoder_), -1);
|
ASSERT_GT(WebRtcOpus_DecoderInitNew(opus_stereo_decoder_), -1);
|
||||||
|
|
||||||
ASSERT_TRUE(acm_receiver_.get() != NULL);
|
ASSERT_TRUE(acm_receiver_.get() != NULL);
|
||||||
EXPECT_EQ(0, acm_receiver_->InitializeReceiver());
|
EXPECT_EQ(0, acm_receiver_->InitializeReceiver());
|
||||||
@ -304,7 +304,7 @@ void OpusTest::Run(TestPackStereo* channel, int channels, int bitrate,
|
|||||||
// Run stand-alone Opus decoder, or decode PLC.
|
// Run stand-alone Opus decoder, or decode PLC.
|
||||||
if (channels == 1) {
|
if (channels == 1) {
|
||||||
if (!lost_packet) {
|
if (!lost_packet) {
|
||||||
decoded_samples += WebRtcOpus_Decode(
|
decoded_samples += WebRtcOpus_DecodeNew(
|
||||||
opus_mono_decoder_, bitstream, bitstream_len_byte,
|
opus_mono_decoder_, bitstream, bitstream_len_byte,
|
||||||
&out_audio[decoded_samples * channels], &audio_type);
|
&out_audio[decoded_samples * channels], &audio_type);
|
||||||
} else {
|
} else {
|
||||||
@ -313,7 +313,7 @@ void OpusTest::Run(TestPackStereo* channel, int channels, int bitrate,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!lost_packet) {
|
if (!lost_packet) {
|
||||||
decoded_samples += WebRtcOpus_Decode(
|
decoded_samples += WebRtcOpus_DecodeNew(
|
||||||
opus_stereo_decoder_, bitstream, bitstream_len_byte,
|
opus_stereo_decoder_, bitstream, bitstream_len_byte,
|
||||||
&out_audio[decoded_samples * channels], &audio_type);
|
&out_audio[decoded_samples * channels], &audio_type);
|
||||||
} else {
|
} else {
|
||||||
|
@ -404,9 +404,9 @@ AudioDecoderOpus::~AudioDecoderOpus() {
|
|||||||
int AudioDecoderOpus::Decode(const uint8_t* encoded, size_t encoded_len,
|
int AudioDecoderOpus::Decode(const uint8_t* encoded, size_t encoded_len,
|
||||||
int16_t* decoded, SpeechType* speech_type) {
|
int16_t* decoded, SpeechType* speech_type) {
|
||||||
int16_t temp_type = 1; // Default is speech.
|
int16_t temp_type = 1; // Default is speech.
|
||||||
int16_t ret = WebRtcOpus_Decode(dec_state_, encoded,
|
int16_t ret = WebRtcOpus_DecodeNew(dec_state_, encoded,
|
||||||
static_cast<int16_t>(encoded_len), decoded,
|
static_cast<int16_t>(encoded_len), decoded,
|
||||||
&temp_type);
|
&temp_type);
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
ret *= static_cast<int16_t>(channels_); // Return total number of samples.
|
ret *= static_cast<int16_t>(channels_); // Return total number of samples.
|
||||||
*speech_type = ConvertSpeechType(temp_type);
|
*speech_type = ConvertSpeechType(temp_type);
|
||||||
@ -427,7 +427,7 @@ int AudioDecoderOpus::DecodeRedundant(const uint8_t* encoded,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int AudioDecoderOpus::Init() {
|
int AudioDecoderOpus::Init() {
|
||||||
return WebRtcOpus_DecoderInit(dec_state_);
|
return WebRtcOpus_DecoderInitNew(dec_state_);
|
||||||
}
|
}
|
||||||
|
|
||||||
int AudioDecoderOpus::PacketDuration(const uint8_t* encoded,
|
int AudioDecoderOpus::PacketDuration(const uint8_t* encoded,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user