libavcodec/flacdec.c File Reference

FLAC (Free Lossless Audio Codec) decoder. More...

#include <limits.h>
#include "libavutil/crc.h"
#include "avcodec.h"
#include "internal.h"
#include "get_bits.h"
#include "bytestream.h"
#include "golomb.h"
#include "flac.h"
#include "flacdata.h"
#include <assert.h>

Go to the source code of this file.

Data Structures

struct  FLACContext

Defines

#define DECORRELATE(left, right)

Functions

static int64_t get_utf8 (GetBitContext *gb)
static void allocate_buffers (FLACContext *s)
int ff_flac_is_extradata_valid (AVCodecContext *avctx, enum FLACExtradataFormat *format, uint8_t **streaminfo_start)
 Validate the FLAC extradata.
static av_cold int flac_decode_init (AVCodecContext *avctx)
static void dump_headers (AVCodecContext *avctx, FLACStreaminfo *s)
void ff_flac_parse_streaminfo (AVCodecContext *avctx, struct FLACStreaminfo *s, const uint8_t *buffer)
 Parse the Streaminfo metadata block.
void ff_flac_parse_block_header (const uint8_t *block_header, int *last, int *type, int *size)
 Parse the metadata block parameters from the header.
static int parse_streaminfo (FLACContext *s, const uint8_t *buf, int buf_size)
 Parse the STREAMINFO from an inline header.
static int get_metadata_size (const uint8_t *buf, int buf_size)
 Determine the size of an inline header.
static int decode_residuals (FLACContext *s, int channel, int pred_order)
static int decode_subframe_fixed (FLACContext *s, int channel, int pred_order)
static int decode_subframe_lpc (FLACContext *s, int channel, int pred_order)
static int decode_subframe (FLACContext *s, int channel)
static int decode_frame_header (AVCodecContext *avctx, GetBitContext *gb, FLACFrameInfo *fi)
 Validate and decode a frame header.
static int decode_frame (FLACContext *s)
static int flac_decode_frame (AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
static av_cold int flac_decode_close (AVCodecContext *avctx)
static void flac_flush (AVCodecContext *avctx)

Variables

static const int sample_size_table []
AVCodec flac_decoder


Detailed Description

FLAC (Free Lossless Audio Codec) decoder.

Author:
Alex Beregszaszi
For more information on the FLAC format, visit: http://flac.sourceforge.net/

This decoder can be used in 1 of 2 ways: Either raw FLAC data can be fed through, starting from the initial 'fLaC' signature; or by passing the 34-byte streaminfo structure through avctx->extradata[_size] followed by data starting with the 0xFFF8 marker.

Definition in file flacdec.c.


Define Documentation

#define DECORRELATE ( left,
right   ) 

Value:

assert(s->channels == 2);\
            for (i = 0; i < s->blocksize; i++) {\
                int a= s->decoded[0][i];\
                int b= s->decoded[1][i];\
                if (s->is32) {\
                    *samples_32++ = (left)  << s->sample_shift;\
                    *samples_32++ = (right) << s->sample_shift;\
                } else {\
                    *samples_16++ = (left)  << s->sample_shift;\
                    *samples_16++ = (right) << s->sample_shift;\
                }\
            }\
            break;

Referenced by flac_decode_frame().


Function Documentation

static void allocate_buffers ( FLACContext s  )  [static]

Definition at line 147 of file flacdec.c.

static int decode_frame ( FLACContext s  )  [static]

Definition at line 573 of file flacdec.c.

static int decode_frame_header ( AVCodecContext avctx,
GetBitContext gb,
FLACFrameInfo fi 
) [static]

Validate and decode a frame header.

Parameters:
avctx AVCodecContext to use as av_log() context
gb GetBitContext from which to read frame header
[out] fi frame information
Returns:
non-zero on error, 0 if ok

Definition at line 490 of file flacdec.c.

Referenced by decode_frame().

static int decode_residuals ( FLACContext s,
int  channel,
int  pred_order 
) [static]

Definition at line 267 of file flacdec.c.

Referenced by decode_subframe_fixed(), and decode_subframe_lpc().

static int decode_subframe ( FLACContext s,
int  channel 
) [inline, static]

Definition at line 424 of file flacdec.c.

Referenced by decode_frame().

static int decode_subframe_fixed ( FLACContext s,
int  channel,
int  pred_order 
) [static]

Definition at line 307 of file flacdec.c.

Referenced by decode_subframe().

static int decode_subframe_lpc ( FLACContext s,
int  channel,
int  pred_order 
) [static]

Definition at line 357 of file flacdec.c.

Referenced by decode_subframe(), and shorten_decode_frame().

static void dump_headers ( AVCodecContext avctx,
FLACStreaminfo s 
) [static]

Definition at line 138 of file flacdec.c.

Referenced by ff_flac_parse_streaminfo().

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

Validate the FLAC extradata.

Parameters:
[in] avctx codec context containing the extradata.
[out] format extradata format.
[out] streaminfo_start pointer to start of 34-byte STREAMINFO data.
Returns:
1 if valid, 0 if not valid.

Definition at line 82 of file flacdec.c.

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

void ff_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_header header data, at least 4 bytes
[out] last indicator for last metadata block
[out] type metadata block type
[out] size metadata block size

Definition at line 203 of file flacdec.c.

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

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

Parse the Streaminfo metadata block.

Parameters:
[out] avctx codec context to set basic stream parameters
[out] s where parsed information is stored
[in] buffer pointer to start of 34-byte streaminfo data

Definition at line 169 of file flacdec.c.

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

static av_cold int flac_decode_close ( AVCodecContext avctx  )  [static]

Definition at line 779 of file flacdec.c.

static int flac_decode_frame ( AVCodecContext avctx,
void *  data,
int *  data_size,
AVPacket avpkt 
) [static]

Definition at line 637 of file flacdec.c.

static av_cold int flac_decode_init ( AVCodecContext avctx  )  [static]

Definition at line 109 of file flacdec.c.

static void flac_flush ( AVCodecContext avctx  )  [static]

Definition at line 792 of file flacdec.c.

static int get_metadata_size ( const uint8_t *  buf,
int  buf_size 
) [static]

Determine the size of an inline header.

Parameters:
buf input buffer, starting with the "fLaC" marker
buf_size buffer size
Returns:
number of bytes in the header, or 0 if more data is needed

Definition at line 248 of file flacdec.c.

Referenced by flac_decode_frame().

static int64_t get_utf8 ( GetBitContext gb  )  [static]

Definition at line 73 of file flacdec.c.

Referenced by decode_frame_header().

static int parse_streaminfo ( FLACContext s,
const uint8_t *  buf,
int  buf_size 
) [static]

Parse the STREAMINFO from an inline header.

Parameters:
s the flac decoding context
buf input buffer, starting with the "fLaC" marker
buf_size buffer size
Returns:
non-zero if metadata is invalid

Definition at line 222 of file flacdec.c.

Referenced by flac_decode_frame().


Variable Documentation

Initial value:

Definition at line 800 of file flacdec.c.

const int sample_size_table[] [static]

Initial value:

{ 0, 8, 12, 0, 16, 20, 24, 0 }

Definition at line 70 of file flacdec.c.

Referenced by decode_frame_header().


Generated on Fri Oct 26 02:36:51 2012 for FFmpeg by  doxygen 1.5.8