1
0
Fork 0
forked from len0rd/rockbox
foxbox/lib/rbcodec/codecs/libffmpegFLAC/decoder.h
Solomon Peachy a98a8ce131 FLAC: Conditionally increase MAX_BLOCKSIZE to 8KB
High-frequency files increasingly use a block size of over 4608B, which
means we need larger buffers to decode them.  However, larger buffers no
longer fit in IRAM on less-capable devices, hurting performance for
"normal" file playback.

On our slowest devices (M68K and PP-based devices), this is not worth
the tradeoff as they will likely not have enough CPU oomph to decode and
downmix these files in realtime.

S5L87xx-based devices have the raw performance to do this, so we decided
to err on the side of wider file compatibility at the cost of some
performance.

All other devices are unaffected.

Change-Id: I7344cf4c8c6b7b5c14f1ea67381160665d6ece5b
2025-09-08 22:51:46 -04:00

52 lines
1.3 KiB
C

#ifndef _FLAC_DECODER_H
#define _FLAC_DECODER_H
#include "bitstream.h"
#define MAX_CHANNELS 7 /* Maximum supported channels, only left/right will be played back */
#ifndef MAX_BLOCKSIZE
#define MAX_BLOCKSIZE 4608 /* Maxsize in samples of one uncompressed frame */
#endif
#define MAX_FRAMESIZE 65536 /* Maxsize in bytes of one compressed frame */
#define MIN_FRAME_SIZE 11 /* smallest valid FLAC frame possible */
#define FLAC_OUTPUT_DEPTH 29 /* Provide samples left-shifted to 28 bits+sign */
enum decorrelation_type {
INDEPENDENT,
LEFT_SIDE,
RIGHT_SIDE,
MID_SIDE,
};
typedef struct FLACContext {
GetBitContext gb;
int min_blocksize, max_blocksize;
int min_framesize, max_framesize;
int samplerate, channels;
int blocksize/*, last_blocksize*/;
int bps;
unsigned long samplenumber;
unsigned long totalsamples;
enum decorrelation_type ch_mode;
int filesize;
int length;
int bitrate;
int metadatalength;
int bitstream_size;
int bitstream_index;
int sample_skip;
int framesize;
int32_t *decoded[MAX_CHANNELS];
} FLACContext;
int flac_decode_frame(FLACContext *s,
uint8_t *buf, int buf_size,
void (*yield)(void)) ICODE_ATTR_FLAC;
#endif