FFmpeg
Data Structures | Macros | Functions | Variables
vorbisenc.c File Reference
#include <float.h>
#include "libavutil/float_dsp.h"
#include "avcodec.h"
#include "encode.h"
#include "internal.h"
#include "fft.h"
#include "mathops.h"
#include "vorbis.h"
#include "vorbis_enc_data.h"
#include "audio_frame_queue.h"
#include "libavfilter/bufferqueue.h"
#include "put_bits.h"
#include <assert.h>

Go to the source code of this file.

Data Structures

struct  vorbis_enc_codebook
 
struct  vorbis_enc_floor_class
 
struct  vorbis_enc_floor
 
struct  vorbis_enc_residue
 
struct  vorbis_enc_mapping
 
struct  vorbis_enc_mode
 
struct  vorbis_enc_context
 

Macros

#define BITSTREAM_WRITER_LE
 
#define MAX_CHANNELS   2
 
#define MAX_CODEBOOK_DIM   8
 
#define MAX_FLOOR_CLASS_DIM   4
 
#define NUM_FLOOR_PARTITIONS   8
 
#define MAX_FLOOR_VALUES   (MAX_FLOOR_CLASS_DIM*NUM_FLOOR_PARTITIONS+2)
 
#define RESIDUE_SIZE   1600
 
#define RESIDUE_PART_SIZE   32
 
#define NUM_RESIDUE_PARTITIONS   (RESIDUE_SIZE/RESIDUE_PART_SIZE)
 

Functions

static int put_codeword (PutBitContext *pb, vorbis_enc_codebook *cb, int entry)
 
static int cb_lookup_vals (int lookup, int dimensions, int entries)
 
static int ready_codebook (vorbis_enc_codebook *cb)
 
static int ready_residue (vorbis_enc_residue *rc, vorbis_enc_context *venc)
 
static av_cold int dsp_init (AVCodecContext *avctx, vorbis_enc_context *venc)
 
static int create_vorbis_context (vorbis_enc_context *venc, AVCodecContext *avctx)
 
static void put_float (PutBitContext *pb, float f)
 
static void put_codebook_header (PutBitContext *pb, vorbis_enc_codebook *cb)
 
static void put_floor_header (PutBitContext *pb, vorbis_enc_floor *fc)
 
static void put_residue_header (PutBitContext *pb, vorbis_enc_residue *rc)
 
static int put_main_header (vorbis_enc_context *venc, uint8_t **out)
 
static float get_floor_average (vorbis_enc_floor *fc, float *coeffs, int i)
 
static void floor_fit (vorbis_enc_context *venc, vorbis_enc_floor *fc, float *coeffs, uint16_t *posts, int samples)
 
static int render_point (int x0, int y0, int x1, int y1, int x)
 
static int floor_encode (vorbis_enc_context *venc, vorbis_enc_floor *fc, PutBitContext *pb, uint16_t *posts, float *floor, int samples)
 
static float * put_vector (vorbis_enc_codebook *book, PutBitContext *pb, float *num)
 
static int residue_encode (vorbis_enc_context *venc, vorbis_enc_residue *rc, PutBitContext *pb, float *coeffs, int samples, int real_ch)
 
static int apply_window_and_mdct (vorbis_enc_context *venc)
 
static AVFramespawn_empty_frame (AVCodecContext *avctx, int channels)
 
static void move_audio (vorbis_enc_context *venc, int sf_size)
 
static int vorbis_encode_frame (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
 
static av_cold int vorbis_encode_close (AVCodecContext *avctx)
 
static av_cold int vorbis_encode_init (AVCodecContext *avctx)
 

Variables

const AVCodec ff_vorbis_encoder
 

Detailed Description

Native Vorbis encoder.

Author
Oded Shimon ods15.nosp@m.@ods.nosp@m.15.dy.nosp@m.ndns.nosp@m..org

Definition in file vorbisenc.c.

Macro Definition Documentation

◆ BITSTREAM_WRITER_LE

#define BITSTREAM_WRITER_LE

Definition at line 41 of file vorbisenc.c.

◆ MAX_CHANNELS

#define MAX_CHANNELS   2

Definition at line 142 of file vorbisenc.c.

◆ MAX_CODEBOOK_DIM

#define MAX_CODEBOOK_DIM   8

Definition at line 143 of file vorbisenc.c.

◆ MAX_FLOOR_CLASS_DIM

#define MAX_FLOOR_CLASS_DIM   4

Definition at line 145 of file vorbisenc.c.

◆ NUM_FLOOR_PARTITIONS

#define NUM_FLOOR_PARTITIONS   8

Definition at line 146 of file vorbisenc.c.

◆ MAX_FLOOR_VALUES

#define MAX_FLOOR_VALUES   (MAX_FLOOR_CLASS_DIM*NUM_FLOOR_PARTITIONS+2)

Definition at line 147 of file vorbisenc.c.

◆ RESIDUE_SIZE

#define RESIDUE_SIZE   1600

Definition at line 149 of file vorbisenc.c.

◆ RESIDUE_PART_SIZE

#define RESIDUE_PART_SIZE   32

Definition at line 150 of file vorbisenc.c.

◆ NUM_RESIDUE_PARTITIONS

#define NUM_RESIDUE_PARTITIONS   (RESIDUE_SIZE/RESIDUE_PART_SIZE)

Definition at line 151 of file vorbisenc.c.

Function Documentation

◆ put_codeword()

static int put_codeword ( PutBitContext pb,
vorbis_enc_codebook cb,
int  entry 
)
inlinestatic

Definition at line 153 of file vorbisenc.c.

Referenced by floor_encode(), put_vector(), and residue_encode().

◆ cb_lookup_vals()

static int cb_lookup_vals ( int  lookup,
int  dimensions,
int  entries 
)
static

Definition at line 165 of file vorbisenc.c.

Referenced by create_vorbis_context(), put_codebook_header(), and ready_codebook().

◆ ready_codebook()

static int ready_codebook ( vorbis_enc_codebook cb)
static

Definition at line 174 of file vorbisenc.c.

Referenced by create_vorbis_context().

◆ ready_residue()

static int ready_residue ( vorbis_enc_residue rc,
vorbis_enc_context venc 
)
static

Definition at line 211 of file vorbisenc.c.

Referenced by create_vorbis_context().

◆ dsp_init()

static av_cold int dsp_init ( AVCodecContext avctx,
vorbis_enc_context venc 
)
static

Definition at line 250 of file vorbisenc.c.

Referenced by create_vorbis_context().

◆ create_vorbis_context()

static int create_vorbis_context ( vorbis_enc_context venc,
AVCodecContext avctx 
)
static

Definition at line 270 of file vorbisenc.c.

Referenced by vorbis_encode_init().

◆ put_float()

static void put_float ( PutBitContext pb,
float  f 
)
static

Definition at line 475 of file vorbisenc.c.

Referenced by put_codebook_header().

◆ put_codebook_header()

static void put_codebook_header ( PutBitContext pb,
vorbis_enc_codebook cb 
)
static

Definition at line 489 of file vorbisenc.c.

Referenced by put_main_header().

◆ put_floor_header()

static void put_floor_header ( PutBitContext pb,
vorbis_enc_floor fc 
)
static

Definition at line 554 of file vorbisenc.c.

Referenced by put_main_header().

◆ put_residue_header()

static void put_residue_header ( PutBitContext pb,
vorbis_enc_residue rc 
)
static

Definition at line 587 of file vorbisenc.c.

Referenced by put_main_header().

◆ put_main_header()

static int put_main_header ( vorbis_enc_context venc,
uint8_t **  out 
)
static

Definition at line 619 of file vorbisenc.c.

Referenced by vorbis_encode_init().

◆ get_floor_average()

static float get_floor_average ( vorbis_enc_floor fc,
float *  coeffs,
int  i 
)
static

Definition at line 754 of file vorbisenc.c.

Referenced by floor_fit().

◆ floor_fit()

static void floor_fit ( vorbis_enc_context venc,
vorbis_enc_floor fc,
float *  coeffs,
uint16_t *  posts,
int  samples 
)
static

Definition at line 766 of file vorbisenc.c.

Referenced by vorbis_encode_frame().

◆ render_point()

static int render_point ( int  x0,
int  y0,
int  x1,
int  y1,
int  x 
)
static

Definition at line 793 of file vorbisenc.c.

Referenced by floor_encode().

◆ floor_encode()

static int floor_encode ( vorbis_enc_context venc,
vorbis_enc_floor fc,
PutBitContext pb,
uint16_t *  posts,
float *  floor,
int  samples 
)
static

Definition at line 798 of file vorbisenc.c.

Referenced by vorbis_encode_frame().

◆ put_vector()

static float* put_vector ( vorbis_enc_codebook book,
PutBitContext pb,
float *  num 
)
static

Definition at line 887 of file vorbisenc.c.

Referenced by residue_encode().

◆ residue_encode()

static int residue_encode ( vorbis_enc_context venc,
vorbis_enc_residue rc,
PutBitContext pb,
float *  coeffs,
int  samples,
int  real_ch 
)
static

Definition at line 910 of file vorbisenc.c.

Referenced by vorbis_encode_frame().

◆ apply_window_and_mdct()

static int apply_window_and_mdct ( vorbis_enc_context venc)
static

Definition at line 1005 of file vorbisenc.c.

Referenced by vorbis_encode_frame().

◆ spawn_empty_frame()

static AVFrame* spawn_empty_frame ( AVCodecContext avctx,
int  channels 
)
static

Definition at line 1031 of file vorbisenc.c.

Referenced by vorbis_encode_frame().

◆ move_audio()

static void move_audio ( vorbis_enc_context venc,
int  sf_size 
)
static

Definition at line 1056 of file vorbisenc.c.

Referenced by vorbis_encode_frame().

◆ vorbis_encode_frame()

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

Definition at line 1090 of file vorbisenc.c.

◆ vorbis_encode_close()

static av_cold int vorbis_encode_close ( AVCodecContext avctx)
static

Definition at line 1204 of file vorbisenc.c.

Referenced by vorbis_encode_init().

◆ vorbis_encode_init()

static av_cold int vorbis_encode_init ( AVCodecContext avctx)
static

Definition at line 1265 of file vorbisenc.c.

Variable Documentation

◆ ff_vorbis_encoder

const AVCodec ff_vorbis_encoder
Initial value:
= {
.name = "vorbis",
.long_name = NULL_IF_CONFIG_SMALL("Vorbis"),
.priv_data_size = sizeof(vorbis_enc_context),
.encode2 = vorbis_encode_frame,
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
}

Definition at line 1300 of file vorbisenc.c.

AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:69
FF_CODEC_CAP_INIT_THREADSAFE
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: internal.h:42
vorbis_encode_init
static av_cold int vorbis_encode_init(AVCodecContext *avctx)
Definition: vorbisenc.c:1265
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:948
vorbis_encode_close
static av_cold int vorbis_encode_close(AVCodecContext *avctx)
Definition: vorbisenc.c:1204
init
static int init
Definition: av_tx.c:47
AV_CODEC_CAP_EXPERIMENTAL
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
Definition: codec.h:105
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
vorbis_encode_frame
static int vorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Definition: vorbisenc.c:1090
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:59
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
vorbis_enc_context
Definition: vorbisenc.c:105
AV_CODEC_CAP_DELAY
#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: codec.h:82
AV_CODEC_ID_VORBIS
@ AV_CODEC_ID_VORBIS
Definition: codec_id.h:428