mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2026-01-31 14:51:11 +03:00
Initial commit
faad does not work yet
This commit is contained in:
29
main/faad.c
29
main/faad.c
@@ -23,6 +23,12 @@
|
||||
|
||||
#include <neaacdec.h>
|
||||
|
||||
#if BYTES_PER_FRAME == 4
|
||||
#define ALIGN(n) (n)
|
||||
#else
|
||||
#define ALIGN(n) (n << 8)
|
||||
#endif
|
||||
|
||||
#define WRAPBUF_LEN 2048
|
||||
|
||||
struct chunk_table {
|
||||
@@ -315,7 +321,7 @@ static decode_state faad_decode(void) {
|
||||
size_t bytes_total;
|
||||
size_t bytes_wrap;
|
||||
static NeAACDecFrameInfo info;
|
||||
s32_t *iptr;
|
||||
ISAMPLE_T *iptr;
|
||||
bool endstream;
|
||||
frames_t frames;
|
||||
|
||||
@@ -491,29 +497,35 @@ static decode_state faad_decode(void) {
|
||||
while (frames > 0) {
|
||||
frames_t f;
|
||||
frames_t count;
|
||||
s32_t *optr;
|
||||
ISAMPLE_T *optr;
|
||||
|
||||
IF_DIRECT(
|
||||
f = _buf_cont_write(outputbuf) / BYTES_PER_FRAME;
|
||||
optr = (s32_t *)outputbuf->writep;
|
||||
optr = (ISAMPLE_T *)outputbuf->writep;
|
||||
);
|
||||
IF_PROCESS(
|
||||
f = process.max_in_frames;
|
||||
optr = (s32_t *)process.inbuf;
|
||||
optr = (ISAMPLE_T *)process.inbuf;
|
||||
);
|
||||
|
||||
f = min(f, frames);
|
||||
count = f;
|
||||
|
||||
if (info.channels == 2) {
|
||||
#if BYTES_PER_FRAME == 4
|
||||
memcpy(optr, iptr, count * BYTES_PER_FRAME);
|
||||
iptr += count * 2;
|
||||
optr += count * 2;
|
||||
#else
|
||||
while (count--) {
|
||||
*optr++ = *iptr++ << 8;
|
||||
*optr++ = *iptr++ << 8;
|
||||
}
|
||||
#endif
|
||||
} else if (info.channels == 1) {
|
||||
while (count--) {
|
||||
*optr++ = *iptr << 8;
|
||||
*optr++ = *iptr++ << 8;
|
||||
*optr++ = ALIGN(*iptr);
|
||||
*optr++ = ALIGN(*iptr++);
|
||||
}
|
||||
} else {
|
||||
LOG_WARN("unsupported number of channels");
|
||||
@@ -563,7 +575,12 @@ static void faad_open(u8_t size, u8_t rate, u8_t chan, u8_t endianness) {
|
||||
|
||||
conf = NEAAC(a, GetCurrentConfiguration, a->hAac);
|
||||
|
||||
#if BYTES_PER_FRAME == 4
|
||||
conf->outputFormat = FAAD_FMT_16BIT;
|
||||
#else
|
||||
conf->outputFormat = FAAD_FMT_24BIT;
|
||||
#endif
|
||||
conf->defSampleRate = 44100;
|
||||
conf->downMatrix = 1;
|
||||
|
||||
if (!NEAAC(a, SetConfiguration, a->hAac, conf)) {
|
||||
|
||||
Reference in New Issue
Block a user