nuclear@0: /******************************************************************** nuclear@0: * * nuclear@0: * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * nuclear@0: * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * nuclear@0: * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * nuclear@0: * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * nuclear@0: * * nuclear@0: * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * nuclear@0: * by the Xiph.Org Foundation http://www.xiph.org/ * nuclear@0: * * nuclear@0: ******************************************************************** nuclear@0: nuclear@0: function: vorbis encode-engine setup nuclear@0: last mod: $Id: vorbisenc.h 17021 2010-03-24 09:29:41Z xiphmont $ nuclear@0: nuclear@0: ********************************************************************/ nuclear@0: nuclear@0: /** \file nuclear@0: * Libvorbisenc is a convenient API for setting up an encoding nuclear@0: * environment using libvorbis. Libvorbisenc encapsulates the nuclear@0: * actions needed to set up the encoder properly. nuclear@0: */ nuclear@0: nuclear@0: #ifndef _OV_ENC_H_ nuclear@0: #define _OV_ENC_H_ nuclear@0: nuclear@0: #ifdef __cplusplus nuclear@0: extern "C" nuclear@0: { nuclear@0: #endif /* __cplusplus */ nuclear@0: nuclear@0: #include "codec.h" nuclear@0: nuclear@0: /** nuclear@0: * This is the primary function within libvorbisenc for setting up managed nuclear@0: * bitrate modes. nuclear@0: * nuclear@0: * Before this function is called, the \ref vorbis_info nuclear@0: * struct should be initialized by using vorbis_info_init() from the libvorbis nuclear@0: * API. After encoding, vorbis_info_clear() should be called. nuclear@0: * nuclear@0: * The max_bitrate, nominal_bitrate, and min_bitrate settings are used to set nuclear@0: * constraints for the encoded file. This function uses these settings to nuclear@0: * select the appropriate encoding mode and set it up. nuclear@0: * nuclear@0: * \param vi Pointer to an initialized \ref vorbis_info struct. nuclear@0: * \param channels The number of channels to be encoded. nuclear@0: * \param rate The sampling rate of the source audio. nuclear@0: * \param max_bitrate Desired maximum bitrate (limit). -1 indicates unset. nuclear@0: * \param nominal_bitrate Desired average, or central, bitrate. -1 indicates unset. nuclear@0: * \param min_bitrate Desired minimum bitrate. -1 indicates unset. nuclear@0: * nuclear@0: * \return Zero for success, and negative values for failure. nuclear@0: * nuclear@0: * \retval 0 Success. nuclear@0: * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. nuclear@0: * \retval OV_EINVAL Invalid setup request, eg, out of range argument. nuclear@0: * \retval OV_EIMPL Unimplemented mode; unable to comply with bitrate request. nuclear@0: */ nuclear@0: extern int vorbis_encode_init(vorbis_info *vi, nuclear@0: long channels, nuclear@0: long rate, nuclear@0: nuclear@0: long max_bitrate, nuclear@0: long nominal_bitrate, nuclear@0: long min_bitrate); nuclear@0: nuclear@0: /** nuclear@0: * This function performs step-one of a three-step bitrate-managed encode nuclear@0: * setup. It functions similarly to the one-step setup performed by \ref nuclear@0: * vorbis_encode_init but allows an application to make further encode setup nuclear@0: * tweaks using \ref vorbis_encode_ctl before finally calling \ref nuclear@0: * vorbis_encode_setup_init to complete the setup process. nuclear@0: * nuclear@0: * Before this function is called, the \ref vorbis_info struct should be nuclear@0: * initialized by using vorbis_info_init() from the libvorbis API. After nuclear@0: * encoding, vorbis_info_clear() should be called. nuclear@0: * nuclear@0: * The max_bitrate, nominal_bitrate, and min_bitrate settings are used to set nuclear@0: * constraints for the encoded file. This function uses these settings to nuclear@0: * select the appropriate encoding mode and set it up. nuclear@0: * nuclear@0: * \param vi Pointer to an initialized vorbis_info struct. nuclear@0: * \param channels The number of channels to be encoded. nuclear@0: * \param rate The sampling rate of the source audio. nuclear@0: * \param max_bitrate Desired maximum bitrate (limit). -1 indicates unset. nuclear@0: * \param nominal_bitrate Desired average, or central, bitrate. -1 indicates unset. nuclear@0: * \param min_bitrate Desired minimum bitrate. -1 indicates unset. nuclear@0: * nuclear@0: * \return Zero for success, and negative for failure. nuclear@0: * nuclear@0: * \retval 0 Success nuclear@0: * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. nuclear@0: * \retval OV_EINVAL Invalid setup request, eg, out of range argument. nuclear@0: * \retval OV_EIMPL Unimplemented mode; unable to comply with bitrate request. nuclear@0: */ nuclear@0: extern int vorbis_encode_setup_managed(vorbis_info *vi, nuclear@0: long channels, nuclear@0: long rate, nuclear@0: nuclear@0: long max_bitrate, nuclear@0: long nominal_bitrate, nuclear@0: long min_bitrate); nuclear@0: nuclear@0: /** nuclear@0: * This function performs step-one of a three-step variable bitrate nuclear@0: * (quality-based) encode setup. It functions similarly to the one-step setup nuclear@0: * performed by \ref vorbis_encode_init_vbr() but allows an application to nuclear@0: * make further encode setup tweaks using \ref vorbis_encode_ctl() before nuclear@0: * finally calling \ref vorbis_encode_setup_init to complete the setup nuclear@0: * process. nuclear@0: * nuclear@0: * Before this function is called, the \ref vorbis_info struct should be nuclear@0: * initialized by using \ref vorbis_info_init() from the libvorbis API. After nuclear@0: * encoding, vorbis_info_clear() should be called. nuclear@0: * nuclear@0: * \param vi Pointer to an initialized vorbis_info struct. nuclear@0: * \param channels The number of channels to be encoded. nuclear@0: * \param rate The sampling rate of the source audio. nuclear@0: * \param quality Desired quality level, currently from -0.1 to 1.0 (lo to hi). nuclear@0: * nuclear@0: * \return Zero for success, and negative values for failure. nuclear@0: * nuclear@0: * \retval 0 Success nuclear@0: * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. nuclear@0: * \retval OV_EINVAL Invalid setup request, eg, out of range argument. nuclear@0: * \retval OV_EIMPL Unimplemented mode; unable to comply with quality level request. nuclear@0: */ nuclear@0: extern int vorbis_encode_setup_vbr(vorbis_info *vi, nuclear@0: long channels, nuclear@0: long rate, nuclear@0: nuclear@0: float quality nuclear@0: ); nuclear@0: nuclear@0: /** nuclear@0: * This is the primary function within libvorbisenc for setting up variable nuclear@0: * bitrate ("quality" based) modes. nuclear@0: * nuclear@0: * nuclear@0: * Before this function is called, the vorbis_info struct should be nuclear@0: * initialized by using vorbis_info_init() from the libvorbis API. After nuclear@0: * encoding, vorbis_info_clear() should be called. nuclear@0: * nuclear@0: * \param vi Pointer to an initialized vorbis_info struct. nuclear@0: * \param channels The number of channels to be encoded. nuclear@0: * \param rate The sampling rate of the source audio. nuclear@0: * \param base_quality Desired quality level, currently from -0.1 to 1.0 (lo to hi). nuclear@0: * nuclear@0: * nuclear@0: * \return Zero for success, or a negative number for failure. nuclear@0: * nuclear@0: * \retval 0 Success nuclear@0: * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. nuclear@0: * \retval OV_EINVAL Invalid setup request, eg, out of range argument. nuclear@0: * \retval OV_EIMPL Unimplemented mode; unable to comply with quality level request. nuclear@0: */ nuclear@0: extern int vorbis_encode_init_vbr(vorbis_info *vi, nuclear@0: long channels, nuclear@0: long rate, nuclear@0: nuclear@0: float base_quality nuclear@0: ); nuclear@0: nuclear@0: /** nuclear@0: * This function performs the last stage of three-step encoding setup, as nuclear@0: * described in the API overview under managed bitrate modes. nuclear@0: * nuclear@0: * Before this function is called, the \ref vorbis_info struct should be nuclear@0: * initialized by using vorbis_info_init() from the libvorbis API, one of nuclear@0: * \ref vorbis_encode_setup_managed() or \ref vorbis_encode_setup_vbr() called to nuclear@0: * initialize the high-level encoding setup, and \ref vorbis_encode_ctl() nuclear@0: * called if necessary to make encoding setup changes. nuclear@0: * vorbis_encode_setup_init() finalizes the highlevel encoding structure into nuclear@0: * a complete encoding setup after which the application may make no further nuclear@0: * setup changes. nuclear@0: * nuclear@0: * After encoding, vorbis_info_clear() should be called. nuclear@0: * nuclear@0: * \param vi Pointer to an initialized \ref vorbis_info struct. nuclear@0: * nuclear@0: * \return Zero for success, and negative values for failure. nuclear@0: * nuclear@0: * \retval 0 Success. nuclear@0: * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. nuclear@0: * nuclear@0: * \retval OV_EINVAL Attempt to use vorbis_encode_setup_init() without first nuclear@0: * calling one of vorbis_encode_setup_managed() or vorbis_encode_setup_vbr() to nuclear@0: * initialize the high-level encoding setup nuclear@0: * nuclear@0: */ nuclear@0: extern int vorbis_encode_setup_init(vorbis_info *vi); nuclear@0: nuclear@0: /** nuclear@0: * This function implements a generic interface to miscellaneous encoder nuclear@0: * settings similar to the classic UNIX 'ioctl()' system call. Applications nuclear@0: * may use vorbis_encode_ctl() to query or set bitrate management or quality nuclear@0: * mode details by using one of several \e request arguments detailed below. nuclear@0: * vorbis_encode_ctl() must be called after one of nuclear@0: * vorbis_encode_setup_managed() or vorbis_encode_setup_vbr(). When used nuclear@0: * to modify settings, \ref vorbis_encode_ctl() must be called before \ref nuclear@0: * vorbis_encode_setup_init(). nuclear@0: * nuclear@0: * \param vi Pointer to an initialized vorbis_info struct. nuclear@0: * nuclear@0: * \param number Specifies the desired action; See \ref encctlcodes "the list nuclear@0: * of available requests". nuclear@0: * nuclear@0: * \param arg void * pointing to a data structure matching the request nuclear@0: * argument. nuclear@0: * nuclear@0: * \retval 0 Success. Any further return information (such as the result of a nuclear@0: * query) is placed into the storage pointed to by *arg. nuclear@0: * nuclear@0: * \retval OV_EINVAL Invalid argument, or an attempt to modify a setting after nuclear@0: * calling vorbis_encode_setup_init(). nuclear@0: * nuclear@0: * \retval OV_EIMPL Unimplemented or unknown request nuclear@0: */ nuclear@0: extern int vorbis_encode_ctl(vorbis_info *vi,int number,void *arg); nuclear@0: nuclear@0: /** nuclear@0: * \deprecated This is a deprecated interface. Please use vorbis_encode_ctl() nuclear@0: * with the \ref ovectl_ratemanage2_arg struct and \ref nuclear@0: * OV_ECTL_RATEMANAGE2_GET and \ref OV_ECTL_RATEMANAGE2_SET calls in new code. nuclear@0: * nuclear@0: * The \ref ovectl_ratemanage_arg structure is used with vorbis_encode_ctl() nuclear@0: * and the \ref OV_ECTL_RATEMANAGE_GET, \ref OV_ECTL_RATEMANAGE_SET, \ref nuclear@0: * OV_ECTL_RATEMANAGE_AVG, \ref OV_ECTL_RATEMANAGE_HARD calls in order to nuclear@0: * query and modify specifics of the encoder's bitrate management nuclear@0: * configuration. nuclear@0: */ nuclear@0: struct ovectl_ratemanage_arg { nuclear@0: int management_active; /**< nonzero if bitrate management is active*/ nuclear@0: /** hard lower limit (in kilobits per second) below which the stream bitrate nuclear@0: will never be allowed for any given bitrate_hard_window seconds of time.*/ nuclear@0: long bitrate_hard_min; nuclear@0: /** hard upper limit (in kilobits per second) above which the stream bitrate nuclear@0: will never be allowed for any given bitrate_hard_window seconds of time.*/ nuclear@0: long bitrate_hard_max; nuclear@0: /** the window period (in seconds) used to regulate the hard bitrate minimum nuclear@0: and maximum*/ nuclear@0: double bitrate_hard_window; nuclear@0: /** soft lower limit (in kilobits per second) below which the average bitrate nuclear@0: tracker will start nudging the bitrate higher.*/ nuclear@0: long bitrate_av_lo; nuclear@0: /** soft upper limit (in kilobits per second) above which the average bitrate nuclear@0: tracker will start nudging the bitrate lower.*/ nuclear@0: long bitrate_av_hi; nuclear@0: /** the window period (in seconds) used to regulate the average bitrate nuclear@0: minimum and maximum.*/ nuclear@0: double bitrate_av_window; nuclear@0: /** Regulates the relative centering of the average and hard windows; in nuclear@0: libvorbis 1.0 and 1.0.1, the hard window regulation overlapped but nuclear@0: followed the average window regulation. In libvorbis 1.1 a bit-reservoir nuclear@0: interface replaces the old windowing interface; the older windowing nuclear@0: interface is simulated and this field has no effect.*/ nuclear@0: double bitrate_av_window_center; nuclear@0: }; nuclear@0: nuclear@0: /** nuclear@0: * \name struct ovectl_ratemanage2_arg nuclear@0: * nuclear@0: * The ovectl_ratemanage2_arg structure is used with vorbis_encode_ctl() and nuclear@0: * the OV_ECTL_RATEMANAGE2_GET and OV_ECTL_RATEMANAGE2_SET calls in order to nuclear@0: * query and modify specifics of the encoder's bitrate management nuclear@0: * configuration. nuclear@0: * nuclear@0: */ nuclear@0: struct ovectl_ratemanage2_arg { nuclear@0: int management_active; /**< nonzero if bitrate management is active */ nuclear@0: /** Lower allowed bitrate limit in kilobits per second */ nuclear@0: long bitrate_limit_min_kbps; nuclear@0: /** Upper allowed bitrate limit in kilobits per second */ nuclear@0: long bitrate_limit_max_kbps; nuclear@0: long bitrate_limit_reservoir_bits; /**struct ovectl_ratemanage2_arg * nuclear@0: * nuclear@0: * Used to query the current encoder bitrate management setting. Also used to nuclear@0: * initialize fields of an ovectl_ratemanage2_arg structure for use with nuclear@0: * \ref OV_ECTL_RATEMANAGE2_SET. nuclear@0: */ nuclear@0: #define OV_ECTL_RATEMANAGE2_GET 0x14 nuclear@0: nuclear@0: /** nuclear@0: * Set the current encoder bitrate management settings. nuclear@0: * nuclear@0: * Argument: struct ovectl_ratemanage2_arg * nuclear@0: * nuclear@0: * Used to set the current encoder bitrate management settings to the values nuclear@0: * listed in the ovectl_ratemanage2_arg. Passing a NULL pointer will disable nuclear@0: * bitrate management. nuclear@0: */ nuclear@0: #define OV_ECTL_RATEMANAGE2_SET 0x15 nuclear@0: nuclear@0: /** nuclear@0: * Returns the current encoder hard-lowpass setting (kHz) in the double nuclear@0: * pointed to by arg. nuclear@0: * nuclear@0: * Argument: double * nuclear@0: */ nuclear@0: #define OV_ECTL_LOWPASS_GET 0x20 nuclear@0: nuclear@0: /** nuclear@0: * Sets the encoder hard-lowpass to the value (kHz) pointed to by arg. Valid nuclear@0: * lowpass settings range from 2 to 99. nuclear@0: * nuclear@0: * Argument: double * nuclear@0: */ nuclear@0: #define OV_ECTL_LOWPASS_SET 0x21 nuclear@0: nuclear@0: /** nuclear@0: * Returns the current encoder impulse block setting in the double pointed nuclear@0: * to by arg. nuclear@0: * nuclear@0: * Argument: double * nuclear@0: */ nuclear@0: #define OV_ECTL_IBLOCK_GET 0x30 nuclear@0: nuclear@0: /** nuclear@0: * Sets the impulse block bias to the the value pointed to by arg. nuclear@0: * nuclear@0: * Argument: double * nuclear@0: * nuclear@0: * Valid range is -15.0 to 0.0 [default]. A negative impulse block bias will nuclear@0: * direct to encoder to use more bits when incoding short blocks that contain nuclear@0: * strong impulses, thus improving the accuracy of impulse encoding. nuclear@0: */ nuclear@0: #define OV_ECTL_IBLOCK_SET 0x31 nuclear@0: nuclear@0: /** nuclear@0: * Returns the current encoder coupling setting in the int pointed nuclear@0: * to by arg. nuclear@0: * nuclear@0: * Argument: int * nuclear@0: */ nuclear@0: #define OV_ECTL_COUPLING_GET 0x40 nuclear@0: nuclear@0: /** nuclear@0: * Enables/disables channel coupling in multichannel encoding according to arg. nuclear@0: * nuclear@0: * Argument: int * nuclear@0: * nuclear@0: * Zero disables channel coupling for multichannel inputs, nonzer enables nuclear@0: * channel coupling. Setting has no effect on monophonic encoding or nuclear@0: * multichannel counts that do not offer coupling. At present, coupling is nuclear@0: * available for stereo and 5.1 encoding. nuclear@0: */ nuclear@0: #define OV_ECTL_COUPLING_SET 0x41 nuclear@0: nuclear@0: /* deprecated rate management supported only for compatibility */ nuclear@0: nuclear@0: /** nuclear@0: * Old interface to querying bitrate management settings. nuclear@0: * nuclear@0: * Deprecated after move to bit-reservoir style management in 1.1 rendered nuclear@0: * this interface partially obsolete. nuclear@0: nuclear@0: * \deprecated Please use \ref OV_ECTL_RATEMANAGE2_GET instead. nuclear@0: * nuclear@0: * Argument: struct ovectl_ratemanage_arg * nuclear@0: */ nuclear@0: #define OV_ECTL_RATEMANAGE_GET 0x10 nuclear@0: /** nuclear@0: * Old interface to modifying bitrate management settings. nuclear@0: * nuclear@0: * deprecated after move to bit-reservoir style management in 1.1 rendered nuclear@0: * this interface partially obsolete. nuclear@0: * nuclear@0: * \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead. nuclear@0: * nuclear@0: * Argument: struct ovectl_ratemanage_arg * nuclear@0: */ nuclear@0: #define OV_ECTL_RATEMANAGE_SET 0x11 nuclear@0: /** nuclear@0: * Old interface to setting average-bitrate encoding mode. nuclear@0: * nuclear@0: * Deprecated after move to bit-reservoir style management in 1.1 rendered nuclear@0: * this interface partially obsolete. nuclear@0: * nuclear@0: * \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead. nuclear@0: * nuclear@0: * Argument: struct ovectl_ratemanage_arg * nuclear@0: */ nuclear@0: #define OV_ECTL_RATEMANAGE_AVG 0x12 nuclear@0: /** nuclear@0: * Old interface to setting bounded-bitrate encoding modes. nuclear@0: * nuclear@0: * deprecated after move to bit-reservoir style management in 1.1 rendered nuclear@0: * this interface partially obsolete. nuclear@0: * nuclear@0: * \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead. nuclear@0: * nuclear@0: * Argument: struct ovectl_ratemanage_arg * nuclear@0: */ nuclear@0: #define OV_ECTL_RATEMANAGE_HARD 0x13 nuclear@0: nuclear@0: /*@}*/ nuclear@0: nuclear@0: nuclear@0: nuclear@0: #ifdef __cplusplus nuclear@0: } nuclear@0: #endif /* __cplusplus */ nuclear@0: nuclear@0: #endif