FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Functions | Variables
flacdec.c File Reference

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

#include <limits.h>
#include "libavutil/avassert.h"
#include "libavutil/crc.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "internal.h"
#include "get_bits.h"
#include "bytestream.h"
#include "golomb.h"
#include "flac.h"
#include "flacdata.h"
#include "flacdsp.h"
#include "thread.h"
#include "unary.h"

Go to the source code of this file.

Data Structures

struct  FLACContext
 

Functions

static int allocate_buffers (FLACContext *s)
 
static void flac_set_bps (FLACContext *s)
 
static av_cold int flac_decode_init (AVCodecContext *avctx)
 
static void dump_headers (AVCodecContext *avctx, FLACStreaminfo *s)
 
static int parse_streaminfo (FLACContext *s, const uint8_t *buf, int buf_size)
 Parse the STREAMINFO from an inline header. More...
 
static int get_metadata_size (const uint8_t *buf, int buf_size)
 Determine the size of an inline header. More...
 
static int decode_residuals (FLACContext *s, int32_t *decoded, int pred_order)
 
static int decode_subframe_fixed (FLACContext *s, int32_t *decoded, int pred_order, int bps)
 
static void lpc_analyze_remodulate (int32_t *decoded, const int coeffs[32], int order, int qlevel, int len, int bps)
 
static int decode_subframe_lpc (FLACContext *s, int32_t *decoded, int pred_order, int bps)
 
static int decode_subframe (FLACContext *s, int channel)
 
static int decode_frame (FLACContext *s)
 
static int flac_decode_frame (AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
 
static int init_thread_copy (AVCodecContext *avctx)
 
static av_cold int flac_decode_close (AVCodecContext *avctx)
 

Variables

static const AVOption options []
 
static const AVClass flac_decoder_class
 
AVCodec ff_flac_decoder
 

Detailed Description

FLAC (Free Lossless Audio Codec) decoder.

Author
Alex Beregszaszi
See Also
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.

Function Documentation

static int allocate_buffers ( FLACContext s)
static

Definition at line 133 of file flacdec.c.

Referenced by decode_frame(), flac_decode_init(), init_thread_copy(), and parse_streaminfo().

static void flac_set_bps ( FLACContext s)
static

Definition at line 73 of file flacdec.c.

Referenced by decode_frame(), flac_decode_init(), and parse_streaminfo().

static av_cold int flac_decode_init ( AVCodecContext avctx)
static

Definition at line 95 of file flacdec.c.

static void dump_headers ( AVCodecContext avctx,
FLACStreaminfo s 
)
static

Definition at line 124 of file flacdec.c.

Referenced by decode_frame().

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

Parse the STREAMINFO from an inline header.

Parameters
sthe flac decoding context
bufinput buffer, starting with the "fLaC" marker
buf_sizebuffer size
Returns
non-zero if metadata is invalid

Definition at line 165 of file flacdec.c.

Referenced by flac_decode_frame().

static int get_metadata_size ( const uint8_t buf,
int  buf_size 
)
static

Determine the size of an inline header.

Parameters
bufinput buffer, starting with the "fLaC" marker
buf_sizebuffer size
Returns
number of bytes in the header, or 0 if more data is needed

Definition at line 196 of file flacdec.c.

Referenced by flac_decode_frame().

static int decode_residuals ( FLACContext s,
int32_t decoded,
int  pred_order 
)
static

Definition at line 217 of file flacdec.c.

Referenced by decode_subframe_fixed(), and decode_subframe_lpc().

static int decode_subframe_fixed ( FLACContext s,
int32_t decoded,
int  pred_order,
int  bps 
)
static

Definition at line 267 of file flacdec.c.

Referenced by decode_subframe().

static void lpc_analyze_remodulate ( int32_t decoded,
const int  coeffs[32],
int  order,
int  qlevel,
int  len,
int  bps 
)
static

Definition at line 318 of file flacdec.c.

Referenced by decode_subframe_lpc().

static int decode_subframe_lpc ( FLACContext s,
int32_t decoded,
int  pred_order,
int  bps 
)
static

Definition at line 345 of file flacdec.c.

Referenced by decode_subframe().

static int decode_subframe ( FLACContext s,
int  channel 
)
inlinestatic

Definition at line 389 of file flacdec.c.

Referenced by decode_frame().

static int decode_frame ( FLACContext s)
static

Definition at line 456 of file flacdec.c.

Referenced by flac_decode_frame().

static int flac_decode_frame ( AVCodecContext avctx,
void data,
int *  got_frame_ptr,
AVPacket avpkt 
)
static

Definition at line 542 of file flacdec.c.

static int init_thread_copy ( AVCodecContext avctx)
static

Definition at line 626 of file flacdec.c.

static av_cold int flac_decode_close ( AVCodecContext avctx)
static

Definition at line 637 of file flacdec.c.

Variable Documentation

const AVOption options[]
static
Initial value:
= {
{ "use_buggy_lpc", "emulate old buggy lavc behavior", 0x42, AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM },
{ NULL },
}
#define NULL
Definition: coverity.c:32
#define AV_OPT_FLAG_AUDIO_PARAM
Definition: opt.h:290
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
Definition: opt.h:286

Definition at line 646 of file flacdec.c.

const AVClass flac_decoder_class
static
Initial value:
= {
"FLAC decoder",
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:62
av_default_item_name
static const AVOption options[]
Definition: flacdec.c:646

Definition at line 651 of file flacdec.c.

AVCodec ff_flac_decoder
Initial value:
= {
.name = "flac",
.long_name = NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"),
.priv_data_size = sizeof(FLACContext),
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16,
.priv_class = &flac_decoder_class,
}
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static const AVClass flac_decoder_class
Definition: flacdec.c:651
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:789
signed 32 bits
Definition: samplefmt.h:63
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:175
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
Definition: internal.h:214
signed 32 bits, planar
Definition: samplefmt.h:69
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:59
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
Definition: ccaption_dec.c:522
#define CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: avcodec.h:866
signed 16 bits
Definition: samplefmt.h:62
static av_cold int flac_decode_init(AVCodecContext *avctx)
Definition: flacdec.c:95
signed 16 bits, planar
Definition: samplefmt.h:68
static int init_thread_copy(AVCodecContext *avctx)
Definition: flacdec.c:626
static av_cold int flac_decode_close(AVCodecContext *avctx)
Definition: flacdec.c:637
static int flac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Definition: flacdec.c:542

Definition at line 658 of file flacdec.c.