51 int bs_code, sr_code, bps_code;
54 if ((
get_bits(gb, 15) & 0x7FFF) != 0x7FFC) {
76 "invalid channel mode: %d\n", fi->
ch_mode);
82 if (bps_code == 3 || bps_code == 7) {
84 "invalid sample size code (%d)\n",
93 "broken stream, invalid padding\n");
101 "sample/frame number invalid; utf8 fscked\n");
108 "reserved blocksize code: 0\n");
110 }
else if (bs_code == 6) {
112 }
else if (bs_code == 7) {
121 }
else if (sr_code == 12) {
122 fi->samplerate =
get_bits(gb, 8) * 1000;
123 }
else if (sr_code == 13) {
125 }
else if (sr_code == 14) {
126 fi->samplerate =
get_bits(gb, 16) * 10;
129 "illegal sample rate code %d\n",
139 "header crc mismatch\n");
155 count += ch * ((7+bps+7)/8);
158 count += (( 2*bps+1) * blocksize + 7) / 8;
160 count += ( ch*bps * blocksize + 7) / 8;
189 *streaminfo_start = &avctx->
extradata[8];
209 s->max_blocksize =
get_bits(&gb, 16);
213 s->max_blocksize = 16;
236 int *last,
int *type,
int *
size)
238 int tmp = bytestream_get_byte(&block_header);
244 *size = bytestream_get_be24(&block_header);
void avpriv_flac_parse_block_header(const uint8_t *block_header, int *last, int *type, int *size)
Parse the metadata block parameters from the header.
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_CH_LAYOUT_SURROUND
static void skip_bits_long(GetBitContext *s, int n)
int64_t frame_or_sample_num
frame number or sample number
int ff_flac_get_max_frame_size(int blocksize, int ch, int bps)
Calculate an estimate for the maximum frame size based on verbatim mode.
int avpriv_flac_is_extradata_valid(AVCodecContext *avctx, enum FLACExtradataFormat *format, uint8_t **streaminfo_start)
Validate the FLAC extradata.
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
#define AV_CH_LAYOUT_STEREO
#define AV_CH_LAYOUT_5POINT0
FLACCOMMONINFO int blocksize
block size of the frame
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
static const int8_t sample_size_table[]
static int64_t get_utf8(GetBitContext *gb)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static int get_bits_count(const GetBitContext *s)
bitstream reader API header.
#define MKTAG(a, b, c, d)
static const int64_t flac_channel_layouts[6]
#define FLAC_MIN_BLOCKSIZE
#define AV_CH_LAYOUT_5POINT1
const int16_t ff_flac_blocksize_table[16]
int ch_mode
channel decorrelation mode
FLAC (Free Lossless Audio Codec) decoder/demuxer common functions.
#define AV_CH_LAYOUT_QUAD
void av_log(void *avcl, int level, const char *fmt,...)
void avpriv_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, const uint8_t *buffer)
Parse the Streaminfo metadata block.
int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb, FLACFrameInfo *fi, int log_level_offset)
Validate and decode a frame header.
uint64_t channel_layout
Audio channel layout.
audio channel layout utility functions
#define FLAC_STREAMINFO_SIZE
const int ff_flac_sample_rate_table[16]
int sample_rate
samples per second
main external API structure.
#define GET_UTF8(val, GET_BYTE, ERROR)
void ff_flac_set_channel_layout(AVCodecContext *avctx)
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
#define FF_ARRAY_ELEMS(a)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
int channels
number of audio channels
int is_var_size
specifies if the stream uses variable block sizes or a fixed block size; also determines the meaning ...
#define AV_CH_LAYOUT_MONO
#define FLAC_MAX_CHANNELS