annotate osx/include/vorbis/vorbisenc.h @ 83:ae30d91d2ffe

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