annotate win64-mingw/include/vorbis/vorbisenc.h @ 42:2cd0e3b3e1fd

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