FFmpeg  4.0
Data Structures | Macros | Functions | Variables
vorbisenc.c File Reference

Native Vorbis encoder. More...

#include <float.h>
#include "libavutil/float_dsp.h"
#include "avcodec.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

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 40 of file vorbisenc.c.

◆ MAX_CHANNELS

#define MAX_CHANNELS   2

Definition at line 141 of file vorbisenc.c.

Referenced by residue_encode().

◆ MAX_CODEBOOK_DIM

#define MAX_CODEBOOK_DIM   8

Definition at line 142 of file vorbisenc.c.

Referenced by residue_encode().

◆ MAX_FLOOR_CLASS_DIM

#define MAX_FLOOR_CLASS_DIM   4

Definition at line 144 of file vorbisenc.c.

◆ NUM_FLOOR_PARTITIONS

#define NUM_FLOOR_PARTITIONS   8

Definition at line 145 of file vorbisenc.c.

Referenced by create_vorbis_context().

◆ MAX_FLOOR_VALUES

#define MAX_FLOOR_VALUES   (MAX_FLOOR_CLASS_DIM*NUM_FLOOR_PARTITIONS+2)

Definition at line 146 of file vorbisenc.c.

Referenced by floor_encode(), floor_fit(), and vorbis_encode_frame().

◆ RESIDUE_SIZE

#define RESIDUE_SIZE   1600

Definition at line 148 of file vorbisenc.c.

◆ RESIDUE_PART_SIZE

#define RESIDUE_PART_SIZE   32

Definition at line 149 of file vorbisenc.c.

◆ NUM_RESIDUE_PARTITIONS

#define NUM_RESIDUE_PARTITIONS   (RESIDUE_SIZE/RESIDUE_PART_SIZE)

Definition at line 150 of file vorbisenc.c.

Referenced by residue_encode().

Function Documentation

◆ put_codeword()

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

Definition at line 152 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 164 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 173 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 210 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 249 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 269 of file vorbisenc.c.

Referenced by vorbis_encode_init().

◆ put_float()

static void put_float ( PutBitContext pb,
float  f 
)
static

Definition at line 470 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 484 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 549 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 582 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 614 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 749 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 761 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 788 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 793 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 882 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 905 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 1000 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 1026 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 1051 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 1085 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 1267 of file vorbisenc.c.

Variable Documentation

◆ ff_vorbis_encoder

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,
}
float, planar
Definition: samplefmt.h:69
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
Definition: avcodec.h:1007
#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:984
static av_cold int vorbis_encode_close(AVCodecContext *avctx)
Definition: vorbisenc.c:1204
static av_cold int vorbis_encode_init(AVCodecContext *avctx)
Definition: vorbisenc.c:1267
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
static int vorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Definition: vorbisenc.c:1085
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:701

Definition at line 1301 of file vorbisenc.c.