]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/ra144.c
WV1F support
[ffmpeg] / libavcodec / ra144.c
index b4588f799f27cedc87123dcd8b355f8d8f183c20..79cce2cef62bf9d625121ea3b494fe5a47e9896a 100644 (file)
@@ -130,7 +130,7 @@ static void do_voice(int *a1, int *a2)
 
 
 /* do quarter-block output */
-static void do_output_subblock(Real144_internal *glob, int x)
+static void do_output_subblock(Real144_internal *glob, unsigned int x)
 {
   int a,b,c,d,e,f,g;
 
@@ -185,7 +185,6 @@ static int irms(short *data, int factor)
 static void add_wav(Real144_internal *glob, int n, int f, int m1, int m2, int m3, short *s1, short *s2, short *s3, short *dest)
 {
   int a,b,c;
-  int x;
   short *ptr,*ptr2;
 
   ptr=glob->wavtable1+n*9;
@@ -308,7 +307,6 @@ static unsigned int rms(int *data, int f)
 {
   int *c;
   int x;
-  int d;
   unsigned int res;
   int b;
 
@@ -426,7 +424,7 @@ static void dec2(Real144_internal *glob, int *data, int *inp, int n, int f, int
 
 /* Uncompress one block (20 bytes -> 160*2 bytes) */
 static int ra144_decode_frame(AVCodecContext * avctx,
-            void *data, int *data_size,
+            void *vdata, int *data_size,
             uint8_t * buf, int buf_size)
 {
   unsigned int a,b,c;
@@ -434,9 +432,13 @@ static int ra144_decode_frame(AVCodecContext * avctx,
   signed short *shptr;
   unsigned int *lptr,*temp;
   const short **dptr;
-  void *datao;
+  int16_t *datao;
+  int16_t *data = vdata;
   Real144_internal *glob=avctx->priv_data;
 
+  if(buf_size==0)
+      return 0;
+  
   datao = data;
   unpack_input(buf,glob->unpacked);
   
@@ -482,10 +484,10 @@ static int ra144_decode_frame(AVCodecContext * avctx,
     shptr=glob->output_buffer;
     while (shptr<glob->output_buffer+BLOCKSIZE) {
       s=*(shptr++)<<2;
-      *((int16_t *)data)=s;
-      if (s>32767) *((int16_t *)data)=32767;
-      if (s<-32767) *((int16_t *)data)=-32768;
-      ((int16_t *)data)++;
+      *data=s;
+      if (s>32767) *data=32767;
+      if (s<-32767) *data=-32768;
+      data++;
     }
     b+=30;
   }
@@ -497,7 +499,7 @@ static int ra144_decode_frame(AVCodecContext * avctx,
   temp=glob->swapbuf2alt;
   glob->swapbuf2alt=glob->swapbuf2;
   glob->swapbuf2=temp;
-  *data_size=data-datao;
+  *data_size=(data-datao)*sizeof(*data);
   return 20;
 }