X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fsonic.c;h=00ae83587373502f0064dd70af1546387b28182e;hb=5e12701c5c881722f28379a15a60d5a20698b10f;hp=79641ae5139c26d1ec0c842349b20201cdc915c4;hpb=98a6fff98c3f2e963783e52fb193529bdc14e040;p=ffmpeg diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c index 79641ae5139..00ae8358737 100644 --- a/libavcodec/sonic.c +++ b/libavcodec/sonic.c @@ -19,11 +19,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "golomb.h" /** - * @file sonic.c + * @file libavcodec/sonic.c * Simple free lossless/lossy audio codec * Based on Paul Francis Harrison's Bonk (http://www.logarithmic.net/pfh/bonk) * Written and designed by Alex Beregszaszi @@ -408,7 +408,7 @@ static int predictor_calc_error(int *k, int *state, int order, int error) return x; } -#ifdef CONFIG_ENCODERS +#if CONFIG_SONIC_ENCODER || CONFIG_SONIC_LS_ENCODER // Heavily modified Levinson-Durbin algorithm which // copes better with quantization, and calculates the // actual whitened result as it goes. @@ -479,13 +479,12 @@ static void modified_levinson_durbin(int *window, int window_entries, av_free(state); } -#endif /* CONFIG_ENCODERS */ +#endif /* CONFIG_SONIC_ENCODER || CONFIG_SONIC_LS_ENCODER */ -static int samplerate_table[] = +static const int samplerate_table[] = { 44100, 22050, 11025, 96000, 48000, 32000, 24000, 16000, 8000 }; -#ifdef CONFIG_ENCODERS - +#if CONFIG_SONIC_ENCODER || CONFIG_SONIC_LS_ENCODER static inline int code_samplerate(int samplerate) { switch (samplerate) @@ -748,9 +747,9 @@ static int sonic_encode_frame(AVCodecContext *avctx, flush_put_bits(&pb); return (put_bits_count(&pb)+7)/8; } -#endif //CONFIG_ENCODERS +#endif /* CONFIG_SONIC_ENCODER || CONFIG_SONIC_LS_ENCODER */ -#ifdef CONFIG_DECODERS +#if CONFIG_SONIC_DECODER static av_cold int sonic_decode_init(AVCodecContext *avctx) { SonicContext *s = avctx->priv_data; @@ -828,6 +827,7 @@ static av_cold int sonic_decode_init(AVCodecContext *avctx) } s->int_samples = av_mallocz(4* s->frame_size); + avctx->sample_fmt = SAMPLE_FMT_S16; return 0; } @@ -851,8 +851,10 @@ static av_cold int sonic_decode_close(AVCodecContext *avctx) static int sonic_decode_frame(AVCodecContext *avctx, void *data, int *data_size, - const uint8_t *buf, int buf_size) + AVPacket *avpkt) { + const uint8_t *buf = avpkt->data; + int buf_size = avpkt->size; SonicContext *s = avctx->priv_data; GetBitContext gb; int i, quant, ch, j; @@ -934,9 +936,9 @@ static int sonic_decode_frame(AVCodecContext *avctx, return (get_bits_count(&gb)+7)/8; } -#endif +#endif /* CONFIG_SONIC_DECODER */ -#ifdef CONFIG_ENCODERS +#if CONFIG_SONIC_ENCODER AVCodec sonic_encoder = { "sonic", CODEC_TYPE_AUDIO, @@ -946,8 +948,11 @@ AVCodec sonic_encoder = { sonic_encode_frame, sonic_encode_close, NULL, + .long_name = NULL_IF_CONFIG_SMALL("Sonic"), }; +#endif +#if CONFIG_SONIC_LS_ENCODER AVCodec sonic_ls_encoder = { "sonicls", CODEC_TYPE_AUDIO, @@ -957,10 +962,11 @@ AVCodec sonic_ls_encoder = { sonic_encode_frame, sonic_encode_close, NULL, + .long_name = NULL_IF_CONFIG_SMALL("Sonic lossless"), }; #endif -#ifdef CONFIG_DECODERS +#if CONFIG_SONIC_DECODER AVCodec sonic_decoder = { "sonic", CODEC_TYPE_AUDIO, @@ -970,5 +976,6 @@ AVCodec sonic_decoder = { NULL, sonic_decode_close, sonic_decode_frame, + .long_name = NULL_IF_CONFIG_SMALL("Sonic"), }; #endif