Index: apps/codecs/libffmpegFLAC/decoder.c =================================================================== --- apps/codecs/libffmpegFLAC/decoder.c (Revision 31207) +++ apps/codecs/libffmpegFLAC/decoder.c (Arbeitskopie) @@ -536,6 +536,88 @@ DECORRELATE( (a-=b>>1) + b, a) break; } + + /* begin downmix */ + if (s->decorrelation == INDEPENDENT) { + int *FL, *FR, *FC, *SB, *RL, *RR; + int *outL = s->decoded[0]; + int *outR = s->decoded[1]; + switch(s->channels) + { + case 1: /* 1.0 Mono */ + /* do nothing */ + break; + case 2: /* 2.0 FL FR */ + /* do nothing */ + break; + case 3: /* 3.0 FL FR FC */ + FL = s->decoded[0]; + FR = s->decoded[1]; + FC = s->decoded[2]; + /* LF = 0.66 LF + 0.33 FC + LR = 0.66 LR + 0.33 FC */ + for (i=0; iblocksize; ++i) { + int a = *(FL)*2 + *(FC); + int b = *(FR)*2 + *(FC); + *outL++ = a/3; + *outR++ = b/3; + FL++; FR++; FC++; + } + break; + case 4: /* 4.0 FL FR RL RR */ + FL = s->decoded[0]; + FR = s->decoded[1]; + RL = s->decoded[2]; + RR = s->decoded[3]; + /* LF = 0.50 LF + 0.50 RL + 0.00 RR + LR = 0.50 LR + 0.00 RL + 0.50 RR */ + for (i=0; iblocksize; ++i) { + int a = *(FL) + *(RL); + int b = *(FR) + *(RR); + *outL++ = a/2; + *outR++ = b/2; + FL++; FR++; RL++; RR++; + } + break; + case 5: /* 5.0 FL FR FC RL RR */ + FL = s->decoded[0]; + FR = s->decoded[1]; + FC = s->decoded[2]; + RL = s->decoded[3]; + RR = s->decoded[4]; + /* LF = 0.40 LF + 0.20 FC + 0.40 RL + 0.00 RR + LR = 0.40 LR + 0.20 FC + 0.00 RL + 0.40 RR */ + for (i=0; iblocksize; ++i) { + int a = *(FL)*2 + *(FC) + *(RL)*2; + int b = *(FR)*2 + *(FC) + *(RR)*2; + *outL++ = a/5; + *outR++ = b/5; + FL++; FR++; FC++; RL++; RR++; + } + break; + case 6: /* 5.1 FL FR FC SUB RL RR */ + FL = s->decoded[0]; + FR = s->decoded[1]; + FC = s->decoded[2]; + SB = s->decoded[3]; + RL = s->decoded[4]; + RR = s->decoded[5]; + /* LF = 0.33 LF + 0.16 SUB + 0.16 FC + 0.33 RL + 0.00 RR + LR = 0.33 LR + 0.16 SUB + 0.16 FC + 0.00 RL + 0.33 RR */ + for (i=0; iblocksize; ++i) { + int a = *(FL)*2 + *(SB) + *(FC) + *(RL)*2; + int b = *(FR)*2 + *(SB) + *(FC) + *(RR)*2; + *outL++ = a/6; + *outR++ = b/6; + FL++; FR++; SB++; FC++; RL++; RR++; + } + break; + default: /* unknown */ + return -501; + break; + } + } + /* end downmix */ s->framesize = (get_bits_count(&s->gb)+7)>>3; Index: apps/codecs/flac.c =================================================================== --- apps/codecs/flac.c (Revision 31207) +++ apps/codecs/flac.c (Arbeitskopie) @@ -27,7 +27,7 @@ /* The output buffers containing the decoded samples (channels 0 and 1) */ static int32_t decoded0[MAX_BLOCKSIZE] IBSS_ATTR_FLAC_DECODED0; static int32_t decoded1[MAX_BLOCKSIZE] IBSS_ATTR; -static int32_t dummydec[MAX_BLOCKSIZE]; +static int32_t dummydec[4][MAX_BLOCKSIZE]; #define MAX_SUPPORTED_SEEKTABLE_SIZE 5000 @@ -99,7 +99,7 @@ for (ch=2; chdecoded[ch] = dummydec; + fc->decoded[ch] = dummydec[ch-2]; } /* Skip any foreign tags at start of file */