opus_defines.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. /* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited
  2. Written by Jean-Marc Valin and Koen Vos */
  3. /*
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions
  6. are met:
  7. - Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. - Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in the
  11. documentation and/or other materials provided with the distribution.
  12. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  13. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  14. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  15. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
  16. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  17. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  18. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  19. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  20. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  21. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. */
  24. /**
  25. * @file opus_defines.h
  26. * @brief Opus reference implementation constants
  27. */
  28. #ifndef OPUS_DEFINES_H
  29. #define OPUS_DEFINES_H
  30. #include "opus_types.h"
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /** @defgroup opus_errorcodes Error codes
  35. * @{
  36. */
  37. /** No error @hideinitializer*/
  38. #define OPUS_OK 0
  39. /** One or more invalid/out of range arguments @hideinitializer*/
  40. #define OPUS_BAD_ARG -1
  41. /** The mode struct passed is invalid @hideinitializer*/
  42. #define OPUS_BUFFER_TOO_SMALL -2
  43. /** An internal error was detected @hideinitializer*/
  44. #define OPUS_INTERNAL_ERROR -3
  45. /** The compressed data passed is corrupted @hideinitializer*/
  46. #define OPUS_INVALID_PACKET -4
  47. /** Invalid/unsupported request number @hideinitializer*/
  48. #define OPUS_UNIMPLEMENTED -5
  49. /** An encoder or decoder structure is invalid or already freed @hideinitializer*/
  50. #define OPUS_INVALID_STATE -6
  51. /** Memory allocation has failed @hideinitializer*/
  52. #define OPUS_ALLOC_FAIL -7
  53. /**@}*/
  54. /** @cond OPUS_INTERNAL_DOC */
  55. /**Export control for opus functions */
  56. #if defined(__GNUC__) && defined(OPUS_BUILD)
  57. # define OPUS_EXPORT __attribute__ ((visibility ("default")))
  58. #elif defined(WIN32) && !defined(__MINGW32__)
  59. # ifdef OPUS_BUILD
  60. # define OPUS_EXPORT __declspec(dllexport)
  61. # else
  62. # define OPUS_EXPORT
  63. # endif
  64. #else
  65. # define OPUS_EXPORT
  66. #endif
  67. # if !defined(OPUS_GNUC_PREREQ)
  68. # if defined(__GNUC__)&&defined(__GNUC_MINOR__)
  69. # define OPUS_GNUC_PREREQ(_maj,_min) \
  70. ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min))
  71. # else
  72. # define OPUS_GNUC_PREREQ(_maj,_min) 0
  73. # endif
  74. # endif
  75. /**Warning attributes for opus functions
  76. * NONNULL is not used in OPUS_BUILD to avoid the compiler optimizing out
  77. * some paranoid null checks. */
  78. #if defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4)
  79. # define OPUS_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__))
  80. #else
  81. # define OPUS_WARN_UNUSED_RESULT
  82. #endif
  83. #if !defined(OPUS_BUILD) && defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4)
  84. # define OPUS_ARG_NONNULL(_x) __attribute__ ((__nonnull__(_x)))
  85. #else
  86. # define OPUS_ARG_NONNULL(_x)
  87. #endif
  88. /** These are the actual Encoder CTL ID numbers.
  89. * They should not be used directly by applications. */
  90. #define OPUS_SET_APPLICATION_REQUEST 4000
  91. #define OPUS_GET_APPLICATION_REQUEST 4001
  92. #define OPUS_SET_BITRATE_REQUEST 4002
  93. #define OPUS_GET_BITRATE_REQUEST 4003
  94. #define OPUS_SET_MAX_BANDWIDTH_REQUEST 4004
  95. #define OPUS_GET_MAX_BANDWIDTH_REQUEST 4005
  96. #define OPUS_SET_VBR_REQUEST 4006
  97. #define OPUS_GET_VBR_REQUEST 4007
  98. #define OPUS_SET_BANDWIDTH_REQUEST 4008
  99. #define OPUS_GET_BANDWIDTH_REQUEST 4009
  100. #define OPUS_SET_COMPLEXITY_REQUEST 4010
  101. #define OPUS_GET_COMPLEXITY_REQUEST 4011
  102. #define OPUS_SET_INBAND_FEC_REQUEST 4012
  103. #define OPUS_GET_INBAND_FEC_REQUEST 4013
  104. #define OPUS_SET_PACKET_LOSS_PERC_REQUEST 4014
  105. #define OPUS_GET_PACKET_LOSS_PERC_REQUEST 4015
  106. #define OPUS_SET_DTX_REQUEST 4016
  107. #define OPUS_GET_DTX_REQUEST 4017
  108. #define OPUS_SET_VBR_CONSTRAINT_REQUEST 4020
  109. #define OPUS_GET_VBR_CONSTRAINT_REQUEST 4021
  110. #define OPUS_SET_FORCE_CHANNELS_REQUEST 4022
  111. #define OPUS_GET_FORCE_CHANNELS_REQUEST 4023
  112. #define OPUS_SET_SIGNAL_REQUEST 4024
  113. #define OPUS_GET_SIGNAL_REQUEST 4025
  114. #define OPUS_GET_LOOKAHEAD_REQUEST 4027
  115. /* #define OPUS_RESET_STATE 4028 */
  116. #define OPUS_GET_FINAL_RANGE_REQUEST 4031
  117. #define OPUS_GET_PITCH_REQUEST 4033
  118. #define OPUS_SET_GAIN_REQUEST 4034
  119. #define OPUS_GET_GAIN_REQUEST 4045
  120. #define OPUS_SET_LSB_DEPTH_REQUEST 4036
  121. #define OPUS_GET_LSB_DEPTH_REQUEST 4037
  122. /* Macros to trigger compilation errors when the wrong types are provided to a CTL */
  123. #define __opus_check_int(x) (((void)((x) == (opus_int32)0)), (opus_int32)(x))
  124. #define __opus_check_int_ptr(ptr) ((ptr) + ((ptr) - (opus_int32*)(ptr)))
  125. #define __opus_check_uint_ptr(ptr) ((ptr) + ((ptr) - (opus_uint32*)(ptr)))
  126. /** @endcond */
  127. /** @defgroup opus_ctlvalues Pre-defined values for CTL interface
  128. * @see opus_genericctls, opus_encoderctls
  129. * @{
  130. */
  131. /* Values for the various encoder CTLs */
  132. #define OPUS_AUTO -1000 /**<Auto/default setting @hideinitializer*/
  133. #define OPUS_BITRATE_MAX -1 /**<Maximum bitrate @hideinitializer*/
  134. /** Best for most VoIP/videoconference applications where listening quality and intelligibility matter most
  135. * @hideinitializer */
  136. #define OPUS_APPLICATION_VOIP 2048
  137. /** Best for broadcast/high-fidelity application where the decoded audio should be as close as possible to the input
  138. * @hideinitializer */
  139. #define OPUS_APPLICATION_AUDIO 2049
  140. /** Only use when lowest-achievable latency is what matters most. Voice-optimized modes cannot be used.
  141. * @hideinitializer */
  142. #define OPUS_APPLICATION_RESTRICTED_LOWDELAY 2051
  143. #define OPUS_SIGNAL_VOICE 3001 /**< Signal being encoded is voice */
  144. #define OPUS_SIGNAL_MUSIC 3002 /**< Signal being encoded is music */
  145. #define OPUS_BANDWIDTH_NARROWBAND 1101 /**< 4kHz bandpass @hideinitializer*/
  146. #define OPUS_BANDWIDTH_MEDIUMBAND 1102 /**< 6kHz bandpass @hideinitializer*/
  147. #define OPUS_BANDWIDTH_WIDEBAND 1103 /**< 8kHz bandpass @hideinitializer*/
  148. #define OPUS_BANDWIDTH_SUPERWIDEBAND 1104 /**<12kHz bandpass @hideinitializer*/
  149. #define OPUS_BANDWIDTH_FULLBAND 1105 /**<20kHz bandpass @hideinitializer*/
  150. /**@}*/
  151. /** @defgroup opus_encoderctls Encoder related CTLs
  152. *
  153. * These are convenience macros for use with the \c opus_encode_ctl
  154. * interface. They are used to generate the appropriate series of
  155. * arguments for that call, passing the correct type, size and so
  156. * on as expected for each particular request.
  157. *
  158. * Some usage examples:
  159. *
  160. * @code
  161. * int ret;
  162. * ret = opus_encoder_ctl(enc_ctx, OPUS_SET_BANDWIDTH(OPUS_AUTO));
  163. * if (ret != OPUS_OK) return ret;
  164. *
  165. * int rate;
  166. * opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&rate));
  167. *
  168. * opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE);
  169. * @endcode
  170. *
  171. * @see opus_genericctls, opus_encoder
  172. * @{
  173. */
  174. /** Configures the encoder's computational complexity.
  175. * The supported range is 0-10 inclusive with 10 representing the highest complexity.
  176. * The default value is 10.
  177. * @param[in] x <tt>int</tt>: 0-10, inclusive
  178. * @hideinitializer */
  179. #define OPUS_SET_COMPLEXITY(x) OPUS_SET_COMPLEXITY_REQUEST, __opus_check_int(x)
  180. /** Gets the encoder's complexity configuration. @see OPUS_SET_COMPLEXITY
  181. * @param[out] x <tt>int*</tt>: 0-10, inclusive
  182. * @hideinitializer */
  183. #define OPUS_GET_COMPLEXITY(x) OPUS_GET_COMPLEXITY_REQUEST, __opus_check_int_ptr(x)
  184. /** Configures the bitrate in the encoder.
  185. * Rates from 500 to 512000 bits per second are meaningful as well as the
  186. * special values OPUS_BITRATE_AUTO and OPUS_BITRATE_MAX.
  187. * The value OPUS_BITRATE_MAX can be used to cause the codec to use as much rate
  188. * as it can, which is useful for controlling the rate by adjusting the output
  189. * buffer size.
  190. * @param[in] x <tt>opus_int32</tt>: bitrate in bits per second.
  191. * @hideinitializer */
  192. #define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __opus_check_int(x)
  193. /** Gets the encoder's bitrate configuration. @see OPUS_SET_BITRATE
  194. * @param[out] x <tt>opus_int32*</tt>: bitrate in bits per second.
  195. * @hideinitializer */
  196. #define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __opus_check_int_ptr(x)
  197. /** Configures VBR in the encoder.
  198. * The following values are currently supported:
  199. * - 0 CBR
  200. * - 1 VBR (default)
  201. * The configured bitrate may not be met exactly because frames must
  202. * be an integer number of bytes in length.
  203. * @warning Only the MDCT mode of Opus can provide hard CBR behavior.
  204. * @param[in] x <tt>int</tt>: 0; 1 (default)
  205. * @hideinitializer */
  206. #define OPUS_SET_VBR(x) OPUS_SET_VBR_REQUEST, __opus_check_int(x)
  207. /** Gets the encoder's VBR configuration. @see OPUS_SET_VBR
  208. * @param[out] x <tt>int*</tt>: 0; 1
  209. * @hideinitializer */
  210. #define OPUS_GET_VBR(x) OPUS_GET_VBR_REQUEST, __opus_check_int_ptr(x)
  211. /** Configures constrained VBR in the encoder.
  212. * The following values are currently supported:
  213. * - 0 Unconstrained VBR (default)
  214. * - 1 Maximum one frame buffering delay assuming transport with a serialization speed of the nominal bitrate
  215. * This setting is irrelevant when the encoder is in CBR mode.
  216. * @warning Only the MDCT mode of Opus currently heeds the constraint.
  217. * Speech mode ignores it completely, hybrid mode may fail to obey it
  218. * if the LPC layer uses more bitrate than the constraint would have
  219. * permitted.
  220. * @param[in] x <tt>int</tt>: 0 (default); 1
  221. * @hideinitializer */
  222. #define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __opus_check_int(x)
  223. /** Gets the encoder's constrained VBR configuration @see OPUS_SET_VBR_CONSTRAINT
  224. * @param[out] x <tt>int*</tt>: 0; 1
  225. * @hideinitializer */
  226. #define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __opus_check_int_ptr(x)
  227. /** Configures mono/stereo forcing in the encoder.
  228. * This is useful when the caller knows that the input signal is currently a mono
  229. * source embedded in a stereo stream.
  230. * @param[in] x <tt>int</tt>: OPUS_AUTO (default); 1 (forced mono); 2 (forced stereo)
  231. * @hideinitializer */
  232. #define OPUS_SET_FORCE_CHANNELS(x) OPUS_SET_FORCE_CHANNELS_REQUEST, __opus_check_int(x)
  233. /** Gets the encoder's forced channel configuration. @see OPUS_SET_FORCE_CHANNELS
  234. * @param[out] x <tt>int*</tt>: OPUS_AUTO; 0; 1
  235. * @hideinitializer */
  236. #define OPUS_GET_FORCE_CHANNELS(x) OPUS_GET_FORCE_CHANNELS_REQUEST, __opus_check_int_ptr(x)
  237. /** Configures the encoder's maximum bandpass allowed. @see OPUS_GET_MAX_BANDWIDTH
  238. * The supported values are:
  239. * - OPUS_BANDWIDTH_NARROWBAND 4kHz passband
  240. * - OPUS_BANDWIDTH_MEDIUMBAND 6kHz passband
  241. * - OPUS_BANDWIDTH_WIDEBAND 8kHz passband
  242. * - OPUS_BANDWIDTH_SUPERWIDEBAND 12kHz passband
  243. * - OPUS_BANDWIDTH_FULLBAND 20kHz passband (default)
  244. * @param[in] x <tt>int</tt>: Bandwidth value
  245. * @hideinitializer */
  246. #define OPUS_SET_MAX_BANDWIDTH(x) OPUS_SET_MAX_BANDWIDTH_REQUEST, __opus_check_int(x)
  247. /** Gets the encoder's configured maximum bandpass allowed. @see OPUS_SET_MAX_BANDWIDTH
  248. * @param[out] x <tt>int*</tt>: Bandwidth value
  249. * @hideinitializer */
  250. #define OPUS_GET_MAX_BANDWIDTH(x) OPUS_GET_MAX_BANDWIDTH_REQUEST, __opus_check_int_ptr(x)
  251. /** Configures the encoder's bandpass. @see OPUS_GET_BANDWIDTH
  252. * The supported values are:
  253. * - OPUS_AUTO (default)
  254. * - OPUS_BANDWIDTH_NARROWBAND 4kHz passband
  255. * - OPUS_BANDWIDTH_MEDIUMBAND 6kHz passband
  256. * - OPUS_BANDWIDTH_WIDEBAND 8kHz passband
  257. * - OPUS_BANDWIDTH_SUPERWIDEBAND 12kHz passband
  258. * - OPUS_BANDWIDTH_FULLBAND 20kHz passband
  259. * @param[in] x <tt>int</tt>: Bandwidth value
  260. * @hideinitializer */
  261. #define OPUS_SET_BANDWIDTH(x) OPUS_SET_BANDWIDTH_REQUEST, __opus_check_int(x)
  262. /** Configures the type of signal being encoded.
  263. * This is a hint which helps the encoder's mode selection.
  264. * The supported values are:
  265. * - OPUS_SIGNAL_AUTO (default)
  266. * - OPUS_SIGNAL_VOICE
  267. * - OPUS_SIGNAL_MUSIC
  268. * @param[in] x <tt>int</tt>: Signal type
  269. * @hideinitializer */
  270. #define OPUS_SET_SIGNAL(x) OPUS_SET_SIGNAL_REQUEST, __opus_check_int(x)
  271. /** Gets the encoder's configured signal type. @see OPUS_SET_SIGNAL
  272. *
  273. * @param[out] x <tt>int*</tt>: Signal type
  274. * @hideinitializer */
  275. #define OPUS_GET_SIGNAL(x) OPUS_GET_SIGNAL_REQUEST, __opus_check_int_ptr(x)
  276. /** Configures the encoder's intended application.
  277. * The initial value is a mandatory argument to the encoder_create function.
  278. * The supported values are:
  279. * - OPUS_APPLICATION_VOIP Process signal for improved speech intelligibility
  280. * - OPUS_APPLICATION_AUDIO Favor faithfulness to the original input
  281. * - OPUS_APPLICATION_RESTRICTED_LOWDELAY Configure the minimum possible coding delay
  282. *
  283. * @param[in] x <tt>int</tt>: Application value
  284. * @hideinitializer */
  285. #define OPUS_SET_APPLICATION(x) OPUS_SET_APPLICATION_REQUEST, __opus_check_int(x)
  286. /** Gets the encoder's configured application. @see OPUS_SET_APPLICATION
  287. *
  288. * @param[out] x <tt>int*</tt>: Application value
  289. * @hideinitializer */
  290. #define OPUS_GET_APPLICATION(x) OPUS_GET_APPLICATION_REQUEST, __opus_check_int_ptr(x)
  291. /** Gets the total samples of delay added by the entire codec.
  292. * This can be queried by the encoder and then the provided number of samples can be
  293. * skipped on from the start of the decoder's output to provide time aligned input
  294. * and output. From the perspective of a decoding application the real data begins this many
  295. * samples late.
  296. *
  297. * The decoder contribution to this delay is identical for all decoders, but the
  298. * encoder portion of the delay may vary from implementation to implementation,
  299. * version to version, or even depend on the encoder's initial configuration.
  300. * Applications needing delay compensation should call this CTL rather than
  301. * hard-coding a value.
  302. * @param[out] x <tt>int*</tt>: Number of lookahead samples
  303. * @hideinitializer */
  304. #define OPUS_GET_LOOKAHEAD(x) OPUS_GET_LOOKAHEAD_REQUEST, __opus_check_int_ptr(x)
  305. /** Configures the encoder's use of inband forward error correction.
  306. * @note This is only applicable to the LPC layer
  307. *
  308. * @param[in] x <tt>int</tt>: FEC flag, 0 (disabled) is default
  309. * @hideinitializer */
  310. #define OPUS_SET_INBAND_FEC(x) OPUS_SET_INBAND_FEC_REQUEST, __opus_check_int(x)
  311. /** Gets encoder's configured use of inband forward error correction. @see OPUS_SET_INBAND_FEC
  312. *
  313. * @param[out] x <tt>int*</tt>: FEC flag
  314. * @hideinitializer */
  315. #define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_int_ptr(x)
  316. /** Configures the encoder's expected packet loss percentage.
  317. * Higher values with trigger progressively more loss resistant behavior in the encoder
  318. * at the expense of quality at a given bitrate in the lossless case, but greater quality
  319. * under loss.
  320. *
  321. * @param[in] x <tt>int</tt>: Loss percentage in the range 0-100, inclusive.
  322. * @hideinitializer */
  323. #define OPUS_SET_PACKET_LOSS_PERC(x) OPUS_SET_PACKET_LOSS_PERC_REQUEST, __opus_check_int(x)
  324. /** Gets the encoder's configured packet loss percentage. @see OPUS_SET_PACKET_LOSS_PERC
  325. *
  326. * @param[out] x <tt>int*</tt>: Loss percentage in the range 0-100, inclusive.
  327. * @hideinitializer */
  328. #define OPUS_GET_PACKET_LOSS_PERC(x) OPUS_GET_PACKET_LOSS_PERC_REQUEST, __opus_check_int_ptr(x)
  329. /** Configures the encoder's use of discontinuous transmission.
  330. * @note This is only applicable to the LPC layer
  331. *
  332. * @param[in] x <tt>int</tt>: DTX flag, 0 (disabled) is default
  333. * @hideinitializer */
  334. #define OPUS_SET_DTX(x) OPUS_SET_DTX_REQUEST, __opus_check_int(x)
  335. /** Gets encoder's configured use of discontinuous transmission. @see OPUS_SET_DTX
  336. *
  337. * @param[out] x <tt>int*</tt>: DTX flag
  338. * @hideinitializer */
  339. #define OPUS_GET_DTX(x) OPUS_GET_DTX_REQUEST, __opus_check_int_ptr(x)
  340. /**@}*/
  341. /** @defgroup opus_genericctls Generic CTLs
  342. *
  343. * These macros are used with the \c opus_decoder_ctl and
  344. * \c opus_encoder_ctl calls to generate a particular
  345. * request.
  346. *
  347. * When called on an \c OpusDecoder they apply to that
  348. * particular decoder instance. When called on an
  349. * \c OpusEncoder they apply to the corresponding setting
  350. * on that encoder instance, if present.
  351. *
  352. * Some usage examples:
  353. *
  354. * @code
  355. * int ret;
  356. * opus_int32 pitch;
  357. * ret = opus_decoder_ctl(dec_ctx, OPUS_GET_PITCH(&pitch));
  358. * if (ret == OPUS_OK) return ret;
  359. *
  360. * opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE);
  361. * opus_decoder_ctl(dec_ctx, OPUS_RESET_STATE);
  362. *
  363. * opus_int32 enc_bw, dec_bw;
  364. * opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&enc_bw));
  365. * opus_decoder_ctl(dec_ctx, OPUS_GET_BANDWIDTH(&dec_bw));
  366. * if (enc_bw != dec_bw) {
  367. * printf("packet bandwidth mismatch!\n");
  368. * }
  369. * @endcode
  370. *
  371. * @see opus_encoder, opus_decoder_ctl, opus_encoder_ctl, opus_decoderctls, opus_encoderctls
  372. * @{
  373. */
  374. /** Resets the codec state to be equivalent to a freshly initialized state.
  375. * This should be called when switching streams in order to prevent
  376. * the back to back decoding from giving different results from
  377. * one at a time decoding.
  378. * @hideinitializer */
  379. #define OPUS_RESET_STATE 4028
  380. /** Gets the final state of the codec's entropy coder.
  381. * This is used for testing purposes,
  382. * The encoder and decoder state should be identical after coding a payload
  383. * (assuming no data corruption or software bugs)
  384. *
  385. * @param[out] x <tt>opus_uint32*</tt>: Entropy coder state
  386. *
  387. * @hideinitializer */
  388. #define OPUS_GET_FINAL_RANGE(x) OPUS_GET_FINAL_RANGE_REQUEST, __opus_check_uint_ptr(x)
  389. /** Gets the pitch of the last decoded frame, if available.
  390. * This can be used for any post-processing algorithm requiring the use of pitch,
  391. * e.g. time stretching/shortening. If the last frame was not voiced, or if the
  392. * pitch was not coded in the frame, then zero is returned.
  393. *
  394. * This CTL is only implemented for decoder instances.
  395. *
  396. * @param[out] x <tt>opus_int32*</tt>: pitch period at 48 kHz (or 0 if not available)
  397. *
  398. * @hideinitializer */
  399. #define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x)
  400. /** Gets the encoder's configured bandpass or the decoder's last bandpass. @see OPUS_SET_BANDWIDTH
  401. * @param[out] x <tt>int*</tt>: Bandwidth value
  402. * @hideinitializer */
  403. #define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __opus_check_int_ptr(x)
  404. /** Configures the depth of signal being encoded.
  405. * This is a hint which helps the encoder identify silence and near-silence.
  406. * The supported values are between 8 and 24 (default)
  407. * @param[in] x <tt>opus_int32</tt>: Input precision
  408. * @hideinitializer */
  409. #define OPUS_SET_LSB_DEPTH(x) OPUS_SET_LSB_DEPTH_REQUEST, __opus_check_int(x)
  410. /** Gets the encoder's configured signal depth. @see OPUS_SET_LSB_DEPTH
  411. *
  412. * @param[out] x <tt>opus_int32*</tt>: Input precision
  413. * @hideinitializer */
  414. #define OPUS_GET_LSB_DEPTH(x) OPUS_GET_LSB_DEPTH_REQUEST, __opus_check_int_ptr(x)
  415. /**@}*/
  416. /** @defgroup opus_decoderctls Decoder related CTLs
  417. * @see opus_genericctls, opus_encoderctls, opus_decoder
  418. * @{
  419. */
  420. /** Configures decoder gain adjustment.
  421. * Scales the decoded output by a factor specified in Q8 dB units.
  422. * This has a maximum range of -32768 to 32767 inclusive, and returns
  423. * OPUS_BAD_ARG otherwise. The default is zero indicating no adjustment.
  424. * This setting survives decoder reset.
  425. *
  426. * gain = pow(10, x/(20.0*256))
  427. *
  428. * @param[in] x <tt>opus_int32</tt>: Amount to scale PCM signal by in Q8 dB units.
  429. * @hideinitializer */
  430. #define OPUS_SET_GAIN(x) OPUS_SET_GAIN_REQUEST, __opus_check_int(x)
  431. /** Gets the decoder's configured gain adjustment. @see OPUS_SET_GAIN
  432. *
  433. * @param[out] x <tt>opus_int32*</tt>: Amount to scale PCM signal by in Q8 dB units.
  434. * @hideinitializer */
  435. #define OPUS_GET_GAIN(x) OPUS_GET_GAIN_REQUEST, __opus_check_int_ptr(x)
  436. /**@}*/
  437. /** @defgroup opus_libinfo Opus library information functions
  438. * @{
  439. */
  440. /** Converts an opus error code into a human readable string.
  441. *
  442. * @param[in] error <tt>int</tt>: Error number
  443. * @returns Error string
  444. */
  445. OPUS_EXPORT const char *opus_strerror(int error);
  446. /** Gets the libopus version string.
  447. *
  448. * @returns Version string
  449. */
  450. OPUS_EXPORT const char *opus_get_version_string(void);
  451. /**@}*/
  452. #ifdef __cplusplus
  453. }
  454. #endif
  455. #endif /* OPUS_DEFINES_H */