]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/sonic.c
ARM: NEON optimised vector_fmul_window
[ffmpeg] / libavcodec / sonic.c
index f3388589b6bc5e0f36caea47c0abfb17fb6a3789..44b458268208eed59d341f8a1a3115662b31603c 100644 (file)
@@ -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)
@@ -503,7 +502,7 @@ static inline int code_samplerate(int samplerate)
     return -1;
 }
 
-static int sonic_encode_init(AVCodecContext *avctx)
+static av_cold int sonic_encode_init(AVCodecContext *avctx)
 {
     SonicContext *s = avctx->priv_data;
     PutBitContext pb;
@@ -608,7 +607,7 @@ static int sonic_encode_init(AVCodecContext *avctx)
     return 0;
 }
 
-static int sonic_encode_close(AVCodecContext *avctx)
+static av_cold int sonic_encode_close(AVCodecContext *avctx)
 {
     SonicContext *s = avctx->priv_data;
     int i;
@@ -748,10 +747,10 @@ 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
-static int sonic_decode_init(AVCodecContext *avctx)
+#if CONFIG_SONIC_DECODER
+static av_cold int sonic_decode_init(AVCodecContext *avctx)
 {
     SonicContext *s = avctx->priv_data;
     GetBitContext gb;
@@ -828,10 +827,11 @@ static int sonic_decode_init(AVCodecContext *avctx)
     }
     s->int_samples = av_mallocz(4* s->frame_size);
 
+    avctx->sample_fmt = SAMPLE_FMT_S16;
     return 0;
 }
 
-static int sonic_decode_close(AVCodecContext *avctx)
+static av_cold int sonic_decode_close(AVCodecContext *avctx)
 {
     SonicContext *s = avctx->priv_data;
     int i;
@@ -851,7 +851,7 @@ static int sonic_decode_close(AVCodecContext *avctx)
 
 static int sonic_decode_frame(AVCodecContext *avctx,
                             void *data, int *data_size,
-                            uint8_t *buf, int buf_size)
+                            const uint8_t *buf, int buf_size)
 {
     SonicContext *s = avctx->priv_data;
     GetBitContext gb;
@@ -926,14 +926,7 @@ static int sonic_decode_frame(AVCodecContext *avctx,
 
     // internal -> short
     for (i = 0; i < s->frame_size; i++)
-    {
-        if (s->int_samples[i] > 32767)
-            samples[i] = 32767;
-        else if (s->int_samples[i] < -32768)
-            samples[i] = -32768;
-        else
-            samples[i] = s->int_samples[i];
-    }
+        samples[i] = av_clip_int16(s->int_samples[i]);
 
     align_get_bits(&gb);
 
@@ -941,9 +934,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,
@@ -953,8 +946,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,
@@ -964,10 +960,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,
@@ -977,5 +974,6 @@ AVCodec sonic_decoder = {
     NULL,
     sonic_decode_close,
     sonic_decode_frame,
+    .long_name = NULL_IF_CONFIG_SMALL("Sonic"),
 };
 #endif