FFmpeg
Data Structures | Macros | Functions | Variables
vorbisenc.c File Reference
#include <float.h>
#include "libavutil/float_dsp.h"
#include "libavutil/tx.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "encode.h"
#include "mathops.h"
#include "vorbis.h"
#include "vorbis_data.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 floatput_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 FFCodec 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 42 of file vorbisenc.c.

◆ MAX_CHANNELS

#define MAX_CHANNELS   2

Definition at line 144 of file vorbisenc.c.

◆ MAX_CODEBOOK_DIM

#define MAX_CODEBOOK_DIM   8

Definition at line 145 of file vorbisenc.c.

◆ MAX_FLOOR_CLASS_DIM

#define MAX_FLOOR_CLASS_DIM   4

Definition at line 147 of file vorbisenc.c.

◆ NUM_FLOOR_PARTITIONS

#define NUM_FLOOR_PARTITIONS   8

Definition at line 148 of file vorbisenc.c.

◆ MAX_FLOOR_VALUES

#define MAX_FLOOR_VALUES   (MAX_FLOOR_CLASS_DIM*NUM_FLOOR_PARTITIONS+2)

Definition at line 149 of file vorbisenc.c.

◆ RESIDUE_SIZE

#define RESIDUE_SIZE   1600

Definition at line 151 of file vorbisenc.c.

◆ RESIDUE_PART_SIZE

#define RESIDUE_PART_SIZE   32

Definition at line 152 of file vorbisenc.c.

◆ NUM_RESIDUE_PARTITIONS

#define NUM_RESIDUE_PARTITIONS   (RESIDUE_SIZE/RESIDUE_PART_SIZE)

Definition at line 153 of file vorbisenc.c.

Function Documentation

◆ put_codeword()

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

Definition at line 155 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 167 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 176 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 213 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 252 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 275 of file vorbisenc.c.

Referenced by vorbis_encode_init().

◆ put_float()

static void put_float ( PutBitContext pb,
float  f 
)
static

Definition at line 480 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 494 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 559 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 592 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 624 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 759 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 771 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 798 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 803 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 892 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 915 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 1010 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 1036 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 1062 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 1096 of file vorbisenc.c.

◆ vorbis_encode_close()

static av_cold int vorbis_encode_close ( AVCodecContext avctx)
static

Definition at line 1210 of file vorbisenc.c.

◆ vorbis_encode_init()

static av_cold int vorbis_encode_init ( AVCodecContext avctx)
static

Definition at line 1271 of file vorbisenc.c.

Variable Documentation

◆ ff_vorbis_encoder

const FFCodec ff_vorbis_encoder
Initial value:
= {
.p.name = "vorbis",
CODEC_LONG_NAME("Vorbis"),
.p.type = AVMEDIA_TYPE_AUDIO,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
.priv_data_size = sizeof(vorbis_enc_context),
.p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}

Definition at line 1303 of file vorbisenc.c.

AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:66
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:42
vorbis_encode_init
static av_cold int vorbis_encode_init(AVCodecContext *avctx)
Definition: vorbisenc.c:1271
vorbis_encode_close
static av_cold int vorbis_encode_close(AVCodecContext *avctx)
Definition: vorbisenc.c:1210
FF_CODEC_ENCODE_CB
#define FF_CODEC_ENCODE_CB(func)
Definition: codec_internal.h:315
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:102
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:1096
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:365
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
vorbis_enc_context
Definition: vorbisenc.c:106
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:76
AV_CODEC_ID_VORBIS
@ AV_CODEC_ID_VORBIS
Definition: codec_id.h:447