diff options
Diffstat (limited to 'apps/codecs/flac.c')
-rw-r--r-- | apps/codecs/flac.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/apps/codecs/flac.c b/apps/codecs/flac.c index c91a173f4a..72bb26663a 100644 --- a/apps/codecs/flac.c +++ b/apps/codecs/flac.c | |||
@@ -27,6 +27,7 @@ CODEC_HEADER | |||
27 | /* The output buffers containing the decoded samples (channels 0 and 1) */ | 27 | /* The output buffers containing the decoded samples (channels 0 and 1) */ |
28 | static int32_t decoded0[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_DECODED0; | 28 | static int32_t decoded0[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_DECODED0; |
29 | static int32_t decoded1[MAX_BLOCKSIZE] IBSS_ATTR; | 29 | static int32_t decoded1[MAX_BLOCKSIZE] IBSS_ATTR; |
30 | static int32_t dummydec[MAX_BLOCKSIZE]; | ||
30 | 31 | ||
31 | #define MAX_SUPPORTED_SEEKTABLE_SIZE 5000 | 32 | #define MAX_SUPPORTED_SEEKTABLE_SIZE 5000 |
32 | 33 | ||
@@ -80,11 +81,26 @@ static bool flac_init(FLACContext* fc, int first_frame_offset) | |||
80 | uint16_t blocksize; | 81 | uint16_t blocksize; |
81 | int endofmetadata=0; | 82 | int endofmetadata=0; |
82 | uint32_t blocklength; | 83 | uint32_t blocklength; |
84 | int ch; | ||
83 | 85 | ||
84 | ci->memset(fc,0,sizeof(FLACContext)); | 86 | ci->memset(fc,0,sizeof(FLACContext)); |
85 | nseekpoints=0; | 87 | nseekpoints=0; |
86 | 88 | ||
87 | fc->sample_skip = 0; | 89 | fc->sample_skip = 0; |
90 | |||
91 | /* Reset sample buffers */ | ||
92 | memset(decoded0, 0, sizeof(decoded0)); | ||
93 | memset(decoded1, 0, sizeof(decoded1)); | ||
94 | memset(dummydec, 0, sizeof(dummydec)); | ||
95 | |||
96 | /* Set sample buffers in decoder structure */ | ||
97 | fc->decoded[0] = decoded0; | ||
98 | fc->decoded[1] = decoded1; | ||
99 | for (ch=2; ch<MAX_CHANNELS; ++ch) | ||
100 | { | ||
101 | /* Only channel 0 and 1 are used, the other are decoded to scratch */ | ||
102 | fc->decoded[ch] = dummydec; | ||
103 | } | ||
88 | 104 | ||
89 | /* Skip any foreign tags at start of file */ | 105 | /* Skip any foreign tags at start of file */ |
90 | ci->seek_buffer(first_frame_offset); | 106 | ci->seek_buffer(first_frame_offset); |
@@ -231,7 +247,7 @@ static bool frame_sync(FLACContext* fc) { | |||
231 | /* Decode the frame to verify the frame crc and | 247 | /* Decode the frame to verify the frame crc and |
232 | * fill fc with its metadata. | 248 | * fill fc with its metadata. |
233 | */ | 249 | */ |
234 | if(flac_decode_frame(fc, decoded0, decoded1, | 250 | if(flac_decode_frame(fc, |
235 | bit_buffer, buff_size, ci->yield) < 0) { | 251 | bit_buffer, buff_size, ci->yield) < 0) { |
236 | return false; | 252 | return false; |
237 | } | 253 | } |
@@ -485,7 +501,7 @@ enum codec_status codec_run(void) | |||
485 | ci->seek_complete(); | 501 | ci->seek_complete(); |
486 | } | 502 | } |
487 | 503 | ||
488 | if((res=flac_decode_frame(&fc,decoded0,decoded1,buf, | 504 | if((res=flac_decode_frame(&fc,buf, |
489 | bytesleft,ci->yield)) < 0) { | 505 | bytesleft,ci->yield)) < 0) { |
490 | LOGF("FLAC: Frame %d, error %d\n",frame,res); | 506 | LOGF("FLAC: Frame %d, error %d\n",frame,res); |
491 | return CODEC_ERROR; | 507 | return CODEC_ERROR; |
@@ -494,7 +510,7 @@ enum codec_status codec_run(void) | |||
494 | frame++; | 510 | frame++; |
495 | 511 | ||
496 | ci->yield(); | 512 | ci->yield(); |
497 | ci->pcmbuf_insert(&decoded0[fc.sample_skip], &decoded1[fc.sample_skip], | 513 | ci->pcmbuf_insert(&fc.decoded[0][fc.sample_skip], &fc.decoded[1][fc.sample_skip], |
498 | fc.blocksize - fc.sample_skip); | 514 | fc.blocksize - fc.sample_skip); |
499 | 515 | ||
500 | fc.sample_skip = 0; | 516 | fc.sample_skip = 0; |