]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/adxdec.c
vorbisdec: return proper error codes instead of made-up ones
[ffmpeg] / libavcodec / adxdec.c
index 91331c04b1804447a47a375c7cf80e8032f3040e..79fcf13c31facb0fe7a202df8f7e9be1f9c7fa68 100644 (file)
@@ -2,27 +2,29 @@
  * ADX ADPCM codecs
  * Copyright (c) 2001,2003 BERO
  *
- * This file is part of FFmpeg.
+ * This file is part of Libav.
  *
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
+
+#include "libavutil/intreadwrite.h"
 #include "avcodec.h"
 #include "adx.h"
 
 /**
- * @file adx.c
+ * @file
  * SEGA CRI adx codecs.
  *
  * Reference documents:
  * adx2wav & wav2adx http://www.geocities.co.jp/Playtown/2004/
  */
 
+static av_cold int adx_decode_init(AVCodecContext *avctx)
+{
+    avctx->sample_fmt = AV_SAMPLE_FMT_S16;
+    return 0;
+}
+
 /* 18 bytes <-> 32 samples */
 
 static void adx_decode(short *out,const unsigned char *in,PREV *prev)
@@ -96,8 +104,10 @@ static int adx_decode_header(AVCodecContext *avctx,const unsigned char *buf,size
 
 static int adx_decode_frame(AVCodecContext *avctx,
                 void *data, int *data_size,
-                const uint8_t *buf0, int buf_size)
+                AVPacket *avpkt)
 {
+    const uint8_t *buf0 = avpkt->data;
+    int buf_size = avpkt->size;
     ADXContext *c = avctx->priv_data;
     short *samples = data;
     const uint8_t *buf = buf0;
@@ -156,15 +166,13 @@ static int adx_decode_frame(AVCodecContext *avctx,
     return buf-buf0;
 }
 
-AVCodec adpcm_adx_decoder = {
-    "adpcm_adx",
-    CODEC_TYPE_AUDIO,
-    CODEC_ID_ADPCM_ADX,
-    sizeof(ADXContext),
-    NULL,
-    NULL,
-    NULL,
-    adx_decode_frame,
-    .long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX"),
+AVCodec ff_adpcm_adx_decoder = {
+    .name           = "adpcm_adx",
+    .type           = AVMEDIA_TYPE_AUDIO,
+    .id             = CODEC_ID_ADPCM_ADX,
+    .priv_data_size = sizeof(ADXContext),
+    .init           = adx_decode_init,
+    .decode         = adx_decode_frame,
+    .long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX ADPCM"),
 };