FFmpeg
Classes | Macros | Typedefs | Functions
dither.c File Reference

Dithered Audio Sample Quantization. More...

#include <math.h>
#include <stdint.h>
#include "libavutil/attributes.h"
#include "libavutil/common.h"
#include "libavutil/lfg.h"
#include "libavutil/mem.h"
#include "libavutil/samplefmt.h"
#include "audio_convert.h"
#include "dither.h"
#include "internal.h"

Classes

struct  DitherState
 
struct  DitherContext
 

Macros

#define MUTE_THRESHOLD_SEC   0.000333
 
#define S16_SCALE   32753.0f
 
#define LFG_SCALE   (1.0f / (2.0f * INT32_MAX))
 
#define SQRT_1_6   0.40824829046386301723f
 

Typedefs

typedef struct DitherState DitherState
 

Functions

int ff_convert_dither (DitherContext *c, AudioData *dst, AudioData *src)
 Convert audio sample format with dithering. More...
 
void ff_dither_free (DitherContext **cp)
 Free a DitherContext. More...
 
DitherContextff_dither_alloc (AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map)
 Allocate and initialize a DitherContext. More...
 

Detailed Description

Dithered Audio Sample Quantization.

Converts from dbl, flt, or s32 to s16 using dithering.

Function Documentation

§ ff_convert_dither()

int ff_convert_dither ( DitherContext c,
AudioData dst,
AudioData src 
)

Convert audio sample format with dithering.

Parameters
cDitherContext
dstdestination audio data
srcsource audio data
Returns
0 if ok, negative AVERROR code on failure

§ ff_dither_alloc()

DitherContext* ff_dither_alloc ( AVAudioResampleContext avr,
enum AVSampleFormat  out_fmt,
enum AVSampleFormat  in_fmt,
int  channels,
int  sample_rate,
int  apply_map 
)

Allocate and initialize a DitherContext.

The parameters in the AVAudioResampleContext are used to initialize the DitherContext.

Parameters
avrAVAudioResampleContext
Returns
newly-allocated DitherContext

§ ff_dither_free()

void ff_dither_free ( DitherContext **  c)

Free a DitherContext.

Parameters
cDitherContext