FFmpeg
Data Structures | Macros | Functions | Variables
flacdec.c File Reference
#include <limits.h>
#include "libavutil/avassert.h"
#include "libavutil/crc.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "get_bits.h"
#include "golomb.h"
#include "flac.h"
#include "flacdsp.h"
#include "flac_parse.h"
#include "thread.h"
#include "unary.h"

Go to the source code of this file.

Data Structures

struct  FLACContext
 

Macros

#define DECODER_SUBFRAME_FIXED_WIDE(residual)
 

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 int decode_subframe_fixed_wide (FLACContext *s, int32_t *decoded, int pred_order, int bps)
 
static int decode_subframe_fixed_33bps (FLACContext *s, int64_t *decoded, int32_t *residual, int pred_order)
 
static void lpc_analyze_remodulate (SUINT32 *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_lpc_33bps (FLACContext *s, int64_t *decoded, int32_t *residual, int pred_order)
 
static int decode_subframe (FLACContext *s, int channel)
 
static int decode_frame (FLACContext *s)
 
static void decorrelate_33bps (int ch_mode, int32_t **decoded, int64_t *decoded_33bps, int len)
 
static int flac_decode_frame (AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
 
static av_cold int flac_decode_close (AVCodecContext *avctx)
 

Variables

static const AVOption options []
 
static const AVClass flac_decoder_class
 
const FFCodec 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.

Macro Definition Documentation

◆ DECODER_SUBFRAME_FIXED_WIDE

#define DECODER_SUBFRAME_FIXED_WIDE (   residual)

Definition at line 354 of file flacdec.c.

Function Documentation

◆ allocate_buffers()

static int allocate_buffers ( FLACContext s)
static

Definition at line 137 of file flacdec.c.

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

◆ flac_set_bps()

static void flac_set_bps ( FLACContext s)
static

Definition at line 76 of file flacdec.c.

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

◆ flac_decode_init()

static av_cold int flac_decode_init ( AVCodecContext avctx)
static

Definition at line 98 of file flacdec.c.

◆ dump_headers()

static void dump_headers ( AVCodecContext avctx,
FLACStreaminfo s 
)
static

Definition at line 128 of file flacdec.c.

Referenced by decode_frame().

◆ parse_streaminfo()

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 187 of file flacdec.c.

Referenced by flac_decode_frame().

◆ get_metadata_size()

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 220 of file flacdec.c.

Referenced by flac_decode_frame().

◆ decode_residuals()

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

◆ decode_subframe_fixed()

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

Definition at line 302 of file flacdec.c.

Referenced by decode_subframe().

◆ decode_subframe_fixed_wide()

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

Definition at line 389 of file flacdec.c.

Referenced by decode_subframe().

◆ decode_subframe_fixed_33bps()

static int decode_subframe_fixed_33bps ( FLACContext s,
int64_t decoded,
int32_t residual,
int  pred_order 
)
static

Definition at line 400 of file flacdec.c.

Referenced by decode_subframe().

◆ lpc_analyze_remodulate()

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

Definition at line 410 of file flacdec.c.

Referenced by decode_subframe_lpc().

◆ decode_subframe_lpc()

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

Definition at line 437 of file flacdec.c.

Referenced by decode_subframe().

◆ decode_subframe_lpc_33bps()

static int decode_subframe_lpc_33bps ( FLACContext s,
int64_t decoded,
int32_t residual,
int  pred_order 
)
static

Definition at line 481 of file flacdec.c.

Referenced by decode_subframe().

◆ decode_subframe()

static int decode_subframe ( FLACContext s,
int  channel 
)
inlinestatic

Definition at line 517 of file flacdec.c.

Referenced by decode_frame().

◆ decode_frame()

static int decode_frame ( FLACContext s)
static

Definition at line 609 of file flacdec.c.

Referenced by flac_decode_frame().

◆ decorrelate_33bps()

static void decorrelate_33bps ( int  ch_mode,
int32_t **  decoded,
int64_t decoded_33bps,
int  len 
)
static

Definition at line 694 of file flacdec.c.

Referenced by flac_decode_frame().

◆ flac_decode_frame()

static int flac_decode_frame ( AVCodecContext avctx,
AVFrame frame,
int *  got_frame_ptr,
AVPacket avpkt 
)
static

Definition at line 714 of file flacdec.c.

◆ flac_decode_close()

static av_cold int flac_decode_close ( AVCodecContext avctx)
static

Definition at line 796 of file flacdec.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "use_buggy_lpc", "emulate old buggy lavc behavior", 0x42, AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM },
{ NULL },
}

Definition at line 806 of file flacdec.c.

◆ flac_decoder_class

const AVClass flac_decoder_class
static
Initial value:
= {
.class_name = "FLAC decoder",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 811 of file flacdec.c.

◆ ff_flac_decoder

const FFCodec ff_flac_decoder
Initial value:
= {
.p.name = "flac",
CODEC_LONG_NAME("FLAC (Free Lossless Audio Codec)"),
.p.type = AVMEDIA_TYPE_AUDIO,
.priv_data_size = sizeof(FLACContext),
.p.capabilities = AV_CODEC_CAP_CHANNEL_CONF |
.p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16,
.p.priv_class = &flac_decoder_class,
}

Definition at line 818 of file flacdec.c.

flac_decode_close
static av_cold int flac_decode_close(AVCodecContext *avctx)
Definition: flacdec.c:796
AV_SAMPLE_FMT_S32P
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
Definition: samplefmt.h:65
AV_CODEC_ID_FLAC
@ AV_CODEC_ID_FLAC
Definition: codec_id.h:459
flac_decoder_class
static const AVClass flac_decoder_class
Definition: flacdec.c:811
AV_OPT_FLAG_AUDIO_PARAM
#define AV_OPT_FLAG_AUDIO_PARAM
Definition: opt.h:357
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:311
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
flac_decode_frame
static int flac_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Definition: flacdec.c:714
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:296
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:110
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
AV_CODEC_CAP_CHANNEL_CONF
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition: codec.h:106
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
AV_SAMPLE_FMT_S16P
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
Definition: samplefmt.h:64
FLACContext
Definition: flacdec.c:51
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
options
static const AVOption options[]
Definition: flacdec.c:806
AV_SAMPLE_FMT_S16
@ AV_SAMPLE_FMT_S16
signed 16 bits
Definition: samplefmt.h:58
flac_decode_init
static av_cold int flac_decode_init(AVCodecContext *avctx)
Definition: flacdec.c:98
AV_OPT_FLAG_DECODING_PARAM
#define AV_OPT_FLAG_DECODING_PARAM
A generic parameter which can be set by the user for demuxing or decoding.
Definition: opt.h:356
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
AV_SAMPLE_FMT_S32
@ AV_SAMPLE_FMT_S32
signed 32 bits
Definition: samplefmt.h:59