annotate win32-mingw/include/vorbis/vorbisenc.h @ 64:eccd51b72864

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