[soc]: r4376 - in amr: amrnbfloatdata.h amrnbfloatdec.c
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 */
cmcq wrote:
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.
Great! :D
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
Maybe have: #define AMR_SAMPLE_BOUND 32768.0 #define AMR_SAMPLE_SCALE 1.0/32768.0 and edit the other code accordingly so that you can use * rather than /. We may have some suitable dsputil function for this anyway so it's not massively important. Michael would have a suggestion about it later I expect. Regards, Rob
2009/6/2 Robert Swain <robert.swain@gmail.com>:
cmcq wrote:
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.
Great! :D
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
Maybe have:
#define AMR_SAMPLE_BOUND 32768.0 #define AMR_SAMPLE_SCALE 1.0/32768.0
and edit the other code accordingly so that you can use * rather than /. We may have some suitable dsputil function for this anyway so it's not massively important. Michael would have a suggestion about it later I expect.
Regards, Rob
Since most of the processes are linear, I should be able to scale the innovative vectors definitions in amrnbfloatdata.h. However, I need to investigate what other effects this will have. Do you have any scripts to help generate amrnbfloatdata.h except reformat.pl?
Colin McQuillan wrote:
2009/6/2 Robert Swain <robert.swain@gmail.com>:
cmcq wrote:
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. Great! :D
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 Maybe have:
#define AMR_SAMPLE_BOUND 32768.0 #define AMR_SAMPLE_SCALE 1.0/32768.0
and edit the other code accordingly so that you can use * rather than /. We may have some suitable dsputil function for this anyway so it's not massively important. Michael would have a suggestion about it later I expect.
Since most of the processes are linear, I should be able to scale the innovative vectors definitions in amrnbfloatdata.h. However, I need to investigate what other effects this will have.
OK.
Do you have any scripts to help generate amrnbfloatdata.h except reformat.pl?
I'll have a look around but I think that's all I used and just edited it accordingly. Regards, Rob
participants (3)
-
cmcq -
Colin McQuillan -
Robert Swain