Skip to content

Commit

Permalink
It works !!!!
Browse files Browse the repository at this point in the history
- Put correct value to CONFIG_MAIN_TASK_STACK_SIZE=65000
  • Loading branch information
commarmi76 committed Apr 23, 2017
1 parent 6808d05 commit 89737b4
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 15 deletions.
Binary file modified Sample16kHz.raw
Binary file not shown.
3 changes: 2 additions & 1 deletion components/libmp3lame/library/bitstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -987,10 +987,11 @@ format_bitstream(lame_internal_flags * gfc)
static int
do_gain_analysis(lame_internal_flags * gfc, unsigned char* buffer, int minimum)
{
#ifdef DECODE_ON_THE_FLY
SessionConfig_t const *const cfg = &gfc->cfg;
RpgStateVar_t const *const rsv = &gfc->sv_rpg;
RpgResult_t *const rov = &gfc->ov_rpg;
#ifdef DECODE_ON_THE_FLY

if (cfg->decode_on_the_fly) { /* decode the frame */
sample_t pcm_buf[2][1152];
int mp3_in = minimum;
Expand Down
4 changes: 2 additions & 2 deletions components/libmp3lame/library/gain_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ ResetSampleFrequency(replaygain_t * rgData, long samplefreq)

for (int i=0; i<12000; i++)
{
gfc->sv_rpg.rgdata->A[i]=0;
rgData->A[i]=0;
}


Expand All @@ -316,7 +316,7 @@ InitGainAnalysis(replaygain_t * rgData, long samplefreq)

for (int i=0; i<12000; i++)
{
gfc->sv_rpg.rgdata->B[i]=0;
rgData->B[i]=0;
}

return INIT_GAIN_ANALYSIS_OK;
Expand Down
3 changes: 2 additions & 1 deletion components/libmp3lame/library/quantize_pvt.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,14 @@ iteration_init(lame_internal_flags * gfc)
adj43asm[i] = i - 0.5 - pow(0.5 * (pow43[i - 1] + pow43[i]), 0.75);
#else
for (i = 0; i < PRECALC_SIZE - 1; i++){
if (0.5 * (pow43[i] + pow43[i + 1]) == 0) adj43[i] = (i + 1);
// if (0.5 * (pow43[i] + pow43[i + 1]) == 0) adj43[i] = (i + 1);
adj43[i] = (i + 1) - pow(0.5 * (pow43[i] + pow43[i + 1]), 0.75);
}
adj43[i] = 0.5;
#endif
for (i = 0; i < Q_MAX; i++)
ipow20[i] = pow(2.0, (double) (i - 210) * -0.1875);

for (i = 0; i <= Q_MAX + Q_MAX2; i++)
pow20[i] = pow(2.0, (double) (i - 210 - Q_MAX2) * 0.25);

Expand Down
24 changes: 14 additions & 10 deletions main/lame_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include <stdlib.h>
#include <string.h>

#include "machine.h"
#define Q_MAX (256+1)
extern FLOAT ipow20[Q_MAX];

extern const uint8_t Sample16kHz_raw_start[] asm("_binary_Sample16kHz_raw_start");
extern const uint8_t Sample16kHz_raw_end[] asm("_binary_Sample16kHz_raw_end");

Expand All @@ -22,15 +26,15 @@ void lameTest()
int framesize = 0;
int num_samples_encoded = 0, total=0;
size_t free8start, free32start;
const int nsamples=1152;
int nsamples=1152;
unsigned char *mp3buf;
const int mp3buf_size=2000;
const int mp3buf_size=2000; //mp3buf_size in bytes = 1.25*num_samples + 7200

free8start=xPortGetFreeHeapSizeCaps(MALLOC_CAP_8BIT);
free8start=xPortGetFreeHeapSizeCaps(MALLOC_CAP_8BIT);
free32start=xPortGetFreeHeapSizeCaps(MALLOC_CAP_32BIT);
printf("pre lame_init() free mem8bit: %d mem32bit: %d\n",free8start,free32start);

mp3buf=malloc(mp3buf_size*sizeof(int));
mp3buf=malloc(mp3buf_size);

/* Init lame flags.*/
lame = lame_init();
Expand Down Expand Up @@ -81,15 +85,15 @@ void lameTest()
pcm_samples = (short int *)Sample16kHz_raw_start;
pcm_samples_end = (short int *)Sample16kHz_raw_end;

while ( (pcm_samples_end - pcm_samples) > 0)
while ( pcm_samples_end - pcm_samples > 0)
//for (int j=0;j<1;j++)
{
// printf("\n=============== lame_encode_buffer_interleaved================ \n");

printf("\n=============== lame_encode_buffer_interleaved================ \n");
/* encode samples. */

num_samples_encoded = lame_encode_buffer_interleaved(lame, pcm_samples, nsamples, mp3buf, mp3buf_size);

// printf("number of samples encoded = %d\n", num_samples_encoded);
printf("number of samples encoded = %d pcm_samples %p \n", num_samples_encoded, pcm_samples);

/* check for value returned.*/
if(num_samples_encoded > 1) {
Expand All @@ -115,10 +119,10 @@ void lameTest()

// printf("Contents of mp3buffer = ");
for(int i = 0; i < num_samples_encoded; i++) {
printf("%02X ", mp3buf[i]);
printf("%02X", mp3buf[i]);
}

pcm_samples += nsamples; // nsamples*2 ????
pcm_samples += (nsamples*2); // nsamples*2 ????

}

Expand Down
2 changes: 1 addition & 1 deletion sdkconfig
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ CONFIG_FOUR_MAC_ADDRESS_FROM_EFUSE=y
CONFIG_NUMBER_OF_MAC_ADDRESS_GENERATED_FROM_EFUSE=4
CONFIG_SYSTEM_EVENT_QUEUE_SIZE=64
CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=4096
CONFIG_MAIN_TASK_STACK_SIZE=204800
CONFIG_MAIN_TASK_STACK_SIZE=65000
CONFIG_NEWLIB_STDOUT_ADDCR=y
# CONFIG_NEWLIB_NANO_FORMAT is not set
CONFIG_CONSOLE_UART_DEFAULT=y
Expand Down
Binary file added t1fromraw.mp3
Binary file not shown.

0 comments on commit 89737b4

Please sign in to comment.