[opus] How can I use static mode 16k?
吴佳健
j2wzx336 at gmail.com
Thu Dec 17 09:33:59 UTC 2020
Hi,
I want to encode a audio to opus, the audio is 16KHz, 16bits, 1
channel. I use the libopusenc and libopus, and I found the audio will be
resampled to 48KHz first, I want to avoid the resample to save MIPS.
I found a static_mode_list in libopus/celt/static_modes_fixed.h which
only include mode48000_960_120, I generate another mode
called mode16000_320_40 by libopus/celt/dump_modes/dump_modes.c, and do
some modify in code like follows:
--- a/celt/celt_encoder.c
+++ b/celt/celt_encoder.c
@@ -128,9 +128,10 @@ struct OpusCustomEncoder {
/* opus_val16 energyError[], Size = channels*mode->nbEBands */
};
-__sys__ int celt_encoder_get_size(int channels)
+__sys__ int celt_encoder_get_size(opus_int32 Fs, int channels)
{
- CELTMode *mode = opus_custom_mode_create(48000, 960, NULL);
+ opus_int32 rate = (Fs == 16000) ? Fs : 48000;
+ CELTMode *mode = opus_custom_mode_create(rate, rate / 50, NULL);
return opus_custom_encoder_get_size(mode, channels);
}
These are only apart of my modify, I also remove the resample in
opusenc.c .
The output sounds like it works but the amplitude has be changed.Am I
do it wrong?
[image: image.png]
Bset Regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xiph.org/pipermail/opus/attachments/20201217/68dc8183/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 18513 bytes
Desc: not available
URL: <http://lists.xiph.org/pipermail/opus/attachments/20201217/68dc8183/attachment-0001.png>
More information about the opus
mailing list