1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
// Copyright 2005-2016 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
#include "mumble_pch.hpp"
#include "CELTCodec.h"
#include "Audio.h"
#include "Version.h"
CELTCodec::CELTCodec(const QString &version) {
bValid = true;
cmMode = NULL;
qsVersion = version;
iBitstreamVersion = INT_MIN;
this->celt_encoder_destroy = ::celt_encoder_destroy;
this->celt_encoder_ctl = ::celt_encoder_ctl;
this->celt_decoder_destroy = ::celt_decoder_destroy;
this->celt_decoder_ctl = ::celt_decoder_ctl;
}
CELTCodec::~CELTCodec() {
if (cmMode)
::celt_mode_destroy(const_cast<CELTMode *>(cmMode));
}
bool CELTCodec::isValid() const {
return bValid;
}
int CELTCodec::bitstreamVersion() const {
if (cmMode && iBitstreamVersion == INT_MIN)
::celt_mode_info(cmMode, CELT_GET_BITSTREAM_VERSION, reinterpret_cast<celt_int32 *>(&iBitstreamVersion));
return iBitstreamVersion;
}
QString CELTCodec::version() const {
return qsVersion;
}
void CELTCodec::report() const {
qWarning("CELT bitstream %08x from internal CELT with SBCELT decoding", bitstreamVersion());
}
CELTCodecSBCELT::CELTCodecSBCELT() : CELTCodec(QLatin1String("0.7.0")) {
if (bValid) {
cmMode = ::celt_mode_create(SAMPLE_RATE, SAMPLE_RATE / 100, NULL);
cmSBCELTMode = ::sbcelt_mode_create(SAMPLE_RATE, SAMPLE_RATE / 100, NULL);
this->celt_decoder_destroy = ::sbcelt_decoder_destroy;
this->celt_decoder_ctl = ::sbcelt_decoder_ctl;
}
}
CELTEncoder *CELTCodecSBCELT::encoderCreate() {
return ::celt_encoder_create(cmMode, 1, NULL);
}
CELTDecoder *CELTCodecSBCELT::decoderCreate() {
return ::sbcelt_decoder_create(cmSBCELTMode, 1, NULL);
}
int CELTCodecSBCELT::encode(CELTEncoder *st, const celt_int16 *pcm, unsigned char *compressed, int nbCompressedBytes) {
return ::celt_encode(st, pcm, NULL, compressed, nbCompressedBytes);
}
int CELTCodecSBCELT::decode_float(CELTDecoder *st, const unsigned char *data, int len, float *pcm) {
return ::sbcelt_decode_float(st, data, len, pcm);
}
|