FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
flacenc.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/crc.h"
#include "libavutil/intmath.h"
#include "libavutil/md5.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "bswapdsp.h"
#include "put_bits.h"
#include "golomb.h"
#include "internal.h"
#include "lpc.h"
#include "flac.h"
#include "flacdata.h"
#include "flacdsp.h"

Go to the source code of this file.

Data Structures

struct  CompressionOptions
 
struct  RiceContext
 
struct  FlacSubframe
 
struct  FlacFrame
 
struct  FlacEncodeContext
 

Macros

#define FLAC_SUBFRAME_CONSTANT   0
 
#define FLAC_SUBFRAME_VERBATIM   1
 
#define FLAC_SUBFRAME_FIXED   8
 
#define FLAC_SUBFRAME_LPC   32
 
#define MAX_FIXED_ORDER   4
 
#define MAX_PARTITION_ORDER   8
 
#define MAX_PARTITIONS   (1 << MAX_PARTITION_ORDER)
 
#define MAX_LPC_PRECISION   15
 
#define MIN_LPC_SHIFT   0
 
#define MAX_LPC_SHIFT   15
 
#define COPY_SAMPLES(bits)
 
#define rice_encode_count(sum, n, k)   (((n)*((k)+1))+((sum-(n>>1))>>(k)))
 
#define FLAGS   AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
 

Enumerations

enum  CodingMode { CODING_MODE_RICE = 4, CODING_MODE_RICE2 = 5 }
 

Functions

static void write_streaminfo (FlacEncodeContext *s, uint8_t *header)
 Write streaminfo metadata block to byte array. More...
 
static int select_blocksize (int samplerate, int block_time_ms)
 Set blocksize based on samplerate. More...
 
static av_cold void dprint_compression_options (FlacEncodeContext *s)
 
static av_cold int flac_encode_init (AVCodecContext *avctx)
 
static void init_frame (FlacEncodeContext *s, int nb_samples)
 
static void copy_samples (FlacEncodeContext *s, const void *samples)
 Copy channel-interleaved input samples into separate subframes. More...
 
static uint64_t rice_count_exact (const int32_t *res, int n, int k)
 
static uint64_t subframe_count_exact (FlacEncodeContext *s, FlacSubframe *sub, int pred_order)
 
static int find_optimal_param (uint64_t sum, int n, int max_param)
 Solve for d/dk(rice_encode_count) = n-((sum-(n>>1))>>(k+1)) = 0. More...
 
static int find_optimal_param_exact (uint64_t sums[32][MAX_PARTITIONS], int i, int max_param)
 
static uint64_t calc_optimal_rice_params (RiceContext *rc, int porder, uint64_t sums[32][MAX_PARTITIONS], int n, int pred_order, int max_param, int exact)
 
static void calc_sum_top (int pmax, int kmax, const uint32_t *data, int n, int pred_order, uint64_t sums[32][MAX_PARTITIONS])
 
static void calc_sum_next (int level, uint64_t sums[32][MAX_PARTITIONS], int kmax)
 
static uint64_t calc_rice_params (RiceContext *rc, uint32_t udata[FLAC_MAX_BLOCKSIZE], uint64_t sums[32][MAX_PARTITIONS], int pmin, int pmax, const int32_t *data, int n, int pred_order, int exact)
 
static int get_max_p_order (int max_porder, int n, int order)
 
static uint64_t find_subframe_rice_params (FlacEncodeContext *s, FlacSubframe *sub, int pred_order)
 
static void encode_residual_fixed (int32_t *res, const int32_t *smp, int n, int order)
 
static int encode_residual_ch (FlacEncodeContext *s, int ch)
 
static int count_frame_header (FlacEncodeContext *s)
 
static int encode_frame (FlacEncodeContext *s)
 
static void remove_wasted_bits (FlacEncodeContext *s)
 
static int estimate_stereo_mode (const int32_t *left_ch, const int32_t *right_ch, int n, int max_rice_param)
 
static void channel_decorrelation (FlacEncodeContext *s)
 Perform stereo channel decorrelation. More...
 
static void write_utf8 (PutBitContext *pb, uint32_t val)
 
static void write_frame_header (FlacEncodeContext *s)
 
static void write_subframes (FlacEncodeContext *s)
 
static void write_frame_footer (FlacEncodeContext *s)
 
static int write_frame (FlacEncodeContext *s, AVPacket *avpkt)
 
static int update_md5_sum (FlacEncodeContext *s, const void *samples)
 
static int flac_encode_frame (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
 
static av_cold int flac_encode_close (AVCodecContext *avctx)
 

Variables

static const AVOption options []
 
static const AVClass flac_encoder_class
 
AVCodec ff_flac_encoder
 

Macro Definition Documentation

#define FLAC_SUBFRAME_CONSTANT   0

Definition at line 38 of file flacenc.c.

Referenced by encode_residual_ch(), subframe_count_exact(), and write_subframes().

#define FLAC_SUBFRAME_VERBATIM   1

Definition at line 39 of file flacenc.c.

Referenced by encode_residual_ch(), subframe_count_exact(), and write_subframes().

#define FLAC_SUBFRAME_FIXED   8

Definition at line 40 of file flacenc.c.

Referenced by encode_residual_ch().

#define FLAC_SUBFRAME_LPC   32
#define MAX_FIXED_ORDER   4

Definition at line 43 of file flacenc.c.

Referenced by encode_residual_ch(), and flac_encode_init().

#define MAX_PARTITION_ORDER   8

Definition at line 44 of file flacenc.c.

Referenced by calc_rice_params().

#define MAX_PARTITIONS   (1 << MAX_PARTITION_ORDER)

Definition at line 45 of file flacenc.c.

#define MAX_LPC_PRECISION   15

Definition at line 46 of file flacenc.c.

#define MIN_LPC_SHIFT   0

Definition at line 47 of file flacenc.c.

Referenced by encode_residual_ch().

#define MAX_LPC_SHIFT   15

Definition at line 48 of file flacenc.c.

Referenced by encode_residual_ch().

#define COPY_SAMPLES (   bits)
Value:
do { \
const int ## bits ## _t *samples0 = samples; \
frame = &s->frame; \
for (i = 0, j = 0; i < frame->blocksize; i++) \
for (ch = 0; ch < s->channels; ch++, j++) \
frame->subframes[ch].samples[i] = samples0[j] >> shift; \
} while (0)
const char * s
Definition: avisynth_c.h:768
static int shift(int a, int b)
Definition: sonic.c:82
uint8_t bits
Definition: crc.c:296
static AVFrame * frame
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t *) pi-0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(constint64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(constfloat *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(constdouble *) pi *(INT64_C(1)<< 63)))#defineFMT_PAIR_FUNC(out, in) staticconv_func_type *constfmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64),};staticvoidcpy1(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, len);}staticvoidcpy2(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 2 *len);}staticvoidcpy4(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 4 *len);}staticvoidcpy8(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 8 *len);}AudioConvert *swri_audio_convert_alloc(enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, constint *ch_map, intflags){AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) returnNULL;if(channels==1){in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);}ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map){switch(av_get_bytes_per_sample(in_fmt)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_YASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);returnctx;}voidswri_audio_convert_free(AudioConvert **ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;}if(ctx->out_simd_align_mask){intplanes=out->planar?out->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;}if(ctx->simd_f &&!ctx->ch_map &&!misaligned){off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){if(out->planar==in->planar){intplanes=out->planar?out->ch_count:1;for(ch=0;ch< planes;ch++){ctx->simd_f(out-> ch ch
Definition: audioconvert.c:56
for(j=16;j >0;--j)

Referenced by copy_samples().

#define rice_encode_count (   sum,
  n,
 
)    (((n)*((k)+1))+((sum-(n>>1))>>(k)))

Definition at line 601 of file flacenc.c.

Referenced by calc_optimal_rice_params(), and estimate_stereo_mode().

Definition at line 1463 of file flacenc.c.

Enumeration Type Documentation

enum CodingMode
Enumerator
CODING_MODE_RICE 
CODING_MODE_RICE2 

Definition at line 50 of file flacenc.c.

Function Documentation

static void write_streaminfo ( FlacEncodeContext s,
uint8_t header 
)
static

Write streaminfo metadata block to byte array.

Definition at line 135 of file flacenc.c.

Referenced by flac_encode_frame(), and flac_encode_init().

static int select_blocksize ( int  samplerate,
int  block_time_ms 
)
static

Set blocksize based on samplerate.

Choose the closest predefined blocksize >= BLOCK_TIME_MS milliseconds.

Definition at line 162 of file flacenc.c.

Referenced by flac_encode_init().

static av_cold void dprint_compression_options ( FlacEncodeContext s)
static

Definition at line 181 of file flacenc.c.

Referenced by flac_encode_init().

static av_cold int flac_encode_init ( AVCodecContext avctx)
static

Definition at line 239 of file flacenc.c.

static void init_frame ( FlacEncodeContext s,
int  nb_samples 
)
static

Definition at line 470 of file flacenc.c.

Referenced by decode_frame(), and flac_encode_frame().

static void copy_samples ( FlacEncodeContext s,
const void samples 
)
static

Copy channel-interleaved input samples into separate subframes.

Definition at line 515 of file flacenc.c.

Referenced by flac_encode_frame().

static uint64_t rice_count_exact ( const int32_t res,
int  n,
int  k 
)
static

Definition at line 537 of file flacenc.c.

Referenced by subframe_count_exact().

static uint64_t subframe_count_exact ( FlacEncodeContext s,
FlacSubframe sub,
int  pred_order 
)
static

Definition at line 551 of file flacenc.c.

Referenced by encode_residual_ch().

static int find_optimal_param ( uint64_t  sum,
int  n,
int  max_param 
)
static

Solve for d/dk(rice_encode_count) = n-((sum-(n>>1))>>(k+1)) = 0.

Definition at line 606 of file flacenc.c.

Referenced by calc_optimal_rice_params(), and estimate_stereo_mode().

static int find_optimal_param_exact ( uint64_t  sums[32][MAX_PARTITIONS],
int  i,
int  max_param 
)
static

Definition at line 618 of file flacenc.c.

Referenced by calc_optimal_rice_params().

static uint64_t calc_optimal_rice_params ( RiceContext rc,
int  porder,
uint64_t  sums[32][MAX_PARTITIONS],
int  n,
int  pred_order,
int  max_param,
int  exact 
)
static

Definition at line 635 of file flacenc.c.

Referenced by calc_rice_params().

static void calc_sum_top ( int  pmax,
int  kmax,
const uint32_t *  data,
int  n,
int  pred_order,
uint64_t  sums[32][MAX_PARTITIONS] 
)
static

Definition at line 665 of file flacenc.c.

Referenced by calc_rice_params().

static void calc_sum_next ( int  level,
uint64_t  sums[32][MAX_PARTITIONS],
int  kmax 
)
static

Definition at line 695 of file flacenc.c.

Referenced by calc_rice_params().

static uint64_t calc_rice_params ( RiceContext rc,
uint32_t  udata[FLAC_MAX_BLOCKSIZE],
uint64_t  sums[32][MAX_PARTITIONS],
int  pmin,
int  pmax,
const int32_t data,
int  n,
int  pred_order,
int  exact 
)
static

Definition at line 705 of file flacenc.c.

Referenced by find_subframe_rice_params().

static int get_max_p_order ( int  max_porder,
int  n,
int  order 
)
static

Definition at line 745 of file flacenc.c.

Referenced by find_subframe_rice_params().

static uint64_t find_subframe_rice_params ( FlacEncodeContext s,
FlacSubframe sub,
int  pred_order 
)
static

Definition at line 754 of file flacenc.c.

Referenced by encode_residual_ch().

static void encode_residual_fixed ( int32_t res,
const int32_t smp,
int  n,
int  order 
)
static

Definition at line 771 of file flacenc.c.

Referenced by encode_residual_ch().

static int encode_residual_ch ( FlacEncodeContext s,
int  ch 
)
static

Definition at line 822 of file flacenc.c.

Referenced by encode_frame().

static int count_frame_header ( FlacEncodeContext s)
static

Definition at line 1021 of file flacenc.c.

Referenced by encode_frame().

static int encode_frame ( FlacEncodeContext s)
static

Definition at line 1057 of file flacenc.c.

Referenced by flac_encode_frame().

static void remove_wasted_bits ( FlacEncodeContext s)
static

Definition at line 1077 of file flacenc.c.

Referenced by flac_encode_frame().

static int estimate_stereo_mode ( const int32_t left_ch,
const int32_t right_ch,
int  n,
int  max_rice_param 
)
static

Definition at line 1109 of file flacenc.c.

Referenced by channel_decorrelation().

static void channel_decorrelation ( FlacEncodeContext s)
static

Perform stereo channel decorrelation.

Definition at line 1153 of file flacenc.c.

Referenced by flac_encode_frame().

static void write_utf8 ( PutBitContext pb,
uint32_t  val 
)
static

Definition at line 1198 of file flacenc.c.

Referenced by write_frame_header().

static void write_frame_header ( FlacEncodeContext s)
static

Definition at line 1205 of file flacenc.c.

Referenced by write_frame().

static void write_subframes ( FlacEncodeContext s)
static

Definition at line 1242 of file flacenc.c.

Referenced by write_frame().

static void write_frame_footer ( FlacEncodeContext s)
static

Definition at line 1302 of file flacenc.c.

Referenced by write_frame().

static int write_frame ( FlacEncodeContext s,
AVPacket avpkt 
)
static

Definition at line 1313 of file flacenc.c.

Referenced by flac_encode_frame().

static int update_md5_sum ( FlacEncodeContext s,
const void samples 
)
static

Definition at line 1323 of file flacenc.c.

Referenced by flac_encode_frame().

static int flac_encode_frame ( AVCodecContext avctx,
AVPacket avpkt,
const AVFrame frame,
int *  got_packet_ptr 
)
static

Definition at line 1359 of file flacenc.c.

static av_cold int flac_encode_close ( AVCodecContext avctx)
static

Definition at line 1450 of file flacenc.c.

Variable Documentation

const AVOption options[]
static
Initial value:
= {
{ "lpc_coeff_precision", "LPC coefficient precision", 0x42, AV_OPT_TYPE_INT, {.i64 = 15 }, 0, MAX_LPC_PRECISION, FLAGS },
{ "lpc_type", "LPC algorithm", 0x42, AV_OPT_TYPE_INT, {.i64 = FF_LPC_TYPE_DEFAULT }, FF_LPC_TYPE_DEFAULT, FF_LPC_TYPE_NB-1, FLAGS, "lpc_type" },
{ "none", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LPC_TYPE_NONE }, INT_MIN, INT_MAX, FLAGS, "lpc_type" },
{ "fixed", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LPC_TYPE_FIXED }, INT_MIN, INT_MAX, FLAGS, "lpc_type" },
{ "levinson", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LPC_TYPE_LEVINSON }, INT_MIN, INT_MAX, FLAGS, "lpc_type" },
{ "cholesky", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LPC_TYPE_CHOLESKY }, INT_MIN, INT_MAX, FLAGS, "lpc_type" },
{ "lpc_passes", "Number of passes to use for Cholesky factorization during LPC analysis", 0x42, AV_OPT_TYPE_INT, {.i64 = 2 }, 1, INT_MAX, FLAGS },
{ "min_partition_order", NULL, 0x42, AV_OPT_TYPE_INT, {.i64 = -1 }, -1, MAX_PARTITION_ORDER, FLAGS },
{ "max_partition_order", NULL, 0x42, AV_OPT_TYPE_INT, {.i64 = -1 }, -1, MAX_PARTITION_ORDER, FLAGS },
{ "prediction_order_method", "Search method for selecting prediction order", 0x42, AV_OPT_TYPE_INT, {.i64 = -1 }, -1, ORDER_METHOD_LOG, FLAGS, "predm" },
{ "estimation", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = ORDER_METHOD_EST }, INT_MIN, INT_MAX, FLAGS, "predm" },
{ "2level", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = ORDER_METHOD_2LEVEL }, INT_MIN, INT_MAX, FLAGS, "predm" },
{ "4level", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = ORDER_METHOD_4LEVEL }, INT_MIN, INT_MAX, FLAGS, "predm" },
{ "8level", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = ORDER_METHOD_8LEVEL }, INT_MIN, INT_MAX, FLAGS, "predm" },
{ "search", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = ORDER_METHOD_SEARCH }, INT_MIN, INT_MAX, FLAGS, "predm" },
{ "log", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = ORDER_METHOD_LOG }, INT_MIN, INT_MAX, FLAGS, "predm" },
{ "ch_mode", "Stereo decorrelation mode", 0x42, AV_OPT_TYPE_INT, { .i64 = -1 }, -1, FLAC_CHMODE_MID_SIDE, FLAGS, "ch_mode" },
{ "auto", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, INT_MIN, INT_MAX, FLAGS, "ch_mode" },
{ "indep", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FLAC_CHMODE_INDEPENDENT }, INT_MIN, INT_MAX, FLAGS, "ch_mode" },
{ "left_side", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FLAC_CHMODE_LEFT_SIDE }, INT_MIN, INT_MAX, FLAGS, "ch_mode" },
{ "right_side", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FLAC_CHMODE_RIGHT_SIDE }, INT_MIN, INT_MAX, FLAGS, "ch_mode" },
{ "mid_side", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FLAC_CHMODE_MID_SIDE }, INT_MIN, INT_MAX, FLAGS, "ch_mode" },
{ "exact_rice_parameters", "Calculate rice parameters exactly", 0x42, AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
{ "multi_dim_quant", "Multi-dimensional quantization", 0x42, AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
{ "min_prediction_order", NULL, 0x42, AV_OPT_TYPE_INT, { .i64 = -1 }, -1, MAX_LPC_ORDER, FLAGS },
{ "max_prediction_order", NULL, 0x42, AV_OPT_TYPE_INT, { .i64 = -1 }, -1, MAX_LPC_ORDER, FLAGS },
{ NULL },
}
#define NULL
Definition: coverity.c:32
#define ORDER_METHOD_SEARCH
Definition: lpc.h:34
#define ORDER_METHOD_8LEVEL
Definition: lpc.h:33
#define MAX_LPC_ORDER
Definition: lpc.h:38
#define MAX_PARTITION_ORDER
Definition: flacenc.c:44
#define ORDER_METHOD_LOG
Definition: lpc.h:35
do not use LPC prediction or use all zero coefficients
Definition: lpc.h:45
#define ORDER_METHOD_4LEVEL
Definition: lpc.h:32
#define ORDER_METHOD_2LEVEL
Definition: lpc.h:31
#define FLAGS
Definition: flacenc.c:1463
Not part of ABI.
Definition: lpc.h:49
Levinson-Durbin recursion.
Definition: lpc.h:47
#define ORDER_METHOD_EST
Definition: lpc.h:30
use the codec default LPC type
Definition: lpc.h:44
#define MAX_LPC_PRECISION
Definition: flacenc.c:46
Cholesky factorization.
Definition: lpc.h:48
fixed LPC coefficients
Definition: lpc.h:46

Definition at line 1464 of file flacenc.c.

const AVClass flac_encoder_class
static
Initial value:
= {
.class_name = "FLAC encoder",
.item_name = av_default_item_name,
.option = options,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
av_default_item_name
static const AVOption options[]
Definition: flacenc.c:1464

Definition at line 1495 of file flacenc.c.

AVCodec ff_flac_encoder
Initial value:
= {
.name = "flac",
.long_name = NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"),
.priv_data_size = sizeof(FlacEncodeContext),
.encode2 = flac_encode_frame,
.priv_class = &flac_encoder_class,
}
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static int flac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Definition: flacenc.c:1359
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: avcodec.h:983
signed 32 bits
Definition: samplefmt.h:62
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
#define AV_CODEC_CAP_SMALL_LAST_FRAME
Codec can be fed a final frame with a smaller size.
Definition: avcodec.h:988
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
signed 16 bits
Definition: samplefmt.h:61
#define AV_CODEC_CAP_LOSSLESS
Codec is lossless.
Definition: avcodec.h:1055
static av_cold int flac_encode_close(AVCodecContext *avctx)
Definition: flacenc.c:1450
static const AVClass flac_encoder_class
Definition: flacenc.c:1495
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:701
static av_cold int flac_encode_init(AVCodecContext *avctx)
Definition: flacenc.c:239

Definition at line 1502 of file flacenc.c.