annotate src/libvorbis-1.3.3/include/vorbis/vorbisenc.h @ 168:ceec0dd9ec9c

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