annotate osx/include/vorbis/vorbisenc.h @ 169:223a55898ab9 tip default

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