[FFmpeg-soc] [soc]: r4381 - in amr: amrnbfloatdata.h amrnbfloatdec.c

cmcq subversion at mplayerhq.hu
Thu Jun 4 01:05:08 CEST 2009


Author: cmcq
Date: Thu Jun  4 01:05:07 2009
New Revision: 4381

Log:
Use separate constants for clipping and scaling PCM values.

Modified:
   amr/amrnbfloatdata.h
   amr/amrnbfloatdec.c

Modified: amr/amrnbfloatdata.h
==============================================================================
--- amr/amrnbfloatdata.h	Thu Jun  4 01:00:21 2009	(r4380)
+++ amr/amrnbfloatdata.h	Thu Jun  4 01:05:07 2009	(r4381)
@@ -39,7 +39,8 @@
 #define AMR_SUBFRAME_SIZE  40
 
 // AMR is designed to produce 16-bit PCM samples (3GPP TS 26.090 4.2)
-#define AMR_SAMPLE_SCALE 32768.0
+#define AMR_SAMPLE_BOUND 32768.0
+#define AMR_SAMPLE_SCALE (1.0/32768.0)
 
 // definition of modes for decoder
 #define NO_DATA 15

Modified: amr/amrnbfloatdec.c
==============================================================================
--- amr/amrnbfloatdec.c	Thu Jun  4 01:00:21 2009	(r4380)
+++ amr/amrnbfloatdec.c	Thu Jun  4 01:05:07 2009	(r4381)
@@ -872,9 +872,9 @@ static int synthesis(AMRContext *p, floa
 
     for (i = 0; i < AMR_SUBFRAME_SIZE; i++)
         // detect overflow
-        if (fabsf(samples[i]) > AMR_SAMPLE_SCALE) {
+        if (fabsf(samples[i]) > AMR_SAMPLE_BOUND) {
             overflow_temp = 1;
-            samples[i] = av_clipf(samples[i], -AMR_SAMPLE_SCALE, AMR_SAMPLE_SCALE);
+            samples[i] = av_clipf(samples[i], -AMR_SAMPLE_BOUND, AMR_SAMPLE_BOUND);
         }
 
     return overflow_temp;
@@ -998,7 +998,7 @@ static int amrnb_decode_frame(AVCodecCon
 
         for (i = 0; i < AMR_SUBFRAME_SIZE; i++)
             buf_out[subframe * AMR_SUBFRAME_SIZE + i] =
-                p->samples_in[LP_FILTER_ORDER + i] / AMR_SAMPLE_SCALE;
+                p->samples_in[LP_FILTER_ORDER + i] * AMR_SAMPLE_SCALE;
     }
 
     /* report how many samples we got */


More information about the FFmpeg-soc mailing list