annotate src/libvorbis-1.3.3/include/vorbis/vorbisenc.h @ 22:b07fe9e906dc

Portaudio: add missed file
author Chris Cannam
date Tue, 26 Mar 2013 12:14:11 +0000
parents 05aa0afa9217
children
rev   line source
Chris@1 1 /********************************************************************
Chris@1 2 * *
Chris@1 3 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
Chris@1 4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
Chris@1 5 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
Chris@1 6 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
Chris@1 7 * *
Chris@1 8 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
Chris@1 9 * by the Xiph.Org Foundation http://www.xiph.org/ *
Chris@1 10 * *
Chris@1 11 ********************************************************************
Chris@1 12
Chris@1 13 function: vorbis encode-engine setup
Chris@1 14 last mod: $Id: vorbisenc.h 17021 2010-03-24 09:29:41Z xiphmont $
Chris@1 15
Chris@1 16 ********************************************************************/
Chris@1 17
Chris@1 18 /** \file
Chris@1 19 * Libvorbisenc is a convenient API for setting up an encoding
Chris@1 20 * environment using libvorbis. Libvorbisenc encapsulates the
Chris@1 21 * actions needed to set up the encoder properly.
Chris@1 22 */
Chris@1 23
Chris@1 24 #ifndef _OV_ENC_H_
Chris@1 25 #define _OV_ENC_H_
Chris@1 26
Chris@1 27 #ifdef __cplusplus
Chris@1 28 extern "C"
Chris@1 29 {
Chris@1 30 #endif /* __cplusplus */
Chris@1 31
Chris@1 32 #include "codec.h"
Chris@1 33
Chris@1 34 /**
Chris@1 35 * This is the primary function within libvorbisenc for setting up managed
Chris@1 36 * bitrate modes.
Chris@1 37 *
Chris@1 38 * Before this function is called, the \ref vorbis_info
Chris@1 39 * struct should be initialized by using vorbis_info_init() from the libvorbis
Chris@1 40 * API. After encoding, vorbis_info_clear() should be called.
Chris@1 41 *
Chris@1 42 * The max_bitrate, nominal_bitrate, and min_bitrate settings are used to set
Chris@1 43 * constraints for the encoded file. This function uses these settings to
Chris@1 44 * select the appropriate encoding mode and set it up.
Chris@1 45 *
Chris@1 46 * \param vi Pointer to an initialized \ref vorbis_info struct.
Chris@1 47 * \param channels The number of channels to be encoded.
Chris@1 48 * \param rate The sampling rate of the source audio.
Chris@1 49 * \param max_bitrate Desired maximum bitrate (limit). -1 indicates unset.
Chris@1 50 * \param nominal_bitrate Desired average, or central, bitrate. -1 indicates unset.
Chris@1 51 * \param min_bitrate Desired minimum bitrate. -1 indicates unset.
Chris@1 52 *
Chris@1 53 * \return Zero for success, and negative values for failure.
Chris@1 54 *
Chris@1 55 * \retval 0 Success.
Chris@1 56 * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption.
Chris@1 57 * \retval OV_EINVAL Invalid setup request, eg, out of range argument.
Chris@1 58 * \retval OV_EIMPL Unimplemented mode; unable to comply with bitrate request.
Chris@1 59 */
Chris@1 60 extern int vorbis_encode_init(vorbis_info *vi,
Chris@1 61 long channels,
Chris@1 62 long rate,
Chris@1 63
Chris@1 64 long max_bitrate,
Chris@1 65 long nominal_bitrate,
Chris@1 66 long min_bitrate);
Chris@1 67
Chris@1 68 /**
Chris@1 69 * This function performs step-one of a three-step bitrate-managed encode
Chris@1 70 * setup. It functions similarly to the one-step setup performed by \ref
Chris@1 71 * vorbis_encode_init but allows an application to make further encode setup
Chris@1 72 * tweaks using \ref vorbis_encode_ctl before finally calling \ref
Chris@1 73 * vorbis_encode_setup_init to complete the setup process.
Chris@1 74 *
Chris@1 75 * Before this function is called, the \ref vorbis_info struct should be
Chris@1 76 * initialized by using vorbis_info_init() from the libvorbis API. After
Chris@1 77 * encoding, vorbis_info_clear() should be called.
Chris@1 78 *
Chris@1 79 * The max_bitrate, nominal_bitrate, and min_bitrate settings are used to set
Chris@1 80 * constraints for the encoded file. This function uses these settings to
Chris@1 81 * select the appropriate encoding mode and set it up.
Chris@1 82 *
Chris@1 83 * \param vi Pointer to an initialized vorbis_info struct.
Chris@1 84 * \param channels The number of channels to be encoded.
Chris@1 85 * \param rate The sampling rate of the source audio.
Chris@1 86 * \param max_bitrate Desired maximum bitrate (limit). -1 indicates unset.
Chris@1 87 * \param nominal_bitrate Desired average, or central, bitrate. -1 indicates unset.
Chris@1 88 * \param min_bitrate Desired minimum bitrate. -1 indicates unset.
Chris@1 89 *
Chris@1 90 * \return Zero for success, and negative for failure.
Chris@1 91 *
Chris@1 92 * \retval 0 Success
Chris@1 93 * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption.
Chris@1 94 * \retval OV_EINVAL Invalid setup request, eg, out of range argument.
Chris@1 95 * \retval OV_EIMPL Unimplemented mode; unable to comply with bitrate request.
Chris@1 96 */
Chris@1 97 extern int vorbis_encode_setup_managed(vorbis_info *vi,
Chris@1 98 long channels,
Chris@1 99 long rate,
Chris@1 100
Chris@1 101 long max_bitrate,
Chris@1 102 long nominal_bitrate,
Chris@1 103 long min_bitrate);
Chris@1 104
Chris@1 105 /**
Chris@1 106 * This function performs step-one of a three-step variable bitrate
Chris@1 107 * (quality-based) encode setup. It functions similarly to the one-step setup
Chris@1 108 * performed by \ref vorbis_encode_init_vbr() but allows an application to
Chris@1 109 * make further encode setup tweaks using \ref vorbis_encode_ctl() before
Chris@1 110 * finally calling \ref vorbis_encode_setup_init to complete the setup
Chris@1 111 * process.
Chris@1 112 *
Chris@1 113 * Before this function is called, the \ref vorbis_info struct should be
Chris@1 114 * initialized by using \ref vorbis_info_init() from the libvorbis API. After
Chris@1 115 * encoding, vorbis_info_clear() should be called.
Chris@1 116 *
Chris@1 117 * \param vi Pointer to an initialized vorbis_info struct.
Chris@1 118 * \param channels The number of channels to be encoded.
Chris@1 119 * \param rate The sampling rate of the source audio.
Chris@1 120 * \param quality Desired quality level, currently from -0.1 to 1.0 (lo to hi).
Chris@1 121 *
Chris@1 122 * \return Zero for success, and negative values for failure.
Chris@1 123 *
Chris@1 124 * \retval 0 Success
Chris@1 125 * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption.
Chris@1 126 * \retval OV_EINVAL Invalid setup request, eg, out of range argument.
Chris@1 127 * \retval OV_EIMPL Unimplemented mode; unable to comply with quality level request.
Chris@1 128 */
Chris@1 129 extern int vorbis_encode_setup_vbr(vorbis_info *vi,
Chris@1 130 long channels,
Chris@1 131 long rate,
Chris@1 132
Chris@1 133 float quality
Chris@1 134 );
Chris@1 135
Chris@1 136 /**
Chris@1 137 * This is the primary function within libvorbisenc for setting up variable
Chris@1 138 * bitrate ("quality" based) modes.
Chris@1 139 *
Chris@1 140 *
Chris@1 141 * Before this function is called, the vorbis_info struct should be
Chris@1 142 * initialized by using vorbis_info_init() from the libvorbis API. After
Chris@1 143 * encoding, vorbis_info_clear() should be called.
Chris@1 144 *
Chris@1 145 * \param vi Pointer to an initialized vorbis_info struct.
Chris@1 146 * \param channels The number of channels to be encoded.
Chris@1 147 * \param rate The sampling rate of the source audio.
Chris@1 148 * \param base_quality Desired quality level, currently from -0.1 to 1.0 (lo to hi).
Chris@1 149 *
Chris@1 150 *
Chris@1 151 * \return Zero for success, or a negative number for failure.
Chris@1 152 *
Chris@1 153 * \retval 0 Success
Chris@1 154 * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption.
Chris@1 155 * \retval OV_EINVAL Invalid setup request, eg, out of range argument.
Chris@1 156 * \retval OV_EIMPL Unimplemented mode; unable to comply with quality level request.
Chris@1 157 */
Chris@1 158 extern int vorbis_encode_init_vbr(vorbis_info *vi,
Chris@1 159 long channels,
Chris@1 160 long rate,
Chris@1 161
Chris@1 162 float base_quality
Chris@1 163 );
Chris@1 164
Chris@1 165 /**
Chris@1 166 * This function performs the last stage of three-step encoding setup, as
Chris@1 167 * described in the API overview under managed bitrate modes.
Chris@1 168 *
Chris@1 169 * Before this function is called, the \ref vorbis_info struct should be
Chris@1 170 * initialized by using vorbis_info_init() from the libvorbis API, one of
Chris@1 171 * \ref vorbis_encode_setup_managed() or \ref vorbis_encode_setup_vbr() called to
Chris@1 172 * initialize the high-level encoding setup, and \ref vorbis_encode_ctl()
Chris@1 173 * called if necessary to make encoding setup changes.
Chris@1 174 * vorbis_encode_setup_init() finalizes the highlevel encoding structure into
Chris@1 175 * a complete encoding setup after which the application may make no further
Chris@1 176 * setup changes.
Chris@1 177 *
Chris@1 178 * After encoding, vorbis_info_clear() should be called.
Chris@1 179 *
Chris@1 180 * \param vi Pointer to an initialized \ref vorbis_info struct.
Chris@1 181 *
Chris@1 182 * \return Zero for success, and negative values for failure.
Chris@1 183 *
Chris@1 184 * \retval 0 Success.
Chris@1 185 * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption.
Chris@1 186 *
Chris@1 187 * \retval OV_EINVAL Attempt to use vorbis_encode_setup_init() without first
Chris@1 188 * calling one of vorbis_encode_setup_managed() or vorbis_encode_setup_vbr() to
Chris@1 189 * initialize the high-level encoding setup
Chris@1 190 *
Chris@1 191 */
Chris@1 192 extern int vorbis_encode_setup_init(vorbis_info *vi);
Chris@1 193
Chris@1 194 /**
Chris@1 195 * This function implements a generic interface to miscellaneous encoder
Chris@1 196 * settings similar to the classic UNIX 'ioctl()' system call. Applications
Chris@1 197 * may use vorbis_encode_ctl() to query or set bitrate management or quality
Chris@1 198 * mode details by using one of several \e request arguments detailed below.
Chris@1 199 * vorbis_encode_ctl() must be called after one of
Chris@1 200 * vorbis_encode_setup_managed() or vorbis_encode_setup_vbr(). When used
Chris@1 201 * to modify settings, \ref vorbis_encode_ctl() must be called before \ref
Chris@1 202 * vorbis_encode_setup_init().
Chris@1 203 *
Chris@1 204 * \param vi Pointer to an initialized vorbis_info struct.
Chris@1 205 *
Chris@1 206 * \param number Specifies the desired action; See \ref encctlcodes "the list
Chris@1 207 * of available requests".
Chris@1 208 *
Chris@1 209 * \param arg void * pointing to a data structure matching the request
Chris@1 210 * argument.
Chris@1 211 *
Chris@1 212 * \retval 0 Success. Any further return information (such as the result of a
Chris@1 213 * query) is placed into the storage pointed to by *arg.
Chris@1 214 *
Chris@1 215 * \retval OV_EINVAL Invalid argument, or an attempt to modify a setting after
Chris@1 216 * calling vorbis_encode_setup_init().
Chris@1 217 *
Chris@1 218 * \retval OV_EIMPL Unimplemented or unknown request
Chris@1 219 */
Chris@1 220 extern int vorbis_encode_ctl(vorbis_info *vi,int number,void *arg);
Chris@1 221
Chris@1 222 /**
Chris@1 223 * \deprecated This is a deprecated interface. Please use vorbis_encode_ctl()
Chris@1 224 * with the \ref ovectl_ratemanage2_arg struct and \ref
Chris@1 225 * OV_ECTL_RATEMANAGE2_GET and \ref OV_ECTL_RATEMANAGE2_SET calls in new code.
Chris@1 226 *
Chris@1 227 * The \ref ovectl_ratemanage_arg structure is used with vorbis_encode_ctl()
Chris@1 228 * and the \ref OV_ECTL_RATEMANAGE_GET, \ref OV_ECTL_RATEMANAGE_SET, \ref
Chris@1 229 * OV_ECTL_RATEMANAGE_AVG, \ref OV_ECTL_RATEMANAGE_HARD calls in order to
Chris@1 230 * query and modify specifics of the encoder's bitrate management
Chris@1 231 * configuration.
Chris@1 232 */
Chris@1 233 struct ovectl_ratemanage_arg {
Chris@1 234 int management_active; /**< nonzero if bitrate management is active*/
Chris@1 235 /** hard lower limit (in kilobits per second) below which the stream bitrate
Chris@1 236 will never be allowed for any given bitrate_hard_window seconds of time.*/
Chris@1 237 long bitrate_hard_min;
Chris@1 238 /** hard upper limit (in kilobits per second) above which the stream bitrate
Chris@1 239 will never be allowed for any given bitrate_hard_window seconds of time.*/
Chris@1 240 long bitrate_hard_max;
Chris@1 241 /** the window period (in seconds) used to regulate the hard bitrate minimum
Chris@1 242 and maximum*/
Chris@1 243 double bitrate_hard_window;
Chris@1 244 /** soft lower limit (in kilobits per second) below which the average bitrate
Chris@1 245 tracker will start nudging the bitrate higher.*/
Chris@1 246 long bitrate_av_lo;
Chris@1 247 /** soft upper limit (in kilobits per second) above which the average bitrate
Chris@1 248 tracker will start nudging the bitrate lower.*/
Chris@1 249 long bitrate_av_hi;
Chris@1 250 /** the window period (in seconds) used to regulate the average bitrate
Chris@1 251 minimum and maximum.*/
Chris@1 252 double bitrate_av_window;
Chris@1 253 /** Regulates the relative centering of the average and hard windows; in
Chris@1 254 libvorbis 1.0 and 1.0.1, the hard window regulation overlapped but
Chris@1 255 followed the average window regulation. In libvorbis 1.1 a bit-reservoir
Chris@1 256 interface replaces the old windowing interface; the older windowing
Chris@1 257 interface is simulated and this field has no effect.*/
Chris@1 258 double bitrate_av_window_center;
Chris@1 259 };
Chris@1 260
Chris@1 261 /**
Chris@1 262 * \name struct ovectl_ratemanage2_arg
Chris@1 263 *
Chris@1 264 * The ovectl_ratemanage2_arg structure is used with vorbis_encode_ctl() and
Chris@1 265 * the OV_ECTL_RATEMANAGE2_GET and OV_ECTL_RATEMANAGE2_SET calls in order to
Chris@1 266 * query and modify specifics of the encoder's bitrate management
Chris@1 267 * configuration.
Chris@1 268 *
Chris@1 269 */
Chris@1 270 struct ovectl_ratemanage2_arg {
Chris@1 271 int management_active; /**< nonzero if bitrate management is active */
Chris@1 272 /** Lower allowed bitrate limit in kilobits per second */
Chris@1 273 long bitrate_limit_min_kbps;
Chris@1 274 /** Upper allowed bitrate limit in kilobits per second */
Chris@1 275 long bitrate_limit_max_kbps;
Chris@1 276 long bitrate_limit_reservoir_bits; /**<Size of the bitrate reservoir in bits */
Chris@1 277 /** Regulates the bitrate reservoir's preferred fill level in a range from 0.0
Chris@1 278 * to 1.0; 0.0 tries to bank bits to buffer against future bitrate spikes, 1.0
Chris@1 279 * buffers against future sudden drops in instantaneous bitrate. Default is
Chris@1 280 * 0.1
Chris@1 281 */
Chris@1 282 double bitrate_limit_reservoir_bias;
Chris@1 283 /** Average bitrate setting in kilobits per second */
Chris@1 284 long bitrate_average_kbps;
Chris@1 285 /** Slew rate limit setting for average bitrate adjustment; sets the minimum
Chris@1 286 * time in seconds the bitrate tracker may swing from one extreme to the
Chris@1 287 * other when boosting or damping average bitrate.
Chris@1 288 */
Chris@1 289 double bitrate_average_damping;
Chris@1 290 };
Chris@1 291
Chris@1 292
Chris@1 293 /**
Chris@1 294 * \name vorbis_encode_ctl() codes
Chris@1 295 *
Chris@1 296 * \anchor encctlcodes
Chris@1 297 *
Chris@1 298 * These values are passed as the \c number parameter of vorbis_encode_ctl().
Chris@1 299 * The type of the referent of that function's \c arg pointer depends on these
Chris@1 300 * codes.
Chris@1 301 */
Chris@1 302 /*@{*/
Chris@1 303
Chris@1 304 /**
Chris@1 305 * Query the current encoder bitrate management setting.
Chris@1 306 *
Chris@1 307 *Argument: <tt>struct ovectl_ratemanage2_arg *</tt>
Chris@1 308 *
Chris@1 309 * Used to query the current encoder bitrate management setting. Also used to
Chris@1 310 * initialize fields of an ovectl_ratemanage2_arg structure for use with
Chris@1 311 * \ref OV_ECTL_RATEMANAGE2_SET.
Chris@1 312 */
Chris@1 313 #define OV_ECTL_RATEMANAGE2_GET 0x14
Chris@1 314
Chris@1 315 /**
Chris@1 316 * Set the current encoder bitrate management settings.
Chris@1 317 *
Chris@1 318 * Argument: <tt>struct ovectl_ratemanage2_arg *</tt>
Chris@1 319 *
Chris@1 320 * Used to set the current encoder bitrate management settings to the values
Chris@1 321 * listed in the ovectl_ratemanage2_arg. Passing a NULL pointer will disable
Chris@1 322 * bitrate management.
Chris@1 323 */
Chris@1 324 #define OV_ECTL_RATEMANAGE2_SET 0x15
Chris@1 325
Chris@1 326 /**
Chris@1 327 * Returns the current encoder hard-lowpass setting (kHz) in the double
Chris@1 328 * pointed to by arg.
Chris@1 329 *
Chris@1 330 * Argument: <tt>double *</tt>
Chris@1 331 */
Chris@1 332 #define OV_ECTL_LOWPASS_GET 0x20
Chris@1 333
Chris@1 334 /**
Chris@1 335 * Sets the encoder hard-lowpass to the value (kHz) pointed to by arg. Valid
Chris@1 336 * lowpass settings range from 2 to 99.
Chris@1 337 *
Chris@1 338 * Argument: <tt>double *</tt>
Chris@1 339 */
Chris@1 340 #define OV_ECTL_LOWPASS_SET 0x21
Chris@1 341
Chris@1 342 /**
Chris@1 343 * Returns the current encoder impulse block setting in the double pointed
Chris@1 344 * to by arg.
Chris@1 345 *
Chris@1 346 * Argument: <tt>double *</tt>
Chris@1 347 */
Chris@1 348 #define OV_ECTL_IBLOCK_GET 0x30
Chris@1 349
Chris@1 350 /**
Chris@1 351 * Sets the impulse block bias to the the value pointed to by arg.
Chris@1 352 *
Chris@1 353 * Argument: <tt>double *</tt>
Chris@1 354 *
Chris@1 355 * Valid range is -15.0 to 0.0 [default]. A negative impulse block bias will
Chris@1 356 * direct to encoder to use more bits when incoding short blocks that contain
Chris@1 357 * strong impulses, thus improving the accuracy of impulse encoding.
Chris@1 358 */
Chris@1 359 #define OV_ECTL_IBLOCK_SET 0x31
Chris@1 360
Chris@1 361 /**
Chris@1 362 * Returns the current encoder coupling setting in the int pointed
Chris@1 363 * to by arg.
Chris@1 364 *
Chris@1 365 * Argument: <tt>int *</tt>
Chris@1 366 */
Chris@1 367 #define OV_ECTL_COUPLING_GET 0x40
Chris@1 368
Chris@1 369 /**
Chris@1 370 * Enables/disables channel coupling in multichannel encoding according to arg.
Chris@1 371 *
Chris@1 372 * Argument: <tt>int *</tt>
Chris@1 373 *
Chris@1 374 * Zero disables channel coupling for multichannel inputs, nonzer enables
Chris@1 375 * channel coupling. Setting has no effect on monophonic encoding or
Chris@1 376 * multichannel counts that do not offer coupling. At present, coupling is
Chris@1 377 * available for stereo and 5.1 encoding.
Chris@1 378 */
Chris@1 379 #define OV_ECTL_COUPLING_SET 0x41
Chris@1 380
Chris@1 381 /* deprecated rate management supported only for compatibility */
Chris@1 382
Chris@1 383 /**
Chris@1 384 * Old interface to querying bitrate management settings.
Chris@1 385 *
Chris@1 386 * Deprecated after move to bit-reservoir style management in 1.1 rendered
Chris@1 387 * this interface partially obsolete.
Chris@1 388
Chris@1 389 * \deprecated Please use \ref OV_ECTL_RATEMANAGE2_GET instead.
Chris@1 390 *
Chris@1 391 * Argument: <tt>struct ovectl_ratemanage_arg *</tt>
Chris@1 392 */
Chris@1 393 #define OV_ECTL_RATEMANAGE_GET 0x10
Chris@1 394 /**
Chris@1 395 * Old interface to modifying bitrate management settings.
Chris@1 396 *
Chris@1 397 * deprecated after move to bit-reservoir style management in 1.1 rendered
Chris@1 398 * this interface partially obsolete.
Chris@1 399 *
Chris@1 400 * \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead.
Chris@1 401 *
Chris@1 402 * Argument: <tt>struct ovectl_ratemanage_arg *</tt>
Chris@1 403 */
Chris@1 404 #define OV_ECTL_RATEMANAGE_SET 0x11
Chris@1 405 /**
Chris@1 406 * Old interface to setting average-bitrate encoding mode.
Chris@1 407 *
Chris@1 408 * Deprecated after move to bit-reservoir style management in 1.1 rendered
Chris@1 409 * this interface partially obsolete.
Chris@1 410 *
Chris@1 411 * \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead.
Chris@1 412 *
Chris@1 413 * Argument: <tt>struct ovectl_ratemanage_arg *</tt>
Chris@1 414 */
Chris@1 415 #define OV_ECTL_RATEMANAGE_AVG 0x12
Chris@1 416 /**
Chris@1 417 * Old interface to setting bounded-bitrate encoding modes.
Chris@1 418 *
Chris@1 419 * deprecated after move to bit-reservoir style management in 1.1 rendered
Chris@1 420 * this interface partially obsolete.
Chris@1 421 *
Chris@1 422 * \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead.
Chris@1 423 *
Chris@1 424 * Argument: <tt>struct ovectl_ratemanage_arg *</tt>
Chris@1 425 */
Chris@1 426 #define OV_ECTL_RATEMANAGE_HARD 0x13
Chris@1 427
Chris@1 428 /*@}*/
Chris@1 429
Chris@1 430
Chris@1 431
Chris@1 432 #ifdef __cplusplus
Chris@1 433 }
Chris@1 434 #endif /* __cplusplus */
Chris@1 435
Chris@1 436 #endif