]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/sonic.c
Fix overflow in pred16x16_plane x86 simd code. Fixes issue 2547.
[ffmpeg] / libavcodec / sonic.c
index 14e19ad6391dfe0b7d5e87aa2e8b59dbeeb0960d..aff155d57fab3780a0d5144ea022a1215a31b71a 100644 (file)
  * 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 libavcodec/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
@@ -479,12 +479,7 @@ static void modified_levinson_durbin(int *window, int window_entries,
 
     av_free(state);
 }
-#endif /* CONFIG_SONIC_ENCODER || CONFIG_SONIC_LS_ENCODER */
-
-static const int samplerate_table[] =
-    { 44100, 22050, 11025, 96000, 48000, 32000, 24000, 16000, 8000 };
 
-#if CONFIG_SONIC_ENCODER || CONFIG_SONIC_LS_ENCODER
 static inline int code_samplerate(int samplerate)
 {
     switch (samplerate)
@@ -750,6 +745,9 @@ static int sonic_encode_frame(AVCodecContext *avctx,
 #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 };
+
 static av_cold int sonic_decode_init(AVCodecContext *avctx)
 {
     SonicContext *s = avctx->priv_data;
@@ -827,7 +825,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;
+    avctx->sample_fmt = AV_SAMPLE_FMT_S16;
     return 0;
 }
 
@@ -851,8 +849,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,12 +934,24 @@ static int sonic_decode_frame(AVCodecContext *avctx,
 
     return (get_bits_count(&gb)+7)/8;
 }
+
+AVCodec 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 sonic_encoder = {
     "sonic",
-    CODEC_TYPE_AUDIO,
+    AVMEDIA_TYPE_AUDIO,
     CODEC_ID_SONIC,
     sizeof(SonicContext),
     sonic_encode_init,
@@ -953,7 +965,7 @@ AVCodec sonic_encoder = {
 #if CONFIG_SONIC_LS_ENCODER
 AVCodec sonic_ls_encoder = {
     "sonicls",
-    CODEC_TYPE_AUDIO,
+    AVMEDIA_TYPE_AUDIO,
     CODEC_ID_SONIC_LS,
     sizeof(SonicContext),
     sonic_encode_init,
@@ -963,17 +975,3 @@ AVCodec sonic_ls_encoder = {
     .long_name = NULL_IF_CONFIG_SMALL("Sonic lossless"),
 };
 #endif
-
-#if CONFIG_SONIC_DECODER
-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