Using OPUS_ macros for <string.h> operations
Removes a bunch of system #include <...> in the process
This commit is contained in:
parent
382cad43ce
commit
be89c39587
10 changed files with 78 additions and 82 deletions
|
@ -115,6 +115,7 @@ static int resampling_factor(opus_int32 rate)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -248,7 +249,7 @@ CELTEncoder *celt_encoder_init_custom(CELTEncoder *st, const CELTMode *mode, int
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CELT_MEMSET((char*)st, 0, celt_encoder_get_size_custom(mode, channels));
|
OPUS_CLEAR((char*)st, celt_encoder_get_size_custom(mode, channels));
|
||||||
|
|
||||||
st->mode = mode;
|
st->mode = mode;
|
||||||
st->overlap = mode->overlap;
|
st->overlap = mode->overlap;
|
||||||
|
@ -440,7 +441,7 @@ static void compute_inv_mdcts(const CELTMode *mode, int shortBlocks, celt_sig *X
|
||||||
B = shortBlocks;
|
B = shortBlocks;
|
||||||
}
|
}
|
||||||
/* Prevents problems from the imdct doing the overlap-add */
|
/* Prevents problems from the imdct doing the overlap-add */
|
||||||
CELT_MEMSET(x, 0, overlap);
|
OPUS_CLEAR(x, overlap);
|
||||||
|
|
||||||
for (b=0;b<B;b++)
|
for (b=0;b<B;b++)
|
||||||
{
|
{
|
||||||
|
@ -1084,8 +1085,8 @@ int celt_encode_with_ec(CELTEncoder * restrict st, const opus_val16 * pcm, int f
|
||||||
silence = silence && *inp == 0;
|
silence = silence && *inp == 0;
|
||||||
inp++;
|
inp++;
|
||||||
}
|
}
|
||||||
CELT_COPY(pre[c], prefilter_mem+c*COMBFILTER_MAXPERIOD, COMBFILTER_MAXPERIOD);
|
OPUS_COPY(pre[c], prefilter_mem+c*COMBFILTER_MAXPERIOD, COMBFILTER_MAXPERIOD);
|
||||||
CELT_COPY(pre[c]+COMBFILTER_MAXPERIOD, in+c*(N+st->overlap)+st->overlap, N);
|
OPUS_COPY(pre[c]+COMBFILTER_MAXPERIOD, in+c*(N+st->overlap)+st->overlap, N);
|
||||||
} while (++c<CC);
|
} while (++c<CC);
|
||||||
|
|
||||||
#ifdef FUZZING
|
#ifdef FUZZING
|
||||||
|
@ -1194,7 +1195,7 @@ int celt_encode_with_ec(CELTEncoder * restrict st, const opus_val16 * pcm, int f
|
||||||
c=0; do {
|
c=0; do {
|
||||||
int offset = st->mode->shortMdctSize-st->mode->overlap;
|
int offset = st->mode->shortMdctSize-st->mode->overlap;
|
||||||
st->prefilter_period=IMAX(st->prefilter_period, COMBFILTER_MINPERIOD);
|
st->prefilter_period=IMAX(st->prefilter_period, COMBFILTER_MINPERIOD);
|
||||||
CELT_COPY(in+c*(N+st->overlap), st->in_mem+c*(st->overlap), st->overlap);
|
OPUS_COPY(in+c*(N+st->overlap), st->in_mem+c*(st->overlap), st->overlap);
|
||||||
if (offset)
|
if (offset)
|
||||||
comb_filter(in+c*(N+st->overlap)+st->overlap, pre[c]+COMBFILTER_MAXPERIOD,
|
comb_filter(in+c*(N+st->overlap)+st->overlap, pre[c]+COMBFILTER_MAXPERIOD,
|
||||||
st->prefilter_period, st->prefilter_period, offset, -st->prefilter_gain, -st->prefilter_gain,
|
st->prefilter_period, st->prefilter_period, offset, -st->prefilter_gain, -st->prefilter_gain,
|
||||||
|
@ -1203,14 +1204,14 @@ int celt_encode_with_ec(CELTEncoder * restrict st, const opus_val16 * pcm, int f
|
||||||
comb_filter(in+c*(N+st->overlap)+st->overlap+offset, pre[c]+COMBFILTER_MAXPERIOD+offset,
|
comb_filter(in+c*(N+st->overlap)+st->overlap+offset, pre[c]+COMBFILTER_MAXPERIOD+offset,
|
||||||
st->prefilter_period, pitch_index, N-offset, -st->prefilter_gain, -gain1,
|
st->prefilter_period, pitch_index, N-offset, -st->prefilter_gain, -gain1,
|
||||||
st->prefilter_tapset, prefilter_tapset, st->mode->window, st->mode->overlap);
|
st->prefilter_tapset, prefilter_tapset, st->mode->window, st->mode->overlap);
|
||||||
CELT_COPY(st->in_mem+c*(st->overlap), in+c*(N+st->overlap)+N, st->overlap);
|
OPUS_COPY(st->in_mem+c*(st->overlap), in+c*(N+st->overlap)+N, st->overlap);
|
||||||
|
|
||||||
if (N>COMBFILTER_MAXPERIOD)
|
if (N>COMBFILTER_MAXPERIOD)
|
||||||
{
|
{
|
||||||
CELT_MOVE(prefilter_mem+c*COMBFILTER_MAXPERIOD, pre[c]+N, COMBFILTER_MAXPERIOD);
|
OPUS_MOVE(prefilter_mem+c*COMBFILTER_MAXPERIOD, pre[c]+N, COMBFILTER_MAXPERIOD);
|
||||||
} else {
|
} else {
|
||||||
CELT_MOVE(prefilter_mem+c*COMBFILTER_MAXPERIOD, prefilter_mem+c*COMBFILTER_MAXPERIOD+N, COMBFILTER_MAXPERIOD-N);
|
OPUS_MOVE(prefilter_mem+c*COMBFILTER_MAXPERIOD, prefilter_mem+c*COMBFILTER_MAXPERIOD+N, COMBFILTER_MAXPERIOD-N);
|
||||||
CELT_MOVE(prefilter_mem+c*COMBFILTER_MAXPERIOD+COMBFILTER_MAXPERIOD-N, pre[c]+COMBFILTER_MAXPERIOD, N);
|
OPUS_MOVE(prefilter_mem+c*COMBFILTER_MAXPERIOD+COMBFILTER_MAXPERIOD-N, pre[c]+COMBFILTER_MAXPERIOD, N);
|
||||||
}
|
}
|
||||||
} while (++c<CC);
|
} while (++c<CC);
|
||||||
|
|
||||||
|
@ -1559,9 +1560,9 @@ int celt_encode_with_ec(CELTEncoder * restrict st, const opus_val16 * pcm, int f
|
||||||
/* Synthesis */
|
/* Synthesis */
|
||||||
denormalise_bands(st->mode, X, freq, bandE, effEnd, C, M);
|
denormalise_bands(st->mode, X, freq, bandE, effEnd, C, M);
|
||||||
|
|
||||||
CELT_MOVE(st->syn_mem[0], st->syn_mem[0]+N, MAX_PERIOD);
|
OPUS_MOVE(st->syn_mem[0], st->syn_mem[0]+N, MAX_PERIOD);
|
||||||
if (CC==2)
|
if (CC==2)
|
||||||
CELT_MOVE(st->syn_mem[1], st->syn_mem[1]+N, MAX_PERIOD);
|
OPUS_MOVE(st->syn_mem[1], st->syn_mem[1]+N, MAX_PERIOD);
|
||||||
|
|
||||||
c=0; do
|
c=0; do
|
||||||
for (i=0;i<M*st->mode->eBands[st->start];i++)
|
for (i=0;i<M*st->mode->eBands[st->start];i++)
|
||||||
|
@ -1809,7 +1810,7 @@ int celt_encoder_ctl(CELTEncoder * restrict st, int request, ...)
|
||||||
break;
|
break;
|
||||||
case CELT_RESET_STATE:
|
case CELT_RESET_STATE:
|
||||||
{
|
{
|
||||||
CELT_MEMSET((char*)&st->ENCODER_RESET_START, 0,
|
OPUS_CLEAR((char*)&st->ENCODER_RESET_START,
|
||||||
celt_encoder_get_size_custom(st->mode, st->channels)-
|
celt_encoder_get_size_custom(st->mode, st->channels)-
|
||||||
((char*)&st->ENCODER_RESET_START - (char*)st));
|
((char*)&st->ENCODER_RESET_START - (char*)st));
|
||||||
st->vbr_offset = 0;
|
st->vbr_offset = 0;
|
||||||
|
@ -1972,7 +1973,7 @@ CELTDecoder *celt_decoder_init_custom(CELTDecoder *st, const CELTMode *mode, int
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CELT_MEMSET((char*)st, 0, celt_decoder_get_size_custom(mode, channels));
|
OPUS_CLEAR((char*)st, celt_decoder_get_size_custom(mode, channels));
|
||||||
|
|
||||||
st->mode = mode;
|
st->mode = mode;
|
||||||
st->overlap = mode->overlap;
|
st->overlap = mode->overlap;
|
||||||
|
@ -2519,9 +2520,9 @@ int celt_decode_with_ec(CELTDecoder * restrict st, const unsigned char *data, in
|
||||||
/* Synthesis */
|
/* Synthesis */
|
||||||
denormalise_bands(st->mode, X, freq, bandE, effEnd, C, M);
|
denormalise_bands(st->mode, X, freq, bandE, effEnd, C, M);
|
||||||
|
|
||||||
CELT_MOVE(decode_mem[0], decode_mem[0]+N, DECODE_BUFFER_SIZE-N);
|
OPUS_MOVE(decode_mem[0], decode_mem[0]+N, DECODE_BUFFER_SIZE-N);
|
||||||
if (CC==2)
|
if (CC==2)
|
||||||
CELT_MOVE(decode_mem[1], decode_mem[1]+N, DECODE_BUFFER_SIZE-N);
|
OPUS_MOVE(decode_mem[1], decode_mem[1]+N, DECODE_BUFFER_SIZE-N);
|
||||||
|
|
||||||
c=0; do
|
c=0; do
|
||||||
for (i=0;i<M*st->mode->eBands[st->start];i++)
|
for (i=0;i<M*st->mode->eBands[st->start];i++)
|
||||||
|
@ -2730,7 +2731,7 @@ int celt_decoder_ctl(CELTDecoder * restrict st, int request, ...)
|
||||||
break;
|
break;
|
||||||
case CELT_RESET_STATE:
|
case CELT_RESET_STATE:
|
||||||
{
|
{
|
||||||
CELT_MEMSET((char*)&st->DECODER_RESET_START, 0,
|
OPUS_CLEAR((char*)&st->DECODER_RESET_START,
|
||||||
celt_decoder_get_size_custom(st->mode, st->channels)-
|
celt_decoder_get_size_custom(st->mode, st->channels)-
|
||||||
((char*)&st->DECODER_RESET_START - (char*)st));
|
((char*)&st->DECODER_RESET_START - (char*)st));
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "os_support.h"
|
#include "os_support.h"
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "cwrs.h"
|
#include "cwrs.h"
|
||||||
#include "mathops.h"
|
#include "mathops.h"
|
||||||
#include "arch.h"
|
#include "arch.h"
|
||||||
|
@ -616,7 +614,8 @@ void encode_pulses(const int *_y,int _n,int _k,ec_enc *_enc){
|
||||||
ec_enc_uint(_enc,i,nc);
|
ec_enc_uint(_enc,i,nc);
|
||||||
RESTORE_STACK;
|
RESTORE_STACK;
|
||||||
#ifndef SMALL_FOOTPRINT
|
#ifndef SMALL_FOOTPRINT
|
||||||
};
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -639,6 +638,7 @@ void decode_pulses(int *_y,int _n,int _k,ec_dec *_dec)
|
||||||
RESTORE_STACK;
|
RESTORE_STACK;
|
||||||
#ifndef SMALL_FOOTPRINT
|
#ifndef SMALL_FOOTPRINT
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,7 +235,7 @@ void ec_enc_patch_initial_bits(ec_enc *_this,unsigned _val,unsigned _nbits){
|
||||||
|
|
||||||
void ec_enc_shrink(ec_enc *_this,opus_uint32 _size){
|
void ec_enc_shrink(ec_enc *_this,opus_uint32 _size){
|
||||||
celt_assert(_this->offs+_this->end_offs<=_size);
|
celt_assert(_this->offs+_this->end_offs<=_size);
|
||||||
CELT_MOVE(_this->buf+_size-_this->end_offs,
|
OPUS_MOVE(_this->buf+_size-_this->end_offs,
|
||||||
_this->buf+_this->storage-_this->end_offs,_this->end_offs);
|
_this->buf+_this->storage-_this->end_offs,_this->end_offs);
|
||||||
_this->storage=_size;
|
_this->storage=_size;
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ void ec_enc_done(ec_enc *_this){
|
||||||
}
|
}
|
||||||
/*Clear any excess space and add any remaining extra bits to the last byte.*/
|
/*Clear any excess space and add any remaining extra bits to the last byte.*/
|
||||||
if(!_this->error){
|
if(!_this->error){
|
||||||
CELT_MEMSET(_this->buf+_this->offs,0,
|
OPUS_CLEAR(_this->buf+_this->offs,
|
||||||
_this->storage-_this->offs-_this->end_offs);
|
_this->storage-_this->offs-_this->end_offs);
|
||||||
if(used>0){
|
if(used>0){
|
||||||
/*If there's no range coder data at all, give up.*/
|
/*If there's no range coder data at all, give up.*/
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
/** Opus wrapper for malloc(). To do your own dynamic allocation, all you need to do is replace this function and opus_free */
|
/** Opus wrapper for malloc(). To do your own dynamic allocation, all you need to do is replace this function and opus_free */
|
||||||
#ifndef OVERRIDE_CELT_ALLOC
|
#ifndef OVERRIDE_OPUS_ALLOC
|
||||||
static inline void *opus_alloc (size_t size)
|
static inline void *opus_alloc (size_t size)
|
||||||
{
|
{
|
||||||
return malloc(size);
|
return malloc(size);
|
||||||
|
@ -48,7 +48,7 @@ static inline void *opus_alloc (size_t size)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Same as celt_alloc(), except that the area is only needed inside a CELT call (might cause problem with wideband though) */
|
/** Same as celt_alloc(), except that the area is only needed inside a CELT call (might cause problem with wideband though) */
|
||||||
#ifndef OVERRIDE_CELT_ALLOC_SCRATCH
|
#ifndef OVERRIDE_OPUS_ALLOC_SCRATCH
|
||||||
static inline void *opus_alloc_scratch (size_t size)
|
static inline void *opus_alloc_scratch (size_t size)
|
||||||
{
|
{
|
||||||
/* Scratch space doesn't need to be cleared */
|
/* Scratch space doesn't need to be cleared */
|
||||||
|
@ -57,7 +57,7 @@ static inline void *opus_alloc_scratch (size_t size)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Opus wrapper for free(). To do your own dynamic allocation, all you need to do is replace this function and opus_alloc */
|
/** Opus wrapper for free(). To do your own dynamic allocation, all you need to do is replace this function and opus_alloc */
|
||||||
#ifndef OVERRIDE_CELT_FREE
|
#ifndef OVERRIDE_OPUS_FREE
|
||||||
static inline void opus_free (void *ptr)
|
static inline void opus_free (void *ptr)
|
||||||
{
|
{
|
||||||
free(ptr);
|
free(ptr);
|
||||||
|
@ -65,19 +65,19 @@ static inline void opus_free (void *ptr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Copy n bytes of memory from src to dst. The 0* term provides compile-time type checking */
|
/** Copy n bytes of memory from src to dst. The 0* term provides compile-time type checking */
|
||||||
#ifndef OVERRIDE_CELT_COPY
|
#ifndef OVERRIDE_OPUS_COPY
|
||||||
#define CELT_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
|
#define OPUS_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Copy n bytes of memory from src to dst, allowing overlapping regions. The 0* term
|
/** Copy n bytes of memory from src to dst, allowing overlapping regions. The 0* term
|
||||||
provides compile-time type checking */
|
provides compile-time type checking */
|
||||||
#ifndef OVERRIDE_CELT_MOVE
|
#ifndef OVERRIDE_OPUS_MOVE
|
||||||
#define CELT_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
|
#define OPUS_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Set n bytes of memory to value of c, starting at address s */
|
/** Set n elements of dst to zero, starting at address s */
|
||||||
#ifndef OVERRIDE_CELT_MEMSET
|
#ifndef OVERRIDE_OPUS_CLEAR
|
||||||
#define CELT_MEMSET(dst, c, n) (memset((dst), (c), (n)*sizeof(*(dst))))
|
#define OPUS_CLEAR(dst, n) (memset((dst), 0, (n)*sizeof(*(dst))))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*#ifdef __GNUC__
|
/*#ifdef __GNUC__
|
||||||
|
|
|
@ -295,7 +295,7 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
|
||||||
|
|
||||||
ALLOC(oldEBands_intra, C*m->nbEBands, opus_val16);
|
ALLOC(oldEBands_intra, C*m->nbEBands, opus_val16);
|
||||||
ALLOC(error_intra, C*m->nbEBands, opus_val16);
|
ALLOC(error_intra, C*m->nbEBands, opus_val16);
|
||||||
CELT_COPY(oldEBands_intra, oldEBands, C*m->nbEBands);
|
OPUS_COPY(oldEBands_intra, oldEBands, C*m->nbEBands);
|
||||||
|
|
||||||
if (two_pass || intra)
|
if (two_pass || intra)
|
||||||
{
|
{
|
||||||
|
@ -320,7 +320,7 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
|
||||||
nintra_bytes = ec_range_bytes(&enc_intra_state);
|
nintra_bytes = ec_range_bytes(&enc_intra_state);
|
||||||
ALLOC(intra_bits, nintra_bytes-nstart_bytes, unsigned char);
|
ALLOC(intra_bits, nintra_bytes-nstart_bytes, unsigned char);
|
||||||
/* Copy bits from intra bit-stream */
|
/* Copy bits from intra bit-stream */
|
||||||
CELT_COPY(intra_bits,
|
OPUS_COPY(intra_bits,
|
||||||
ec_get_buffer(&enc_intra_state) + nstart_bytes,
|
ec_get_buffer(&enc_intra_state) + nstart_bytes,
|
||||||
nintra_bytes - nstart_bytes);
|
nintra_bytes - nstart_bytes);
|
||||||
|
|
||||||
|
@ -333,15 +333,15 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
|
||||||
{
|
{
|
||||||
*enc = enc_intra_state;
|
*enc = enc_intra_state;
|
||||||
/* Copy intra bits to bit-stream */
|
/* Copy intra bits to bit-stream */
|
||||||
CELT_COPY(ec_get_buffer(&enc_intra_state) + nstart_bytes,
|
OPUS_COPY(ec_get_buffer(&enc_intra_state) + nstart_bytes,
|
||||||
intra_bits, nintra_bytes - nstart_bytes);
|
intra_bits, nintra_bytes - nstart_bytes);
|
||||||
CELT_COPY(oldEBands, oldEBands_intra, C*m->nbEBands);
|
OPUS_COPY(oldEBands, oldEBands_intra, C*m->nbEBands);
|
||||||
CELT_COPY(error, error_intra, C*m->nbEBands);
|
OPUS_COPY(error, error_intra, C*m->nbEBands);
|
||||||
intra = 1;
|
intra = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
CELT_COPY(oldEBands, oldEBands_intra, C*m->nbEBands);
|
OPUS_COPY(oldEBands, oldEBands_intra, C*m->nbEBands);
|
||||||
CELT_COPY(error, error_intra, C*m->nbEBands);
|
OPUS_COPY(error, error_intra, C*m->nbEBands);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intra)
|
if (intra)
|
||||||
|
|
|
@ -29,9 +29,6 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "celt.h"
|
#include "celt.h"
|
||||||
#include "opus.h"
|
#include "opus.h"
|
||||||
|
@ -94,7 +91,7 @@ int opus_decoder_init(OpusDecoder *st, int Fs, int channels)
|
||||||
|
|
||||||
if (channels<1 || channels > 2)
|
if (channels<1 || channels > 2)
|
||||||
return OPUS_BAD_ARG;
|
return OPUS_BAD_ARG;
|
||||||
memset(st, 0, opus_decoder_get_size(channels));
|
OPUS_CLEAR((char*)st, opus_decoder_get_size(channels));
|
||||||
/* Initialize SILK encoder */
|
/* Initialize SILK encoder */
|
||||||
ret = silk_Get_Decoder_Size( &silkDecSizeBytes );
|
ret = silk_Get_Decoder_Size( &silkDecSizeBytes );
|
||||||
if( ret ) {
|
if( ret ) {
|
||||||
|
@ -254,7 +251,7 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data,
|
||||||
}
|
}
|
||||||
if (audiosize > frame_size)
|
if (audiosize > frame_size)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "PCM buffer too small: %d vs %d (mode = %d)\n", audiosize, frame_size, mode);
|
/*fprintf(stderr, "PCM buffer too small: %d vs %d (mode = %d)\n", audiosize, frame_size, mode);*/
|
||||||
RESTORE_STACK;
|
RESTORE_STACK;
|
||||||
return OPUS_BAD_ARG;
|
return OPUS_BAD_ARG;
|
||||||
} else {
|
} else {
|
||||||
|
@ -743,6 +740,7 @@ int opus_decode_float(OpusDecoder *st, const unsigned char *data,
|
||||||
|
|
||||||
int opus_decoder_ctl(OpusDecoder *st, int request, ...)
|
int opus_decoder_ctl(OpusDecoder *st, int request, ...)
|
||||||
{
|
{
|
||||||
|
int ret = OPUS_OK;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, request);
|
va_start(ap, request);
|
||||||
|
@ -762,12 +760,13 @@ int opus_decoder_ctl(OpusDecoder *st, int request, ...)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "unknown opus_decoder_ctl() request: %d", request);
|
/*fprintf(stderr, "unknown opus_decoder_ctl() request: %d", request);*/
|
||||||
|
ret = OPUS_BAD_ARG;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return OPUS_OK;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void opus_decoder_destroy(OpusDecoder *st)
|
void opus_decoder_destroy(OpusDecoder *st)
|
||||||
|
|
|
@ -29,9 +29,6 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "celt.h"
|
#include "celt.h"
|
||||||
#include "entenc.h"
|
#include "entenc.h"
|
||||||
|
@ -125,7 +122,7 @@ int opus_encoder_init(OpusEncoder* st, int Fs, int channels, int application)
|
||||||
if (Fs != 8000 && Fs != 12000 && Fs != 16000 && Fs != 24000 && Fs != 48000)
|
if (Fs != 8000 && Fs != 12000 && Fs != 16000 && Fs != 24000 && Fs != 48000)
|
||||||
return OPUS_BAD_ARG;
|
return OPUS_BAD_ARG;
|
||||||
|
|
||||||
memset(st, 0, opus_encoder_get_size(channels));
|
OPUS_CLEAR((char*)st, opus_encoder_get_size(channels));
|
||||||
/* Create SILK encoder */
|
/* Create SILK encoder */
|
||||||
ret = silk_Get_Encoder_Size( &silkEncSizeBytes );
|
ret = silk_Get_Encoder_Size( &silkEncSizeBytes );
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -552,8 +549,9 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
|
||||||
#endif
|
#endif
|
||||||
ret = silk_Encode( silk_enc, &st->silk_mode, pcm_silk, frame_size, &enc, &nBytes, 0 );
|
ret = silk_Encode( silk_enc, &st->silk_mode, pcm_silk, frame_size, &enc, &nBytes, 0 );
|
||||||
if( ret ) {
|
if( ret ) {
|
||||||
fprintf (stderr, "SILK encode error: %d\n", ret);
|
/*fprintf (stderr, "SILK encode error: %d\n", ret);*/
|
||||||
/* Handle error */
|
/* Handle error */
|
||||||
|
return OPUS_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
if (nBytes==0)
|
if (nBytes==0)
|
||||||
{
|
{
|
||||||
|
@ -810,9 +808,11 @@ int opus_encode(OpusEncoder *st, const opus_int16 *pcm, int frame_size,
|
||||||
|
|
||||||
int opus_encoder_ctl(OpusEncoder *st, int request, ...)
|
int opus_encoder_ctl(OpusEncoder *st, int request, ...)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
CELTEncoder *celt_enc;
|
CELTEncoder *celt_enc;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
|
ret = OPUS_OK;
|
||||||
va_start(ap, request);
|
va_start(ap, request);
|
||||||
|
|
||||||
celt_enc = (CELTEncoder*)((char*)st+st->celt_enc_offset);
|
celt_enc = (CELTEncoder*)((char*)st+st->celt_enc_offset);
|
||||||
|
@ -999,11 +999,12 @@ int opus_encoder_ctl(OpusEncoder *st, int request, ...)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "unknown opus_encoder_ctl() request: %d", request);
|
/* fprintf(stderr, "unknown opus_encoder_ctl() request: %d", request);*/
|
||||||
|
ret = OPUS_BAD_ARG;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return OPUS_OK;
|
return ret;
|
||||||
bad_arg:
|
bad_arg:
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return OPUS_BAD_ARG;
|
return OPUS_BAD_ARG;
|
||||||
|
|
|
@ -33,9 +33,6 @@
|
||||||
#include "opus.h"
|
#include "opus.h"
|
||||||
#include "opus_private.h"
|
#include "opus_private.h"
|
||||||
#include "stack_alloc.h"
|
#include "stack_alloc.h"
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "float_cast.h"
|
#include "float_cast.h"
|
||||||
#include "os_support.h"
|
#include "os_support.h"
|
||||||
|
@ -297,7 +294,7 @@ int opus_multistream_encode_float(
|
||||||
}
|
}
|
||||||
/* IMPORTANT: Here we assume that the encoder only returned one frame */
|
/* IMPORTANT: Here we assume that the encoder only returned one frame */
|
||||||
tot_size += len;
|
tot_size += len;
|
||||||
memcpy(data, &tmp_data[1], len-1);
|
OPUS_COPY(data, &tmp_data[1], len-1);
|
||||||
}
|
}
|
||||||
RESTORE_STACK;
|
RESTORE_STACK;
|
||||||
return tot_size;
|
return tot_size;
|
||||||
|
|
|
@ -29,10 +29,6 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "opus.h"
|
#include "opus.h"
|
||||||
#include "opus_private.h"
|
#include "opus_private.h"
|
||||||
#include "os_support.h"
|
#include "os_support.h"
|
||||||
|
@ -181,11 +177,12 @@ int opus_repacketizer_out_range(OpusRepacketizer *rp, int begin, int end, unsign
|
||||||
*data++ = count;
|
*data++ = count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
/* Copy the actual data */
|
/* Copy the actual data */
|
||||||
for (i=0;i<count;i++)
|
for (i=0;i<count;i++)
|
||||||
{
|
{
|
||||||
memcpy(data, frames[i], len[i]);
|
OPUS_COPY(data, frames[i], len[i]);
|
||||||
data += len[i];
|
data += len[i];
|
||||||
}
|
}
|
||||||
return tot_size;
|
return tot_size;
|
||||||
|
|
|
@ -318,6 +318,7 @@ int main(int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
bandwidth_string = "unknown";
|
bandwidth_string = "unknown";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "Encoding %d Hz input at %.3f kb/s in %s mode with %d-sample frames.\n", sampling_rate, bitrate_bps*0.001, bandwidth_string, frame_size);
|
fprintf(stderr, "Encoding %d Hz input at %.3f kb/s in %s mode with %d-sample frames.\n", sampling_rate, bitrate_bps*0.001, bandwidth_string, frame_size);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue