flac.c File Reference
#include "libavutil/channel_layout.h"
#include "libavutil/crc.h"
#include "libavutil/log.h"
#include "bytestream.h"
#include "get_bits.h"
#include "flac.h"
#include "flacdata.h"
Include dependency graph for flac.c:

Go to the source code of this file.

Functions

static int64_t get_utf8 (GetBitContext *gb)
 
int ff_flac_decode_frame_header (AVCodecContext *avctx, GetBitContext *gb, FLACFrameInfo *fi, int log_level_offset)
 Validate and decode a frame header. More...
 
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. More...
 
int avpriv_flac_is_extradata_valid (AVCodecContext *avctx, enum FLACExtradataFormat *format, uint8_t **streaminfo_start)
 Validate the FLAC extradata. More...
 
void ff_flac_set_channel_layout (AVCodecContext *avctx)
 
void avpriv_flac_parse_streaminfo (AVCodecContext *avctx, struct FLACStreaminfo *s, const uint8_t *buffer)
 Parse the Streaminfo metadata block. More...
 
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. More...
 

Variables

static const int8_t sample_size_table [] = { 0, 8, 12, 0, 16, 20, 24, 0 }
 
static const uint64_t flac_channel_layouts [8]
 

Function Documentation

int avpriv_flac_is_extradata_valid ( AVCodecContext avctx,
enum FLACExtradataFormat format,
uint8_t **  streaminfo_start 
)

Validate the FLAC extradata.

Parameters
[in]avctxcodec context containing the extradata.
[out]formatextradata format.
[out]streaminfo_startpointer to start of 34-byte STREAMINFO data.
Returns
1 if valid, 0 if not valid.

Definition at line 169 of file flac.c.

Referenced by ff_flac_write_header(), flac_decode_init(), flac_write_trailer(), and ogg_build_flac_headers().

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.

Parameters
[in]block_headerheader data, at least 4 bytes
[out]lastindicator for last metadata block
[out]typemetadata block type
[out]sizemetadata block size

Definition at line 236 of file flac.c.

Referenced by flac_read_header(), get_metadata_size(), and parse_streaminfo().

void avpriv_flac_parse_streaminfo ( AVCodecContext avctx,
struct FLACStreaminfo s,
const uint8_t buffer 
)

Parse the Streaminfo metadata block.

Parameters
[out]avctxcodec context to set basic stream parameters
[out]swhere parsed information is stored
[in]bufferpointer to start of 34-byte streaminfo data

Definition at line 204 of file flac.c.

Referenced by flac_decode_init(), flac_header(), flac_read_header(), and parse_streaminfo().

int ff_flac_decode_frame_header ( AVCodecContext avctx,
GetBitContext gb,
FLACFrameInfo fi,
int  log_level_offset 
)

Validate and decode a frame header.

Parameters
avctxAVCodecContext to use as av_log() context
gbGetBitContext from which to read frame header
[out]fiframe information
log_level_offsetlog level offset. can be used to silence error messages.
Returns
non-zero on error, 0 if ok

Definition at line 50 of file flac.c.

Referenced by decode_frame(), and frame_header_is_valid().

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.

Parameters
blocksizeblock size, in samples
chnumber of channels
bpsbits-per-sample

Definition at line 148 of file flac.c.

Referenced by flac_decode_frame(), flac_encode_frame(), and flac_encode_init().

void ff_flac_set_channel_layout ( AVCodecContext avctx)

Definition at line 196 of file flac.c.

Referenced by avpriv_flac_parse_streaminfo(), decode_frame(), and get_best_header().

static int64_t get_utf8 ( GetBitContext gb)
static

Definition at line 43 of file flac.c.

Referenced by ff_flac_decode_frame_header().

Variable Documentation

const uint64_t flac_channel_layouts[8]
static
Initial value:
= {
}
#define AV_CH_LAYOUT_7POINT1
#define AV_CH_LAYOUT_6POINT1
#define AV_CH_LAYOUT_SURROUND
#define AV_CH_LAYOUT_STEREO
#define AV_CH_LAYOUT_5POINT0
#define AV_CH_LAYOUT_5POINT1
#define AV_CH_LAYOUT_QUAD
#define AV_CH_LAYOUT_MONO

Definition at line 32 of file flac.c.

Referenced by ff_flac_set_channel_layout().

const int8_t sample_size_table[] = { 0, 8, 12, 0, 16, 20, 24, 0 }
static

Definition at line 30 of file flac.c.

Referenced by ff_flac_decode_frame_header().