diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2011-08-30 20:39:51 +0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2011-08-30 20:39:51 +0400 |
commit | be89c395872c57087a6fd0b004ee175677bb3d79 (patch) | |
tree | 5227fe9ba9ad7f485a839c3b1db99f059bff494e /src | |
parent | 382cad43ce1505a8bc809dd557b8b423d0017e24 (diff) |
Using OPUS_ macros for <string.h> operations
Removes a bunch of system #include <...> in the process
Diffstat (limited to 'src')
-rw-r--r-- | src/opus_decoder.c | 53 | ||||
-rw-r--r-- | src/opus_encoder.c | 15 | ||||
-rw-r--r-- | src/opus_multistream.c | 5 | ||||
-rw-r--r-- | src/repacketizer.c | 7 | ||||
-rw-r--r-- | src/test_opus.c | 1 |
5 files changed, 38 insertions, 43 deletions
diff --git a/src/opus_decoder.c b/src/opus_decoder.c index b1e990bb..074b9d6e 100644 --- a/src/opus_decoder.c +++ b/src/opus_decoder.c @@ -29,9 +29,6 @@ #include "config.h" #endif -#include <string.h> -#include <stdlib.h> -#include <stdio.h> #include <stdarg.h> #include "celt.h" #include "opus.h" @@ -94,7 +91,7 @@ int opus_decoder_init(OpusDecoder *st, int Fs, int channels) if (channels<1 || channels > 2) return OPUS_BAD_ARG; - memset(st, 0, opus_decoder_get_size(channels)); + OPUS_CLEAR((char*)st, opus_decoder_get_size(channels)); /* Initialize SILK encoder */ ret = silk_Get_Decoder_Size( &silkDecSizeBytes ); if( ret ) { @@ -254,7 +251,7 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, } 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; return OPUS_BAD_ARG; } else { @@ -743,31 +740,33 @@ int opus_decode_float(OpusDecoder *st, const unsigned char *data, int opus_decoder_ctl(OpusDecoder *st, int request, ...) { - va_list ap; + int ret = OPUS_OK; + va_list ap; - va_start(ap, request); + va_start(ap, request); - switch (request) - { - case OPUS_GET_BANDWIDTH_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - *value = st->bandwidth; - } - break; - case OPUS_GET_FINAL_RANGE_REQUEST: - { - opus_uint32 *value = va_arg(ap, opus_uint32*); - *value = st->rangeFinal; - } - break; - default: - fprintf(stderr, "unknown opus_decoder_ctl() request: %d", request); - break; - } + switch (request) + { + case OPUS_GET_BANDWIDTH_REQUEST: + { + opus_int32 *value = va_arg(ap, opus_int32*); + *value = st->bandwidth; + } + break; + case OPUS_GET_FINAL_RANGE_REQUEST: + { + opus_uint32 *value = va_arg(ap, opus_uint32*); + *value = st->rangeFinal; + } + break; + default: + /*fprintf(stderr, "unknown opus_decoder_ctl() request: %d", request);*/ + ret = OPUS_BAD_ARG; + break; + } - va_end(ap); - return OPUS_OK; + va_end(ap); + return ret; } void opus_decoder_destroy(OpusDecoder *st) diff --git a/src/opus_encoder.c b/src/opus_encoder.c index d0ecea01..cafdb8d9 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -29,9 +29,6 @@ #include "config.h" #endif -#include <string.h> -#include <stdlib.h> -#include <stdio.h> #include <stdarg.h> #include "celt.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) return OPUS_BAD_ARG; - memset(st, 0, opus_encoder_get_size(channels)); + OPUS_CLEAR((char*)st, opus_encoder_get_size(channels)); /* Create SILK encoder */ ret = silk_Get_Encoder_Size( &silkEncSizeBytes ); if (ret) @@ -552,8 +549,9 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size, #endif ret = silk_Encode( silk_enc, &st->silk_mode, pcm_silk, frame_size, &enc, &nBytes, 0 ); if( ret ) { - fprintf (stderr, "SILK encode error: %d\n", ret); + /*fprintf (stderr, "SILK encode error: %d\n", ret);*/ /* Handle error */ + return OPUS_INTERNAL_ERROR; } 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 ret; CELTEncoder *celt_enc; va_list ap; + ret = OPUS_OK; va_start(ap, request); celt_enc = (CELTEncoder*)((char*)st+st->celt_enc_offset); @@ -999,11 +999,12 @@ int opus_encoder_ctl(OpusEncoder *st, int request, ...) } break; default: - fprintf(stderr, "unknown opus_encoder_ctl() request: %d", request); + /* fprintf(stderr, "unknown opus_encoder_ctl() request: %d", request);*/ + ret = OPUS_BAD_ARG; break; } va_end(ap); - return OPUS_OK; + return ret; bad_arg: va_end(ap); return OPUS_BAD_ARG; diff --git a/src/opus_multistream.c b/src/opus_multistream.c index 697cf5b1..49e3d0f8 100644 --- a/src/opus_multistream.c +++ b/src/opus_multistream.c @@ -33,9 +33,6 @@ #include "opus.h" #include "opus_private.h" #include "stack_alloc.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> #include <stdarg.h> #include "float_cast.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 */ tot_size += len; - memcpy(data, &tmp_data[1], len-1); + OPUS_COPY(data, &tmp_data[1], len-1); } RESTORE_STACK; return tot_size; diff --git a/src/repacketizer.c b/src/repacketizer.c index 4ef8e1ba..ac4a616c 100644 --- a/src/repacketizer.c +++ b/src/repacketizer.c @@ -29,10 +29,6 @@ #include "config.h" #endif -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - #include "opus.h" #include "opus_private.h" #include "os_support.h" @@ -181,11 +177,12 @@ int opus_repacketizer_out_range(OpusRepacketizer *rp, int begin, int end, unsign *data++ = count; } } + break; } /* Copy the actual data */ for (i=0;i<count;i++) { - memcpy(data, frames[i], len[i]); + OPUS_COPY(data, frames[i], len[i]); data += len[i]; } return tot_size; diff --git a/src/test_opus.c b/src/test_opus.c index 3a84fafc..7ec1e059 100644 --- a/src/test_opus.c +++ b/src/test_opus.c @@ -318,6 +318,7 @@ int main(int argc, char *argv[]) break; default: 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); |