FFmpeg
Data Structures | Macros | Typedefs | Functions | Variables
aaccoder.c File Reference
#include "libavutil/libm.h"
#include <float.h>
#include "libavutil/mathematics.h"
#include "mathops.h"
#include "avcodec.h"
#include "put_bits.h"
#include "aac.h"
#include "aacenc.h"
#include "aactab.h"
#include "aacenctab.h"
#include "aacenc_utils.h"
#include "aacenc_quantization.h"
#include "aacenc_is.h"
#include "aacenc_tns.h"
#include "aacenc_ltp.h"
#include "aacenc_pred.h"
#include "libavcodec/aaccoder_twoloop.h"
#include "libavcodec/aaccoder_trellis.h"

Go to the source code of this file.

Data Structures

struct  BandCodingPath
 structure used in optimal codebook search More...
 
struct  TrellisPath
 

Macros

#define NOISE_SPREAD_THRESHOLD   0.9f
 
#define NOISE_LAMBDA_REPLACE   1.948f
 
#define QUANTIZE_AND_ENCODE_BAND_COST_FUNC(NAME, BT_ZERO, BT_UNSIGNED, BT_PAIR, BT_ESC, BT_NOISE, BT_STEREO, ROUNDING)
 
#define TRELLIS_STAGES   121
 
#define TRELLIS_STATES   (SCALE_MAX_DIFF+1)
 

Typedefs

typedef float(* quantize_and_encode_band_func) (struct AACEncContext *s, PutBitContext *pb, const float *in, float *quant, const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, int *bits, float *energy)
 

Functions

static av_always_inline float quantize_and_encode_band_cost_template (struct AACEncContext *s, PutBitContext *pb, const float *in, float *out, const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, int *bits, float *energy, int BT_ZERO, int BT_UNSIGNED, int BT_PAIR, int BT_ESC, int BT_NOISE, int BT_STEREO, const float ROUNDING)
 Calculate rate distortion cost for quantizing with given codebook. More...
 
static float quantize_and_encode_band_cost_NONE (struct AACEncContext *s, PutBitContext *pb, const float *in, float *quant, const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, int *bits, float *energy)
 
float ff_quantize_and_encode_band_cost (struct AACEncContext *s, PutBitContext *pb, const float *in, float *quant, const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, int *bits, float *energy)
 
static void quantize_and_encode_band (struct AACEncContext *s, PutBitContext *pb, const float *in, float *out, int size, int scale_idx, int cb, const float lambda, int rtz)
 
static void encode_window_bands_info (AACEncContext *s, SingleChannelElement *sce, int win, int group_len, const float lambda)
 Encode band info for single window group bands. More...
 
static void set_special_band_scalefactors (AACEncContext *s, SingleChannelElement *sce)
 
static void search_for_quantizers_anmr (AVCodecContext *avctx, AACEncContext *s, SingleChannelElement *sce, const float lambda)
 
static void search_for_quantizers_fast (AVCodecContext *avctx, AACEncContext *s, SingleChannelElement *sce, const float lambda)
 
static void search_for_pns (AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce)
 
static void mark_pns (AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce)
 
static void search_for_ms (AACEncContext *s, ChannelElement *cpe)
 

Variables

static const quantize_and_encode_band_func quantize_and_encode_band_cost_arr []
 
static const quantize_and_encode_band_func quantize_and_encode_band_cost_rtz_arr []
 
const AACCoefficientsEncoder ff_aac_coders [AAC_CODER_NB]
 

Detailed Description

AAC coefficients encoder

Definition in file aaccoder.c.

Macro Definition Documentation

◆ NOISE_SPREAD_THRESHOLD

#define NOISE_SPREAD_THRESHOLD   0.9f

Definition at line 57 of file aaccoder.c.

◆ NOISE_LAMBDA_REPLACE

#define NOISE_LAMBDA_REPLACE   1.948f

Definition at line 61 of file aaccoder.c.

◆ QUANTIZE_AND_ENCODE_BAND_COST_FUNC

#define QUANTIZE_AND_ENCODE_BAND_COST_FUNC (   NAME,
  BT_ZERO,
  BT_UNSIGNED,
  BT_PAIR,
  BT_ESC,
  BT_NOISE,
  BT_STEREO,
  ROUNDING 
)
Value:
static float quantize_and_encode_band_cost_ ## NAME( \
struct AACEncContext *s, \
PutBitContext *pb, const float *in, float *quant, \
const float *scaled, int size, int scale_idx, \
int cb, const float lambda, const float uplim, \
int *bits, float *energy) { \
s, pb, in, quant, scaled, size, scale_idx, \
BT_ESC ? ESC_BT : cb, lambda, uplim, bits, energy, \
BT_ZERO, BT_UNSIGNED, BT_PAIR, BT_ESC, BT_NOISE, BT_STEREO, \
ROUNDING); \
}

Definition at line 205 of file aaccoder.c.

◆ TRELLIS_STAGES

#define TRELLIS_STAGES   121

Definition at line 416 of file aaccoder.c.

◆ TRELLIS_STATES

#define TRELLIS_STATES   (SCALE_MAX_DIFF+1)

Definition at line 417 of file aaccoder.c.

Typedef Documentation

◆ quantize_and_encode_band_func

typedef float(* quantize_and_encode_band_func) (struct AACEncContext *s, PutBitContext *pb, const float *in, float *quant, const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, int *bits, float *energy)

Definition at line 65 of file aaccoder.c.

Function Documentation

◆ quantize_and_encode_band_cost_template()

static av_always_inline float quantize_and_encode_band_cost_template ( struct AACEncContext s,
PutBitContext pb,
const float in,
float out,
const float scaled,
int  size,
int  scale_idx,
int  cb,
const float  lambda,
const float  uplim,
int bits,
float energy,
int  BT_ZERO,
int  BT_UNSIGNED,
int  BT_PAIR,
int  BT_ESC,
int  BT_NOISE,
int  BT_STEREO,
const float  ROUNDING 
)
static

Calculate rate distortion cost for quantizing with given codebook.

Returns
quantization distortion

Definition at line 76 of file aaccoder.c.

◆ quantize_and_encode_band_cost_NONE()

static float quantize_and_encode_band_cost_NONE ( struct AACEncContext s,
PutBitContext pb,
const float in,
float quant,
const float scaled,
int  size,
int  scale_idx,
int  cb,
const float  lambda,
const float  uplim,
int bits,
float energy 
)
inlinestatic

Definition at line 196 of file aaccoder.c.

◆ ff_quantize_and_encode_band_cost()

float ff_quantize_and_encode_band_cost ( struct AACEncContext s,
PutBitContext pb,
const float in,
float quant,
const float scaled,
int  size,
int  scale_idx,
int  cb,
const float  lambda,
const float  uplim,
int bits,
float energy 
)

Definition at line 269 of file aaccoder.c.

Referenced by ff_aac_search_for_pred(), quantize_band_cost(), and quantize_band_cost_bits().

◆ quantize_and_encode_band()

static void quantize_and_encode_band ( struct AACEncContext s,
PutBitContext pb,
const float in,
float out,
int  size,
int  scale_idx,
int  cb,
const float  lambda,
int  rtz 
)
inlinestatic

Definition at line 280 of file aaccoder.c.

◆ encode_window_bands_info()

static void encode_window_bands_info ( AACEncContext s,
SingleChannelElement sce,
int  win,
int  group_len,
const float  lambda 
)
static

Encode band info for single window group bands.

Definition at line 300 of file aaccoder.c.

◆ set_special_band_scalefactors()

static void set_special_band_scalefactors ( AACEncContext s,
SingleChannelElement sce 
)
static

Definition at line 419 of file aaccoder.c.

◆ search_for_quantizers_anmr()

static void search_for_quantizers_anmr ( AVCodecContext avctx,
AACEncContext s,
SingleChannelElement sce,
const float  lambda 
)
static

Definition at line 458 of file aaccoder.c.

◆ search_for_quantizers_fast()

static void search_for_quantizers_fast ( AVCodecContext avctx,
AACEncContext s,
SingleChannelElement sce,
const float  lambda 
)
static

Definition at line 618 of file aaccoder.c.

◆ search_for_pns()

static void search_for_pns ( AACEncContext s,
AVCodecContext avctx,
SingleChannelElement sce 
)
static

Keep this in sync with twoloop's cutoff selection

Definition at line 765 of file aaccoder.c.

◆ mark_pns()

static void mark_pns ( AACEncContext s,
AVCodecContext avctx,
SingleChannelElement sce 
)
static

Keep this in sync with twoloop's cutoff selection

Definition at line 907 of file aaccoder.c.

◆ search_for_ms()

static void search_for_ms ( AACEncContext s,
ChannelElement cpe 
)
static

Scout out next nonzero bands

Definition at line 978 of file aaccoder.c.

Variable Documentation

◆ quantize_and_encode_band_cost_arr

const quantize_and_encode_band_func quantize_and_encode_band_cost_arr[]
static
Initial value:
=
{
quantize_and_encode_band_cost_ZERO,
quantize_and_encode_band_cost_SQUAD,
quantize_and_encode_band_cost_SQUAD,
quantize_and_encode_band_cost_UQUAD,
quantize_and_encode_band_cost_UQUAD,
quantize_and_encode_band_cost_SPAIR,
quantize_and_encode_band_cost_SPAIR,
quantize_and_encode_band_cost_UPAIR,
quantize_and_encode_band_cost_UPAIR,
quantize_and_encode_band_cost_UPAIR,
quantize_and_encode_band_cost_UPAIR,
quantize_and_encode_band_cost_ESC,
quantize_and_encode_band_cost_NOISE,
quantize_and_encode_band_cost_STEREO,
quantize_and_encode_band_cost_STEREO,
}

Definition at line 229 of file aaccoder.c.

Referenced by ff_quantize_and_encode_band_cost(), and quantize_and_encode_band().

◆ quantize_and_encode_band_cost_rtz_arr

const quantize_and_encode_band_func quantize_and_encode_band_cost_rtz_arr[]
static
Initial value:
=
{
quantize_and_encode_band_cost_ZERO,
quantize_and_encode_band_cost_SQUAD,
quantize_and_encode_band_cost_SQUAD,
quantize_and_encode_band_cost_UQUAD,
quantize_and_encode_band_cost_UQUAD,
quantize_and_encode_band_cost_SPAIR,
quantize_and_encode_band_cost_SPAIR,
quantize_and_encode_band_cost_UPAIR,
quantize_and_encode_band_cost_UPAIR,
quantize_and_encode_band_cost_UPAIR,
quantize_and_encode_band_cost_UPAIR,
quantize_and_encode_band_cost_ESC_RTZ,
quantize_and_encode_band_cost_NOISE,
quantize_and_encode_band_cost_STEREO,
quantize_and_encode_band_cost_STEREO,
}

Definition at line 249 of file aaccoder.c.

Referenced by quantize_and_encode_band().

◆ ff_aac_coders

const AACCoefficientsEncoder ff_aac_coders[AAC_CODER_NB]

Definition at line 1119 of file aaccoder.c.

Referenced by aac_encode_init().

quantize_and_encode_band_cost_template
static av_always_inline float quantize_and_encode_band_cost_template(struct AACEncContext *s, PutBitContext *pb, const float *in, float *out, const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, int *bits, float *energy, int BT_ZERO, int BT_UNSIGNED, int BT_PAIR, int BT_ESC, int BT_NOISE, int BT_STEREO, const float ROUNDING)
Calculate rate distortion cost for quantizing with given codebook.
Definition: aaccoder.c:76
cb
static double cb(void *priv, double x, double y)
Definition: vf_geq.c:239
quantize_and_encode_band_cost_NONE
static float quantize_and_encode_band_cost_NONE(struct AACEncContext *s, PutBitContext *pb, const float *in, float *quant, const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, int *bits, float *energy)
Definition: aaccoder.c:196
quant
static int quant(float coef, const float Q, const float rounding)
Quantize one coefficient.
Definition: aacenc_utils.h:59
s
#define s(width, name)
Definition: cbs_vp9.c:256
bits
uint8_t bits
Definition: vp3data.h:128
PutBitContext
Definition: put_bits.h:50
size
int size
Definition: twinvq_data.h:10344
ESC_BT
@ ESC_BT
Spectral data are coded with an escape sequence.
Definition: aac.h:84
AACEncContext
AAC encoder context.
Definition: aacenc.h:108