cleaning up
This commit is contained in:
parent
ccc988b822
commit
3d3bb68536
3 changed files with 32 additions and 68 deletions
|
@ -143,49 +143,6 @@ void celt_encoder_destroy(CELTEncoder *st)
|
||||||
celt_free(st);
|
celt_free(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void haar1(float *X, int N, int stride)
|
|
||||||
{
|
|
||||||
int i, k;
|
|
||||||
for (k=0;k<stride;k++)
|
|
||||||
{
|
|
||||||
for (i=k;i<N*stride;i+=2*stride)
|
|
||||||
{
|
|
||||||
float a, b;
|
|
||||||
a = X[i];
|
|
||||||
b = X[i+stride];
|
|
||||||
X[i] = .707107f*(a+b);
|
|
||||||
X[i+stride] = .707107f*(a-b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void time_dct(float *X, int N, int B, int stride)
|
|
||||||
{
|
|
||||||
switch (B)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
haar1(X, B*N, stride);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
celt_warning("time_dct not defined for B > 2");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static void time_idct(float *X, int N, int B, int stride)
|
|
||||||
{
|
|
||||||
switch (B)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
haar1(X, B*N, stride);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
celt_warning("time_dct not defined for B > 2");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static void compute_mdcts(mdct_lookup *mdct_lookup, float *window, float *in, float *out, int N, int B, int C)
|
static void compute_mdcts(mdct_lookup *mdct_lookup, float *window, float *in, float *out, int N, int B, int C)
|
||||||
{
|
{
|
||||||
|
@ -234,7 +191,7 @@ static void compute_inv_mdcts(mdct_lookup *mdct_lookup, float *window, float *X,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int celt_encode(CELTEncoder *st, short *pcm, unsigned char *compressed, int nbCompressedBytes)
|
int celt_encode(CELTEncoder *st, celt_int16_t *pcm, unsigned char *compressed, int nbCompressedBytes)
|
||||||
{
|
{
|
||||||
int i, c, N, B, C, N4;
|
int i, c, N, B, C, N4;
|
||||||
N = st->block_size;
|
N = st->block_size;
|
||||||
|
@ -328,9 +285,6 @@ int celt_encode(CELTEncoder *st, short *pcm, unsigned char *compressed, int nbCo
|
||||||
//for (i=30;i<N*B;i++)
|
//for (i=30;i<N*B;i++)
|
||||||
// X[i*C+1] = P[i*C+1] = 0;
|
// X[i*C+1] = P[i*C+1] = 0;
|
||||||
/* Get a tiny bit more frequency resolution and prevent unstable energy when quantising */
|
/* Get a tiny bit more frequency resolution and prevent unstable energy when quantising */
|
||||||
time_dct(X, N, B, C);
|
|
||||||
time_dct(P, N, B, C);
|
|
||||||
|
|
||||||
|
|
||||||
/* Pitch prediction */
|
/* Pitch prediction */
|
||||||
compute_pitch_gain(st->mode, X, P, gains, bandE);
|
compute_pitch_gain(st->mode, X, P, gains, bandE);
|
||||||
|
@ -349,9 +303,7 @@ int celt_encode(CELTEncoder *st, short *pcm, unsigned char *compressed, int nbCo
|
||||||
/* Residual quantisation */
|
/* Residual quantisation */
|
||||||
quant_bands(st->mode, X, P, mask, &st->alloc, nbCompressedBytes*8, &st->enc);
|
quant_bands(st->mode, X, P, mask, &st->alloc, nbCompressedBytes*8, &st->enc);
|
||||||
|
|
||||||
time_idct(X, N, B, C);
|
|
||||||
if (C==2)
|
if (C==2)
|
||||||
//haar1(X, B*N*C, 1);
|
|
||||||
stereo_mix(st->mode, X, bandE, -1);
|
stereo_mix(st->mode, X, bandE, -1);
|
||||||
|
|
||||||
renormalise_bands(st->mode, X);
|
renormalise_bands(st->mode, X);
|
||||||
|
@ -544,7 +496,7 @@ static void celt_decode_lost(CELTDecoder *st, short *pcm)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int celt_decode(CELTDecoder *st, char *data, int len, short *pcm)
|
int celt_decode(CELTDecoder *st, char *data, int len, celt_int16_t *pcm)
|
||||||
{
|
{
|
||||||
int i, c, N, B, C;
|
int i, c, N, B, C;
|
||||||
N = st->block_size;
|
N = st->block_size;
|
||||||
|
@ -585,9 +537,7 @@ int celt_decode(CELTDecoder *st, char *data, int len, short *pcm)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (C==2)
|
if (C==2)
|
||||||
//haar1(P, B*N*C, 1);
|
|
||||||
stereo_mix(st->mode, P, bandE, 1);
|
stereo_mix(st->mode, P, bandE, 1);
|
||||||
time_dct(P, N, B, C);
|
|
||||||
|
|
||||||
/* Get the pitch gains */
|
/* Get the pitch gains */
|
||||||
unquant_pitch(gains, st->mode->nbPBands, &dec);
|
unquant_pitch(gains, st->mode->nbPBands, &dec);
|
||||||
|
@ -598,9 +548,7 @@ int celt_decode(CELTDecoder *st, char *data, int len, short *pcm)
|
||||||
/* Decode fixed codebook and merge with pitch */
|
/* Decode fixed codebook and merge with pitch */
|
||||||
unquant_bands(st->mode, X, P, &st->alloc, len*8, &dec);
|
unquant_bands(st->mode, X, P, &st->alloc, len*8, &dec);
|
||||||
|
|
||||||
time_idct(X, N, B, C);
|
|
||||||
if (C==2)
|
if (C==2)
|
||||||
//haar1(X, B*N*C, 1);
|
|
||||||
stereo_mix(st->mode, X, bandE, -1);
|
stereo_mix(st->mode, X, bandE, -1);
|
||||||
|
|
||||||
renormalise_bands(st->mode, X);
|
renormalise_bands(st->mode, X);
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
#ifndef CELT_H
|
#ifndef CELT_H
|
||||||
#define CELT_H
|
#define CELT_H
|
||||||
|
|
||||||
|
#include "celt_types.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -57,7 +59,7 @@ CELTEncoder *celt_encoder_new(const CELTMode *mode);
|
||||||
|
|
||||||
void celt_encoder_destroy(CELTEncoder *st);
|
void celt_encoder_destroy(CELTEncoder *st);
|
||||||
|
|
||||||
int celt_encode(CELTEncoder *st, short *pcm, unsigned char *compressed, int nbCompressedBytes);
|
int celt_encode(CELTEncoder *st, celt_int16_t *pcm, unsigned char *compressed, int nbCompressedBytes);
|
||||||
|
|
||||||
/* Decoder stuff */
|
/* Decoder stuff */
|
||||||
|
|
||||||
|
@ -65,7 +67,7 @@ CELTDecoder *celt_decoder_new(const CELTMode *mode);
|
||||||
|
|
||||||
void celt_decoder_destroy(CELTDecoder *st);
|
void celt_decoder_destroy(CELTDecoder *st);
|
||||||
|
|
||||||
int celt_decode(CELTDecoder *st, char *data, int len, short *pcm);
|
int celt_decode(CELTDecoder *st, char *data, int len, celt_int16_t *pcm);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,22 +29,36 @@
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef CELT_HEADER_H
|
||||||
|
#define CELT_HEADER_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "celt.h"
|
#include "celt.h"
|
||||||
|
#include "celt_types.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char codec_id[8];
|
char codec_id[8];
|
||||||
char codec_version[20];
|
char codec_version[20];
|
||||||
int version_id;
|
celt_int32_t version_id;
|
||||||
int header_size;
|
celt_int32_t header_size;
|
||||||
int mode;
|
celt_int32_t mode;
|
||||||
int sample_rate;
|
celt_int32_t sample_rate;
|
||||||
int nb_channels;
|
celt_int32_t nb_channels;
|
||||||
int bytes_per_packet;
|
celt_int32_t bytes_per_packet;
|
||||||
int extra_headers;
|
celt_int32_t extra_headers;
|
||||||
} CELTHeader;
|
} CELTHeader;
|
||||||
|
|
||||||
void celt_init_header(CELTHeader *header, int rate, int nb_channels, const struct CELTMode *m);
|
void celt_init_header(CELTHeader *header, celt_int32_t rate, celt_int32_t nb_channels, const struct CELTMode *m);
|
||||||
|
|
||||||
int celt_header_to_packet(const CELTHeader *header, char *packet, int size);
|
int celt_header_to_packet(const CELTHeader *header, char *packet, celt_uint32_t size);
|
||||||
|
|
||||||
int celt_packet_to_header(const char *packet, int size, CELTHeader *header);
|
int celt_packet_to_header(const char *packet, celt_uint32_t size, CELTHeader *header);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CELT_HEADER_H */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue