forked from len0rd/rockbox
flac: Implement proper support for 7 channel FLACs
* Allocate buffer for additional channel * Proper downmixing Change-Id: I4190358a93bb328585952affcd42db05b05c19a5
This commit is contained in:
parent
3aef933348
commit
29f28ad8e6
2 changed files with 22 additions and 2 deletions
|
@ -33,6 +33,7 @@ static int32_t decoded2[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_LARGE_IRAM;
|
|||
static int32_t decoded3[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_LARGE_IRAM;
|
||||
static int32_t decoded4[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_XLARGE_IRAM;
|
||||
static int32_t decoded5[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_XLARGE_IRAM;
|
||||
static int32_t decoded6[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_XLARGE_IRAM;
|
||||
|
||||
#define MAX_SUPPORTED_SEEKTABLE_SIZE 5000
|
||||
|
||||
|
@ -99,6 +100,7 @@ static bool flac_init(FLACContext* fc, int first_frame_offset)
|
|||
ci->memset(decoded3, 0, sizeof(decoded3));
|
||||
ci->memset(decoded4, 0, sizeof(decoded4));
|
||||
ci->memset(decoded5, 0, sizeof(decoded5));
|
||||
ci->memset(decoded6, 0, sizeof(decoded5));
|
||||
|
||||
/* Set sample buffers in decoder structure */
|
||||
fc->decoded[0] = decoded0;
|
||||
|
@ -107,7 +109,7 @@ static bool flac_init(FLACContext* fc, int first_frame_offset)
|
|||
fc->decoded[3] = decoded3;
|
||||
fc->decoded[4] = decoded4;
|
||||
fc->decoded[5] = decoded5;
|
||||
|
||||
fc->decoded[6] = decoded6;
|
||||
|
||||
/* Skip any foreign tags at start of file */
|
||||
ci->seek_buffer(first_frame_offset);
|
||||
|
|
|
@ -531,7 +531,7 @@ static int decode_frame(FLACContext *s,
|
|||
static int flac_downmix(FLACContext *s) ICODE_ATTR_FLAC;
|
||||
static int flac_downmix(FLACContext *s)
|
||||
{
|
||||
int32_t *FL, *FR, *FC, *SB, *RL, *RR;
|
||||
int32_t *FL, *FR, *FC, *SB, *RL, *RR, *RC;
|
||||
int32_t *outL = s->decoded[0];
|
||||
int32_t *outR = s->decoded[1];
|
||||
int i, scale=FLAC_OUTPUT_DEPTH-s->bps;
|
||||
|
@ -600,6 +600,24 @@ static int flac_downmix(FLACContext *s)
|
|||
FL++; FR++; SB++; FC++; RL++; RR++;
|
||||
}
|
||||
break;
|
||||
case 7: /* 6.1 channel order: FL FR FC SUB RL RR RC */
|
||||
FL = s->decoded[0];
|
||||
FR = s->decoded[1];
|
||||
FC = s->decoded[2];
|
||||
SB = s->decoded[3];
|
||||
RL = s->decoded[4];
|
||||
RR = s->decoded[5];
|
||||
RC = s->decoded[6];
|
||||
/* LF = 0.28 LF + 0.14 SUB + 0.14 FC + 0.28 RL + 0.00 RR + 0.14 CR
|
||||
LR = 0.28 LR + 0.14 SUB + 0.14 FC + 0.00 RL + 0.28 RR + 0.14 CR */
|
||||
for (i=0; i<s->blocksize; ++i) {
|
||||
int32_t a = *(FL)*2 + *(SB) + *(FC) + *(RL)*2 + *(RC);
|
||||
int32_t b = *(FR)*2 + *(SB) + *(FC) + *(RR)*2 + *(RC);
|
||||
*outL++ = ((a + (a<<4))>>6) << scale; /* 9>>6 ~= 1/7 */
|
||||
*outR++ = ((b + (b<<4))>>6) << scale; /* 9>>6 ~= 1/7 */
|
||||
FL++; FR++; SB++; FC++; RL++; RR++; RC++;
|
||||
}
|
||||
break;
|
||||
default: /* 1.0 and 2.0 do not need downmix, other formats unknown. */
|
||||
return -501;
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue