LMMS
Loading...
Searching...
No Matches
vorbisenc.c File Reference
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "../../codec.h"
#include "../../vorbisenc.h"
#include "codec_internal.h"
#include "os.h"
#include "misc.h"
#include "modes/setup_44.h"
#include "modes/setup_44u.h"
#include "modes/setup_44p51.h"
#include "modes/setup_32.h"
#include "modes/setup_8.h"
#include "modes/setup_11.h"
#include "modes/setup_16.h"
#include "modes/setup_22.h"
#include "modes/setup_X.h"

Classes

struct  static_bookblock
struct  vorbis_residue_template
struct  vorbis_mapping_template
struct  vp_adjblock
struct  compandblock
struct  att3
struct  adj3
struct  adj_stereo
struct  noiseguard
struct  noise3
struct  ve_setup_data_template

Typedefs

typedef struct vp_adjblock vp_adjblock

Functions

static void vorbis_encode_floor_setup (vorbis_info *vi, int s, const static_codebook *const *const *const books, const vorbis_info_floor1 *in, const int *x)
static void vorbis_encode_global_psych_setup (vorbis_info *vi, double s, const vorbis_info_psy_global *in, const double *x)
static void vorbis_encode_global_stereo (vorbis_info *vi, const highlevel_encode_setup *const hi, const adj_stereo *p)
static void vorbis_encode_psyset_setup (vorbis_info *vi, double s, const int *nn_start, const int *nn_partition, const double *nn_thresh, int block)
static void vorbis_encode_tonemask_setup (vorbis_info *vi, double s, int block, const att3 *att, const int *max, const vp_adjblock *in)
static void vorbis_encode_compand_setup (vorbis_info *vi, double s, int block, const compandblock *in, const double *x)
static void vorbis_encode_peak_setup (vorbis_info *vi, double s, int block, const int *suppress)
static void vorbis_encode_noisebias_setup (vorbis_info *vi, double s, int block, const int *suppress, const noise3 *in, const noiseguard *guard, double userbias)
static void vorbis_encode_ath_setup (vorbis_info *vi, int block)
static int book_dup_or_new (codec_setup_info *ci, const static_codebook *book)
static void vorbis_encode_blocksize_setup (vorbis_info *vi, double s, const int *shortb, const int *longb)
static void vorbis_encode_residue_setup (vorbis_info *vi, int number, int block, const vorbis_residue_template *res)
static void vorbis_encode_map_n_res_setup (vorbis_info *vi, double s, const vorbis_mapping_template *maps)
static double setting_to_approx_bitrate (vorbis_info *vi)
static const voidget_setup_template (long ch, long srate, double req, int q_or_bitrate, double *base_setting)
int vorbis_encode_setup_init (vorbis_info *vi)
static void vorbis_encode_setup_setting (vorbis_info *vi, long channels, long rate)
int vorbis_encode_setup_vbr (vorbis_info *vi, long channels, long rate, float quality)
int vorbis_encode_init_vbr (vorbis_info *vi, long channels, long rate, float base_quality)
int vorbis_encode_setup_managed (vorbis_info *vi, long channels, long rate, long max_bitrate, long nominal_bitrate, long min_bitrate)
int vorbis_encode_init (vorbis_info *vi, long channels, long rate, long max_bitrate, long nominal_bitrate, long min_bitrate)
int vorbis_encode_ctl (vorbis_info *vi, int number, void *arg)

Variables

static const vorbis_info_mode _mode_template [2]
static const vorbis_info_mapping0 _map_nominal [2]
static const ve_setup_data_template *const setup_list []

Typedef Documentation

◆ vp_adjblock

typedef struct vp_adjblock vp_adjblock

Function Documentation

◆ book_dup_or_new()

int book_dup_or_new ( codec_setup_info * ci,
const static_codebook * book )
static

◆ get_setup_template()

const void * get_setup_template ( long ch,
long srate,
double req,
int q_or_bitrate,
double * base_setting )
static

◆ setting_to_approx_bitrate()

double setting_to_approx_bitrate ( vorbis_info * vi)
static

◆ vorbis_encode_ath_setup()

void vorbis_encode_ath_setup ( vorbis_info * vi,
int block )
static

◆ vorbis_encode_blocksize_setup()

void vorbis_encode_blocksize_setup ( vorbis_info * vi,
double s,
const int * shortb,
const int * longb )
static

◆ vorbis_encode_compand_setup()

void vorbis_encode_compand_setup ( vorbis_info * vi,
double s,
int block,
const compandblock * in,
const double * x )
static

◆ vorbis_encode_ctl()

int vorbis_encode_ctl ( vorbis_info * vi,
int number,
void * arg )

This function implements a generic interface to miscellaneous encoder settings similar to the classic UNIX 'ioctl()' system call. Applications may use vorbis_encode_ctl() to query or set bitrate management or quality mode details by using one of several request arguments detailed below. vorbis_encode_ctl() must be called after one of vorbis_encode_setup_managed() or vorbis_encode_setup_vbr(). When used to modify settings, vorbis_encode_ctl() must be called before vorbis_encode_setup_init().

Parameters
viPointer to an initialized vorbis_info struct.
numberSpecifies the desired action; See the listof available requests.
argvoid * pointing to a data structure matching the request argument.
Return values
0Success. Any further return information (such as the result of a query) is placed into the storage pointed to by *arg.
OV_EINVALInvalid argument, or an attempt to modify a setting after calling vorbis_encode_setup_init().
OV_EIMPLUnimplemented or unknown request

◆ vorbis_encode_floor_setup()

void vorbis_encode_floor_setup ( vorbis_info * vi,
int s,
const static_codebook *const *const *const books,
const vorbis_info_floor1 * in,
const int * x )
static

◆ vorbis_encode_global_psych_setup()

void vorbis_encode_global_psych_setup ( vorbis_info * vi,
double s,
const vorbis_info_psy_global * in,
const double * x )
static

◆ vorbis_encode_global_stereo()

void vorbis_encode_global_stereo ( vorbis_info * vi,
const highlevel_encode_setup *const hi,
const adj_stereo * p )
static

◆ vorbis_encode_init()

int vorbis_encode_init ( vorbis_info * vi,
long channels,
long rate,
long max_bitrate,
long nominal_bitrate,
long min_bitrate )

This is the primary function within libvorbisenc for setting up managed bitrate modes.

Before this function is called, the vorbis_info struct should be initialized by using vorbis_info_init() from the libvorbis API. After encoding, vorbis_info_clear() should be called.

The max_bitrate, nominal_bitrate, and min_bitrate settings are used to set constraints for the encoded file. This function uses these settings to select the appropriate encoding mode and set it up.

Parameters
viPointer to an initialized vorbis_info struct.
channelsThe number of channels to be encoded.
rateThe sampling rate of the source audio.
max_bitrateDesired maximum bitrate (limit). -1 indicates unset.
nominal_bitrateDesired average, or central, bitrate. -1 indicates unset.
min_bitrateDesired minimum bitrate. -1 indicates unset.
Returns
Zero for success, and negative values for failure.
Return values
0Success.
OV_EFAULTInternal logic fault; indicates a bug or heap/stack corruption.
OV_EINVALInvalid setup request, eg, out of range argument.
OV_EIMPLUnimplemented mode; unable to comply with bitrate request.

◆ vorbis_encode_init_vbr()

int vorbis_encode_init_vbr ( vorbis_info * vi,
long channels,
long rate,
float base_quality )

This is the primary function within libvorbisenc for setting up variable bitrate ("quality" based) modes.

Before this function is called, the vorbis_info struct should be initialized by using vorbis_info_init() from the libvorbis API. After encoding, vorbis_info_clear() should be called.

Parameters
viPointer to an initialized vorbis_info struct.
channelsThe number of channels to be encoded.
rateThe sampling rate of the source audio.
base_qualityDesired quality level, currently from -0.1 to 1.0 (lo to hi).
Returns
Zero for success, or a negative number for failure.
Return values
0Success
OV_EFAULTInternal logic fault; indicates a bug or heap/stack corruption.
OV_EINVALInvalid setup request, eg, out of range argument.
OV_EIMPLUnimplemented mode; unable to comply with quality level request.

◆ vorbis_encode_map_n_res_setup()

void vorbis_encode_map_n_res_setup ( vorbis_info * vi,
double s,
const vorbis_mapping_template * maps )
static

◆ vorbis_encode_noisebias_setup()

void vorbis_encode_noisebias_setup ( vorbis_info * vi,
double s,
int block,
const int * suppress,
const noise3 * in,
const noiseguard * guard,
double userbias )
static

◆ vorbis_encode_peak_setup()

void vorbis_encode_peak_setup ( vorbis_info * vi,
double s,
int block,
const int * suppress )
static

◆ vorbis_encode_psyset_setup()

void vorbis_encode_psyset_setup ( vorbis_info * vi,
double s,
const int * nn_start,
const int * nn_partition,
const double * nn_thresh,
int block )
static

◆ vorbis_encode_residue_setup()

void vorbis_encode_residue_setup ( vorbis_info * vi,
int number,
int block,
const vorbis_residue_template * res )
static

◆ vorbis_encode_setup_init()

int vorbis_encode_setup_init ( vorbis_info * vi)

This function performs the last stage of three-step encoding setup, as described in the API overview under managed bitrate modes.

Before this function is called, the vorbis_info struct should be initialized by using vorbis_info_init() from the libvorbis API, one of vorbis_encode_setup_managed() or vorbis_encode_setup_vbr() called to initialize the high-level encoding setup, and vorbis_encode_ctl() called if necessary to make encoding setup changes. vorbis_encode_setup_init() finalizes the highlevel encoding structure into a complete encoding setup after which the application may make no further setup changes.

After encoding, vorbis_info_clear() should be called.

Parameters
viPointer to an initialized vorbis_info struct.
Returns
Zero for success, and negative values for failure.
Return values
0Success.
OV_EFAULTInternal logic fault; indicates a bug or heap/stack corruption.
OV_EINVALAttempt to use vorbis_encode_setup_init() without first calling one of vorbis_encode_setup_managed() or vorbis_encode_setup_vbr() to initialize the high-level encoding setup

◆ vorbis_encode_setup_managed()

int vorbis_encode_setup_managed ( vorbis_info * vi,
long channels,
long rate,
long max_bitrate,
long nominal_bitrate,
long min_bitrate )

This function performs step-one of a three-step bitrate-managed encode setup. It functions similarly to the one-step setup performed by vorbis_encode_init but allows an application to make further encode setup tweaks using vorbis_encode_ctl before finally calling vorbis_encode_setup_init to complete the setup process.

Before this function is called, the vorbis_info struct should be initialized by using vorbis_info_init() from the libvorbis API. After encoding, vorbis_info_clear() should be called.

The max_bitrate, nominal_bitrate, and min_bitrate settings are used to set constraints for the encoded file. This function uses these settings to select the appropriate encoding mode and set it up.

Parameters
viPointer to an initialized vorbis_info struct.
channelsThe number of channels to be encoded.
rateThe sampling rate of the source audio.
max_bitrateDesired maximum bitrate (limit). -1 indicates unset.
nominal_bitrateDesired average, or central, bitrate. -1 indicates unset.
min_bitrateDesired minimum bitrate. -1 indicates unset.
Returns
Zero for success, and negative for failure.
Return values
0Success
OV_EFAULTInternal logic fault; indicates a bug or heap/stack corruption.
OV_EINVALInvalid setup request, eg, out of range argument.
OV_EIMPLUnimplemented mode; unable to comply with bitrate request.

◆ vorbis_encode_setup_setting()

void vorbis_encode_setup_setting ( vorbis_info * vi,
long channels,
long rate )
static

◆ vorbis_encode_setup_vbr()

int vorbis_encode_setup_vbr ( vorbis_info * vi,
long channels,
long rate,
float quality )

This function performs step-one of a three-step variable bitrate (quality-based) encode setup. It functions similarly to the one-step setup performed by vorbis_encode_init_vbr() but allows an application to make further encode setup tweaks using vorbis_encode_ctl() before finally calling vorbis_encode_setup_init to complete the setup process.

Before this function is called, the vorbis_info struct should be initialized by using vorbis_info_init() from the libvorbis API. After encoding, vorbis_info_clear() should be called.

Parameters
viPointer to an initialized vorbis_info struct.
channelsThe number of channels to be encoded.
rateThe sampling rate of the source audio.
qualityDesired quality level, currently from -0.1 to 1.0 (lo to hi).
Returns
Zero for success, and negative values for failure.
Return values
0Success
OV_EFAULTInternal logic fault; indicates a bug or heap/stack corruption.
OV_EINVALInvalid setup request, eg, out of range argument.
OV_EIMPLUnimplemented mode; unable to comply with quality level request.

◆ vorbis_encode_tonemask_setup()

void vorbis_encode_tonemask_setup ( vorbis_info * vi,
double s,
int block,
const att3 * att,
const int * max,
const vp_adjblock * in )
static

Variable Documentation

◆ _map_nominal

const vorbis_info_mapping0 _map_nominal[2]
static
Initial value:
={
{1, {0,0}, {0}, {0}, 1,{0},{1}},
{1, {0,0}, {1}, {1}, 1,{0},{1}}
}

◆ _mode_template

const vorbis_info_mode _mode_template[2]
static
Initial value:
={
{0,0,0,0},
{1,0,0,1}
}

◆ setup_list

const ve_setup_data_template* const setup_list[]
static
Initial value:
={
0
}
static const ve_setup_data_template ve_setup_11_stereo
Definition setup_11.h:42
static const ve_setup_data_template ve_setup_11_uncoupled
Definition setup_11.h:93
static const ve_setup_data_template ve_setup_16_stereo
Definition setup_16.h:52
static const ve_setup_data_template ve_setup_16_uncoupled
Definition setup_16.h:103
static const ve_setup_data_template ve_setup_22_stereo
Definition setup_22.h:27
static const ve_setup_data_template ve_setup_22_uncoupled
Definition setup_22.h:78
static const ve_setup_data_template ve_setup_32_stereo
Definition setup_32.h:31
static const ve_setup_data_template ve_setup_32_uncoupled
Definition setup_32.h:82
static const ve_setup_data_template ve_setup_44_stereo
Definition setup_44.h:67
static const ve_setup_data_template ve_setup_44_51
Definition setup_44p51.h:24
static const ve_setup_data_template ve_setup_44_uncoupled
Definition setup_44u.h:24
static const ve_setup_data_template ve_setup_8_uncoupled
Definition setup_8.h:99
static const ve_setup_data_template ve_setup_8_stereo
Definition setup_8.h:48
static const ve_setup_data_template ve_setup_X_stereo
Definition setup_X.h:22
static const ve_setup_data_template ve_setup_X_uncoupled
Definition setup_X.h:73
static const ve_setup_data_template ve_setup_XX_uncoupled
Definition setup_X.h:175
static const ve_setup_data_template ve_setup_XX_stereo
Definition setup_X.h:124