changeset 2544:8c426f5a09ae libavcodec

decoder works fine now, when fed properly-sized chunks by the demuxer; cleaned up some cruft for this commit
author melanson
date Sun, 06 Mar 2005 07:00:24 +0000
parents e8f1f57215ad
children 2b9fc44b8615
files alac.c
diffstat 1 files changed, 14 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/alac.c	Sun Mar 06 06:22:24 2005 +0000
+++ b/alac.c	Sun Mar 06 07:00:24 2005 +0000
@@ -132,7 +132,7 @@
     int new_accumulator;
 
     if (alac->input_buffer_index + 2 >= alac->input_buffer_size) {
-        av_log(NULL, AV_LOG_INFO, "alac: input buffer went out of bounds (%d >= %d)\n",
+        av_log(NULL, AV_LOG_ERROR, "alac: input buffer went out of bounds (%d >= %d)\n",
             alac->input_buffer_index + 2, alac->input_buffer_size);
 //        exit (0);
     }
@@ -184,9 +184,9 @@
     int new_accumulator;
 
     if (alac->input_buffer_index >= alac->input_buffer_size) {
-        av_log(NULL, AV_LOG_INFO, "alac: input buffer went out of bounds (%d >= %d)\n",
+        av_log(NULL, AV_LOG_ERROR, "alac: input buffer went out of bounds (%d >= %d)\n",
             alac->input_buffer_index + 2, alac->input_buffer_size);
-//        exit (0);
+        exit (0);
     }
 
     result = alac->input_buffer[alac->input_buffer_index];
@@ -508,14 +508,6 @@
             left = (midright - ((difference * interlacing_leftweight) >> interlacing_shift))
                  + difference;
 
-            /* output is always little endian */
-/*
-            if (host_bigendian) {
-                be2me_16(left);
-                be2me_16(right);
-            }
-*/
-
             buffer_out[i*numchannels] = left;
             buffer_out[i*numchannels + 1] = right;
         }
@@ -530,27 +522,25 @@
         left = buffer_a[i];
         right = buffer_b[i];
 
-        /* output is always little endian */
-/*
-        if (host_bigendian) {
-            be2me_16(left);
-            be2me_16(right);
-        }
-*/
-
         buffer_out[i*numchannels] = left;
         buffer_out[i*numchannels + 1] = right;
     }
 }
 
-int decode_frame(ALACContext *s, alac_file *alac,
-                  unsigned char *inbuffer,
-                  int input_buffer_size,
-                  void *outbuffer, int *outputsize)
+static int alac_decode_frame(AVCodecContext *avctx,
+                             void *outbuffer, int *outputsize,
+                             uint8_t *inbuffer, int input_buffer_size)
 {
+    ALACContext *s = avctx->priv_data;
+    alac_file *alac = s->alac;
+
     int channels;
     int32_t outputsamples;
 
+    /* short-circuit null buffers */
+    if (!inbuffer || !input_buffer_size)
+        return input_buffer_size;
+
     /* initialize from the extradata */
     if (!s->context_initialized) {
         if (s->avctx->extradata_size != ALAC_EXTRADATA_SIZE) {
@@ -906,15 +896,7 @@
     }
     }
 
-av_log(NULL, AV_LOG_INFO, "buf size = %d, consumed %d\n",
-  input_buffer_size, alac->input_buffer_index);
-
-    /* avoid infinite loop: if decoder consumed 0 bytes; report all bytes
-     * consumed */
-//    if (alac->input_buffer_index)
-//        return alac->input_buffer_index;
-//    else
-        return input_buffer_size;
+    return input_buffer_size;
 }
 
 static int alac_decode_init(AVCodecContext * avctx)
@@ -932,20 +914,6 @@
     return 0;
 }
 
-static int alac_decode_frame(AVCodecContext *avctx,
-                             void *data, int *data_size,
-                             uint8_t *buf, int buf_size)
-{
-    ALACContext *s = avctx->priv_data;
-    int bytes_consumed = buf_size;
-
-    if (buf)
-        bytes_consumed = decode_frame(s, s->alac, buf, buf_size, 
-            data, data_size);
-
-    return bytes_consumed;
-}
-
 static int alac_decode_close(AVCodecContext *avctx)
 {
     ALACContext *s = avctx->priv_data;