This is a setup to solve

https://code.google.com/p/webrtc/issues/detail?id=1906

In particular, we add an API to call Opus's set maximum bandwidth to prevent the encoder from coding audio content beyond this bandwidth so as to increase computation and transmission efficiency (without affecting sampling rate).

BUG=
R=henrik.lundin@webrtc.org, turaj@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6817 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
minyue@webrtc.org
2014-08-04 14:41:57 +00:00
parent 84b9e1e9d9
commit 0040a6ef97
5 changed files with 110 additions and 16 deletions

View File

@ -9,12 +9,11 @@
*/
#include "webrtc/modules/audio_coding/codecs/opus/interface/opus_interface.h"
#include "webrtc/modules/audio_coding/codecs/opus/opus_inst.h"
#include <stdlib.h>
#include <string.h>
#include "opus.h"
enum {
/* Maximum supported frame size in WebRTC is 60 ms. */
kWebRtcOpusMaxEncodeFrameSizeMs = 60,
@ -32,10 +31,6 @@ enum {
kWebRtcOpusDefaultFrameSize = 960,
};
struct WebRtcOpusEncInst {
OpusEncoder* encoder;
};
int16_t WebRtcOpus_EncoderCreate(OpusEncInst** inst, int32_t channels) {
OpusEncInst* state;
if (inst != NULL) {
@ -104,6 +99,27 @@ int16_t WebRtcOpus_SetPacketLossRate(OpusEncInst* inst, int32_t loss_rate) {
}
}
int16_t WebRtcOpus_SetMaxBandwidth(OpusEncInst* inst, int32_t bandwidth) {
opus_int32 set_bandwidth;
if (!inst)
return -1;
if (bandwidth <= 4000) {
set_bandwidth = OPUS_BANDWIDTH_NARROWBAND;
} else if (bandwidth <= 6000) {
set_bandwidth = OPUS_BANDWIDTH_MEDIUMBAND;
} else if (bandwidth <= 8000) {
set_bandwidth = OPUS_BANDWIDTH_WIDEBAND;
} else if (bandwidth <= 12000) {
set_bandwidth = OPUS_BANDWIDTH_SUPERWIDEBAND;
} else {
set_bandwidth = OPUS_BANDWIDTH_FULLBAND;
}
return opus_encoder_ctl(inst->encoder,
OPUS_SET_MAX_BANDWIDTH(set_bandwidth));
}
int16_t WebRtcOpus_EnableFec(OpusEncInst* inst) {
if (inst) {
return opus_encoder_ctl(inst->encoder, OPUS_SET_INBAND_FEC(1));
@ -128,13 +144,6 @@ int16_t WebRtcOpus_SetComplexity(OpusEncInst* inst, int32_t complexity) {
}
}
struct WebRtcOpusDecInst {
OpusDecoder* decoder_left;
OpusDecoder* decoder_right;
int prev_decoded_samples;
int channels;
};
int16_t WebRtcOpus_DecoderCreate(OpusDecInst** inst, int channels) {
int error_l;
int error_r;