]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/atrac3.c
cosmetics: Fix typos in ADPCM codec long names.
[ffmpeg] / libavcodec / atrac3.c
index 0e6d184259585ed897aa5026de86733fd786997c..cfbaf7acc3f4e32001fa25864117649590fd4092 100644 (file)
@@ -225,14 +225,14 @@ static void IMLT(float *pInput, float *pOutput, int odd_band, float* mdct_tmp)
  * @param out       pointer to 8 bit array of outdata
  */
 
-static int decode_bytes(uint8_t* inbuffer, uint8_t* out, int bytes){
+static int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes){
     int i, off;
     uint32_t c;
-    uint32_t* buf;
+    const uint32_t* buf;
     uint32_t* obuf = (uint32_t*) out;
 
     off = (int)((long)inbuffer & 3);
-    buf = (uint32_t*) (inbuffer - off);
+    buf = (const uint32_t*) (inbuffer - off);
     c = be2me_32((0x537F6103 >> (off*8)) | (0x537F6103 << (32-(off*8))));
     bytes += 3 + off;
     for (i = 0; i < bytes/4; i++)
@@ -363,7 +363,7 @@ static int decodeSpectrum (GetBitContext *gb, float *pOut)
     float SF;
 
     numSubbands = get_bits(gb, 5); // number of coded subbands
-    codingMode = get_bits(gb, 1); // coding Mode: 0 - VLC/ 1-CLC
+    codingMode = get_bits1(gb); // coding Mode: 0 - VLC/ 1-CLC
 
     /* Get the VLC selector table for the subbands, 0 means not coded. */
     for (cnt = 0; cnt <= numSubbands; cnt++)
@@ -811,7 +811,7 @@ static int decodeFrame(ATRAC3Context *q, uint8_t* databuf)
 
         /* Fill the Weighting coeffs delay buffer */
         memmove(q->weighting_delay,&(q->weighting_delay[2]),4*sizeof(int));
-        q->weighting_delay[4] = get_bits(&q->gb,1);
+        q->weighting_delay[4] = get_bits1(&q->gb);
         q->weighting_delay[5] = get_bits(&q->gb,3);
 
         for (i = 0; i < 4; i++) {
@@ -868,7 +868,7 @@ static int decodeFrame(ATRAC3Context *q, uint8_t* databuf)
 
 static int atrac3_decode_frame(AVCodecContext *avctx,
             void *data, int *data_size,
-            uint8_t *buf, int buf_size) {
+            const uint8_t *buf, int buf_size) {
     ATRAC3Context *q = avctx->priv_data;
     int result = 0, i;
     uint8_t* databuf;
@@ -895,13 +895,13 @@ static int atrac3_decode_frame(AVCodecContext *avctx,
     if (q->channels == 1) {
         /* mono */
         for (i = 0; i<1024; i++)
-            samples[i] = av_clip(round(q->outSamples[i]), -32768, 32767);
+            samples[i] = av_clip_int16(round(q->outSamples[i]));
         *data_size = 1024 * sizeof(int16_t);
     } else {
         /* stereo */
         for (i = 0; i < 1024; i++) {
-            samples[i*2] = av_clip(round(q->outSamples[i]), -32768, 32767);
-            samples[i*2+1] = av_clip(round(q->outSamples[1024+i]), -32768, 32767);
+            samples[i*2] = av_clip_int16(round(q->outSamples[i]));
+            samples[i*2+1] = av_clip_int16(round(q->outSamples[1024+i]));
         }
         *data_size = 2048 * sizeof(int16_t);
     }
@@ -919,7 +919,7 @@ static int atrac3_decode_frame(AVCodecContext *avctx,
 static int atrac3_decode_init(AVCodecContext *avctx)
 {
     int i;
-    uint8_t *edata_ptr = avctx->extradata;
+    const uint8_t *edata_ptr = avctx->extradata;
     ATRAC3Context *q = avctx->priv_data;
 
     /* Take data from the AVCodecContext (RM container). */
@@ -1007,7 +1007,7 @@ static int atrac3_decode_init(AVCodecContext *avctx)
     /* Pad the data buffer with FF_INPUT_BUFFER_PADDING_SIZE,
      * this is for the bitstream reader. */
     if ((q->decoded_bytes_buffer = av_mallocz((avctx->block_align+(4-avctx->block_align%4) + FF_INPUT_BUFFER_PADDING_SIZE)))  == NULL)
-        return -1;
+        return AVERROR(ENOMEM);
 
 
     /* Initialize the VLC tables. */
@@ -1047,6 +1047,10 @@ static int atrac3_decode_init(AVCodecContext *avctx)
     dsputil_init(&dsp, avctx);
 
     q->pUnits = av_mallocz(sizeof(channel_unit)*q->channels);
+    if (!q->pUnits) {
+        av_free(q->decoded_bytes_buffer);
+        return AVERROR(ENOMEM);
+    }
 
     return 0;
 }
@@ -1054,11 +1058,12 @@ static int atrac3_decode_init(AVCodecContext *avctx)
 
 AVCodec atrac3_decoder =
 {
-    .name = "atrac 3",
+    .name = "atrac3",
     .type = CODEC_TYPE_AUDIO,
     .id = CODEC_ID_ATRAC3,
     .priv_data_size = sizeof(ATRAC3Context),
     .init = atrac3_decode_init,
     .close = atrac3_decode_close,
     .decode = atrac3_decode_frame,
+    .long_name = "Atrac 3 (Adaptive TRansform Acoustic Coding 3)",
 };