80     if (need32 || want32) {
 
  155     return ret < 0 ? ret : 0;
 
  167     int metadata_type, metadata_size, ret;
 
  198     int metadata_last, metadata_size;
 
  199     const uint8_t *buf_end = buf + buf_size;
 
  203         if (buf_end - buf < 4)
 
  207         if (buf_end - buf < metadata_size) {
 
  211         buf += metadata_size;
 
  212     } 
while (!metadata_last);
 
  214     return buf_size - (buf_end - 
buf);
 
  219     int i, 
tmp, partition, method_type, rice_order;
 
  220     int rice_bits, rice_esc;
 
  224     if (method_type > 1) {
 
  233     if (samples << rice_order != s->
blocksize) {
 
  239     if (pred_order > samples) {
 
  241                pred_order, samples);
 
  245     rice_bits = 4 + method_type;
 
  246     rice_esc  = (1 << rice_bits) - 1;
 
  248     decoded += pred_order;
 
  250     for (partition = 0; partition < (1 << rice_order); partition++) {
 
  252         if (tmp == rice_esc) {
 
  254             for (; i < samples; i++)
 
  257             for (; i < samples; i++) {
 
  268                                  int pred_order, 
int bps)
 
  275     for (i = 0; i < pred_order; i++) {
 
  283         a = decoded[pred_order-1];
 
  285         b = 
a - decoded[pred_order-2];
 
  287         c = 
b - decoded[pred_order-2] + decoded[pred_order-3];
 
  289         d = 
c - decoded[pred_order-2] + 2*decoded[pred_order-3] - decoded[pred_order-4];
 
  291     switch (pred_order) {
 
  295         for (i = pred_order; i < blocksize; i++)
 
  296             decoded[i] = 
a += decoded[i];
 
  299         for (i = pred_order; i < blocksize; i++)
 
  300             decoded[i] = 
a += 
b += decoded[i];
 
  303         for (i = pred_order; i < blocksize; i++)
 
  304             decoded[i] = 
a += 
b += 
c += decoded[i];
 
  307         for (i = pred_order; i < blocksize; i++)
 
  308             decoded[i] = 
a += 
b += 
c += d += decoded[i];
 
  319                                    int order, 
int qlevel, 
int len, 
int bps)
 
  322     int ebps = 1 << (bps-1);
 
  325     for (i = order; i < 
len; i++)
 
  326         sigma |= decoded[i] + ebps;
 
  331     for (i = len - 1; i >= order; i--) {
 
  333         for (j = 0; j < order; j++)
 
  334             p += coeffs[j] * (int64_t)decoded[i-order+j];
 
  335         decoded[i] -= p >> qlevel;
 
  337     for (i = order; i < 
len; i++, decoded++) {
 
  339         for (j = 0; j < order; j++)
 
  340             p += coeffs[j] * (uint32_t)decoded[j];
 
  341         decoded[j] += p >> qlevel;
 
  349     int coeff_prec, qlevel;
 
  353     for (i = 0; i < pred_order; i++) {
 
  358     if (coeff_prec == 16) {
 
  369     for (i = 0; i < pred_order; i++) {
 
  370         coeffs[pred_order - i - 1] = 
get_sbits(&s->
gb, coeff_prec);
 
  378             && bps + coeff_prec + 
av_log2(pred_order) <= 32)) {
 
  392     int type, wasted = 0;
 
  416                    "Invalid number of wasted bits > available bits (%d) - left=%d\n",
 
  433     } 
else if (type == 1) {
 
  436     } 
else if ((type >= 8) && (type <= 12)) {
 
  439     } 
else if (type >= 32) {
 
  450             decoded[i] <<= wasted;
 
  509                                         " or frame header\n");
 
  512     if (fi.samplerate == 0)
 
  543                              int *got_frame_ptr, 
AVPacket *avpkt)
 
  548     int buf_size = avpkt->
size;
 
  561     if (buf_size > 5 && !memcmp(buf, 
"\177FLAC", 5)) {
 
  597                0, buf, bytes_read)) {
 
  612     if (bytes_read > buf_size) {
 
  616     if (bytes_read < buf_size) {
 
  618                buf_size - bytes_read, buf_size);
 
static unsigned int show_bits_long(GetBitContext *s, int n)
Show 0-32 bits. 
 
static int get_sr_golomb_flac(GetBitContext *gb, int k, int limit, int esc_len)
read signed golomb rice code (flac). 
 
#define AVERROR_INVALIDDATA
Invalid data found when processing input. 
 
This structure describes decoded (raw) audio or video data. 
 
ptrdiff_t const GLvoid * data
 
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits. 
 
static int init_thread_copy(AVCodecContext *avctx)
 
#define LIBAVUTIL_VERSION_INT
 
av_cold void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt, int channels, int bps)
 
static av_cold int init(AVCodecContext *avctx)
 
static int allocate_buffers(FLACContext *s)
 
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. 
 
#define AV_OPT_FLAG_AUDIO_PARAM
 
#define AV_EF_COMPLIANT
consider all spec non compliances as errors 
 
AVCodecContext * avctx
parent AVCodecContext 
 
#define FLAC_MAX_BLOCKSIZE
 
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format. 
 
static int decode_residuals(FLACContext *s, int32_t *decoded, int pred_order)
 
FLACCOMMONINFO int blocksize
block size of the frame 
 
static int get_sbits(GetBitContext *s, int n)
 
int ff_flac_is_extradata_valid(AVCodecContext *avctx, enum FLACExtradataFormat *format, uint8_t **streaminfo_start)
Validate the FLAC extradata. 
 
static int get_sbits_long(GetBitContext *s, int n)
Read 0-32 bits as a signed integer. 
 
#define av_assert0(cond)
assert() equivalent, that is always enabled. 
 
void(* lpc32)(int32_t *samples, const int coeffs[32], int order, int qlevel, int len)
 
enum AVSampleFormat sample_fmt
audio sample format 
 
static const AVClass flac_decoder_class
 
Multithreading support functions. 
 
uint8_t * extradata
some codecs need / can use extradata like Huffman tables. 
 
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
 
static void flac_set_bps(FLACContext *s)
 
static int get_bits_count(const GetBitContext *s)
 
bitstream reader API header. 
 
unsigned int decoded_buffer_size
 
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar. 
 
static int get_bits_left(GetBitContext *gb)
 
int32_t * decoded[FLAC_MAX_CHANNELS]
decoded samples 
 
int ch_mode
channel decorrelation mode 
 
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered. 
 
FLAC (Free Lossless Audio Codec) decoder/demuxer common functions. 
 
enum AVSampleFormat request_sample_fmt
desired sample format 
 
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
 
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers. 
 
static int decode_subframe_lpc(FLACContext *s, int32_t *decoded, int pred_order, int bps)
 
simple assert() macros that are a bit more flexible than ISO C assert(). 
 
static int get_metadata_size(const uint8_t *buf, int buf_size)
Determine the size of an inline header. 
 
GetBitContext gb
GetBitContext initialized to start at the current frame. 
 
const char * name
Name of the codec implementation. 
 
static void dump_headers(AVCodecContext *avctx, FLACStreaminfo *s)
 
int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb, FLACFrameInfo *fi, int log_level_offset)
Validate and decode a frame header. 
 
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading. 
 
static int decode_subframe_fixed(FLACContext *s, int32_t *decoded, int pred_order, int bps)
 
uint64_t channel_layout
Audio channel layout. 
 
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified. 
 
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors. 
 
int buggy_lpc
use workaround for old lavc encoded files 
 
int got_streaminfo
indicates if the STREAMINFO has been read 
 
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block. 
 
static void lpc_analyze_remodulate(int32_t *decoded, const int coeffs[32], int order, int qlevel, int len, int bps)
 
#define FLAC_STREAMINFO_SIZE
 
#define AV_EF_EXPLODE
abort decoding on minor error detection 
 
int sample_shift
shift required to make output samples 16-bit or 32-bit 
 
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome. 
 
Libavcodec external API header. 
 
AVSampleFormat
Audio sample formats. 
 
int sample_rate
samples per second 
 
static const AVOption options[]
 
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext. 
 
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs. 
 
static int decode_frame(FLACContext *s)
 
main external API structure. 
 
void ff_flac_set_channel_layout(AVCodecContext *avctx)
 
static unsigned int get_bits1(GetBitContext *s)
 
void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, const uint8_t *buffer)
Parse the Streaminfo metadata block. 
 
static const char * format
 
Describe the class of an AVClass context structure. 
 
static void skip_bits(GetBitContext *s, int n)
 
int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Get the required buffer size for the given audio parameters. 
 
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding 
 
static av_always_inline void flac_parse_block_header(const uint8_t *block_header, int *last, int *type, int *size)
Parse the metadata block parameters from the header. 
 
#define AV_EF_CRCCHECK
Verify checksums embedded in the bitstream (could be of either encoded or decoded data...
 
static int parse_streaminfo(FLACContext *s, const uint8_t *buf, int buf_size)
Parse the STREAMINFO from an inline header. 
 
struct FLACStreaminfo flac_stream_info
 
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature. 
 
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes. 
 
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample. 
 
int blocksize
number of samples in the current frame 
 
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table. 
 
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
 
static int decode_subframe(FLACContext *s, int channel)
 
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough. 
 
void(* lpc16)(int32_t *samples, const int coeffs[32], int order, int qlevel, int len)
 
common internal api header. 
 
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length. 
 
#define FLAC_MIN_FRAME_SIZE
 
#define MKBETAG(a, b, c, d)
 
int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, const uint8_t *buf, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Fill plane data pointers and linesize for samples with sample format sample_fmt. 
 
static const int16_t coeffs[]
 
int channels
number of audio channels 
 
static const uint8_t * align_get_bits(GetBitContext *s)
 
static av_cold int flac_decode_init(AVCodecContext *avctx)
 
This structure stores compressed data. 
 
int nb_samples
number of audio samples (per channel) described by this frame 
 
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators. 
 
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
 
void(* decorrelate[4])(uint8_t **out, int32_t **in, int channels, int len, int shift)
 
#define FLAC_MAX_CHANNELS
 
static av_cold int flac_decode_close(AVCodecContext *avctx)
 
int ch_mode
channel decorrelation type in the current frame 
 
static int flac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)