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

cmcq subversion at mplayerhq.hu
Tue Jun 2 13:58:23 CEST 2009


Author: cmcq
Date: Tue Jun  2 13:58:23 2009
New Revision: 4376

Log:
Rescale AMR samples from 16-bit PCM values
The samples /A-codecs/amr/{sample,sample2,whatireallywant}.amr now produce
recognizable output. There is still significant distortion.

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

Modified: amr/amrnbfloatdata.h
==============================================================================
--- amr/amrnbfloatdata.h	Mon Jun  1 19:34:02 2009	(r4375)
+++ amr/amrnbfloatdata.h	Tue Jun  2 13:58:23 2009	(r4376)
@@ -38,6 +38,9 @@
 #define AMR_BLOCK_SIZE    160
 #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
+
 // definition of modes for decoder
 #define NO_DATA 15
 enum Mode {

Modified: amr/amrnbfloatdec.c
==============================================================================
--- amr/amrnbfloatdec.c	Mon Jun  1 19:34:02 2009	(r4375)
+++ amr/amrnbfloatdec.c	Tue Jun  2 13:58:23 2009	(r4376)
@@ -871,9 +871,9 @@ static int synthesis(AMRContext *p, floa
 
     for (i = 0; i < AMR_SUBFRAME_SIZE; i++)
         // detect overflow
-        if (fabsf(samples[i]) > 1.0) {
+        if (fabsf(samples[i]) > AMR_SAMPLE_SCALE) {
             overflow_temp = 1;
-            samples[i] = av_clipf(samples[i], -1.0, 1.0);
+            samples[i] = av_clipf(samples[i], -AMR_SAMPLE_SCALE, AMR_SAMPLE_SCALE);
         }
 
     return overflow_temp;
@@ -995,9 +995,9 @@ static int amrnb_decode_frame(AVCodecCon
         // update buffers and history
         update_state(p);
 
-        memcpy(&buf_out[subframe * AMR_SUBFRAME_SIZE],
-               &p->samples_in[LP_FILTER_ORDER],
-               AMR_SUBFRAME_SIZE * sizeof(float));
+        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;
     }
 
     /* report how many samples we got */


More information about the FFmpeg-soc mailing list