* 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
* 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
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.
av_free(state);
}
-#endif /* CONFIG_ENCODERS */
-
-static const int samplerate_table[] =
- { 44100, 22050, 11025, 96000, 48000, 32000, 24000, 16000, 8000 };
-
-#ifdef CONFIG_ENCODERS
static inline int code_samplerate(int samplerate)
{
flush_put_bits(&pb);
return (put_bits_count(&pb)+7)/8;
}
-#endif //CONFIG_ENCODERS
+#endif /* CONFIG_SONIC_ENCODER || CONFIG_SONIC_LS_ENCODER */
+
+#if CONFIG_SONIC_DECODER
+static const int samplerate_table[] =
+ { 44100, 22050, 11025, 96000, 48000, 32000, 24000, 16000, 8000 };
-#ifdef CONFIG_DECODERS
static av_cold int sonic_decode_init(AVCodecContext *avctx)
{
SonicContext *s = avctx->priv_data;
}
s->int_samples = av_mallocz(4* s->frame_size);
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
}
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;
return (get_bits_count(&gb)+7)/8;
}
-#endif
-#ifdef CONFIG_ENCODERS
-AVCodec sonic_encoder = {
+AVCodec ff_sonic_decoder = {
+ "sonic",
+ AVMEDIA_TYPE_AUDIO,
+ CODEC_ID_SONIC,
+ sizeof(SonicContext),
+ sonic_decode_init,
+ NULL,
+ sonic_decode_close,
+ sonic_decode_frame,
+ .long_name = NULL_IF_CONFIG_SMALL("Sonic"),
+};
+#endif /* CONFIG_SONIC_DECODER */
+
+#if CONFIG_SONIC_ENCODER
+AVCodec ff_sonic_encoder = {
"sonic",
- CODEC_TYPE_AUDIO,
+ AVMEDIA_TYPE_AUDIO,
CODEC_ID_SONIC,
sizeof(SonicContext),
sonic_encode_init,
NULL,
.long_name = NULL_IF_CONFIG_SMALL("Sonic"),
};
+#endif
-AVCodec sonic_ls_encoder = {
+#if CONFIG_SONIC_LS_ENCODER
+AVCodec ff_sonic_ls_encoder = {
"sonicls",
- CODEC_TYPE_AUDIO,
+ AVMEDIA_TYPE_AUDIO,
CODEC_ID_SONIC_LS,
sizeof(SonicContext),
sonic_encode_init,
.long_name = NULL_IF_CONFIG_SMALL("Sonic lossless"),
};
#endif
-
-#ifdef CONFIG_DECODERS
-AVCodec sonic_decoder = {
- "sonic",
- CODEC_TYPE_AUDIO,
- CODEC_ID_SONIC,
- sizeof(SonicContext),
- sonic_decode_init,
- NULL,
- sonic_decode_close,
- sonic_decode_frame,
- .long_name = NULL_IF_CONFIG_SMALL("Sonic"),
-};
-#endif