opus_projection.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. /* Copyright (c) 2017 Google Inc.
  2. Written by Andrew Allen */
  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_projection.h
  26. * @brief Opus projection reference API
  27. */
  28. #ifndef OPUS_PROJECTION_H
  29. #define OPUS_PROJECTION_H
  30. #include "opus_multistream.h"
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /** @cond OPUS_INTERNAL_DOC */
  35. /** These are the actual encoder and decoder CTL ID numbers.
  36. * They should not be used directly by applications.c
  37. * In general, SETs should be even and GETs should be odd.*/
  38. /**@{*/
  39. #define OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN_REQUEST 6001
  40. #define OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE_REQUEST 6003
  41. #define OPUS_PROJECTION_GET_DEMIXING_MATRIX_REQUEST 6005
  42. /**@}*/
  43. /** @endcond */
  44. /** @defgroup opus_projection_ctls Projection specific encoder and decoder CTLs
  45. *
  46. * These are convenience macros that are specific to the
  47. * opus_projection_encoder_ctl() and opus_projection_decoder_ctl()
  48. * interface.
  49. * The CTLs from @ref opus_genericctls, @ref opus_encoderctls,
  50. * @ref opus_decoderctls, and @ref opus_multistream_ctls may be applied to a
  51. * projection encoder or decoder as well.
  52. */
  53. /**@{*/
  54. /** Gets the gain (in dB. S7.8-format) of the demixing matrix from the encoder.
  55. * @param[out] x <tt>opus_int32 *</tt>: Returns the gain (in dB. S7.8-format)
  56. * of the demixing matrix.
  57. * @hideinitializer
  58. */
  59. #define OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN(x) OPUS_PROJECTION_GET_DEMIXING_MATRIX_GAIN_REQUEST, __opus_check_int_ptr(x)
  60. /** Gets the size in bytes of the demixing matrix from the encoder.
  61. * @param[out] x <tt>opus_int32 *</tt>: Returns the size in bytes of the
  62. * demixing matrix.
  63. * @hideinitializer
  64. */
  65. #define OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE(x) OPUS_PROJECTION_GET_DEMIXING_MATRIX_SIZE_REQUEST, __opus_check_int_ptr(x)
  66. /** Copies the demixing matrix to the supplied pointer location.
  67. * @param[out] x <tt>unsigned char *</tt>: Returns the demixing matrix to the
  68. * supplied pointer location.
  69. * @param y <tt>opus_int32</tt>: The size in bytes of the reserved memory at the
  70. * pointer location.
  71. * @hideinitializer
  72. */
  73. #define OPUS_PROJECTION_GET_DEMIXING_MATRIX(x,y) OPUS_PROJECTION_GET_DEMIXING_MATRIX_REQUEST, x, __opus_check_int(y)
  74. /**@}*/
  75. /** Opus projection encoder state.
  76. * This contains the complete state of a projection Opus encoder.
  77. * It is position independent and can be freely copied.
  78. * @see opus_projection_ambisonics_encoder_create
  79. */
  80. typedef struct OpusProjectionEncoder OpusProjectionEncoder;
  81. /** Opus projection decoder state.
  82. * This contains the complete state of a projection Opus decoder.
  83. * It is position independent and can be freely copied.
  84. * @see opus_projection_decoder_create
  85. * @see opus_projection_decoder_init
  86. */
  87. typedef struct OpusProjectionDecoder OpusProjectionDecoder;
  88. /**\name Projection encoder functions */
  89. /**@{*/
  90. /** Gets the size of an OpusProjectionEncoder structure.
  91. * @param channels <tt>int</tt>: The total number of input channels to encode.
  92. * This must be no more than 255.
  93. * @param mapping_family <tt>int</tt>: The mapping family to use for selecting
  94. * the appropriate projection.
  95. * @returns The size in bytes on success, or a negative error code
  96. * (see @ref opus_errorcodes) on error.
  97. */
  98. OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_projection_ambisonics_encoder_get_size(
  99. int channels,
  100. int mapping_family
  101. );
  102. /** Allocates and initializes a projection encoder state.
  103. * Call opus_projection_encoder_destroy() to release
  104. * this object when finished.
  105. * @param Fs <tt>opus_int32</tt>: Sampling rate of the input signal (in Hz).
  106. * This must be one of 8000, 12000, 16000,
  107. * 24000, or 48000.
  108. * @param channels <tt>int</tt>: Number of channels in the input signal.
  109. * This must be at most 255.
  110. * It may be greater than the number of
  111. * coded channels (<code>streams +
  112. * coupled_streams</code>).
  113. * @param mapping_family <tt>int</tt>: The mapping family to use for selecting
  114. * the appropriate projection.
  115. * @param[out] streams <tt>int *</tt>: The total number of streams that will
  116. * be encoded from the input.
  117. * @param[out] coupled_streams <tt>int *</tt>: Number of coupled (2 channel)
  118. * streams that will be encoded from the input.
  119. * @param application <tt>int</tt>: The target encoder application.
  120. * This must be one of the following:
  121. * <dl>
  122. * <dt>#OPUS_APPLICATION_VOIP</dt>
  123. * <dd>Process signal for improved speech intelligibility.</dd>
  124. * <dt>#OPUS_APPLICATION_AUDIO</dt>
  125. * <dd>Favor faithfulness to the original input.</dd>
  126. * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt>
  127. * <dd>Configure the minimum possible coding delay by disabling certain modes
  128. * of operation.</dd>
  129. * </dl>
  130. * @param[out] error <tt>int *</tt>: Returns #OPUS_OK on success, or an error
  131. * code (see @ref opus_errorcodes) on
  132. * failure.
  133. */
  134. OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusProjectionEncoder *opus_projection_ambisonics_encoder_create(
  135. opus_int32 Fs,
  136. int channels,
  137. int mapping_family,
  138. int *streams,
  139. int *coupled_streams,
  140. int application,
  141. int *error
  142. ) OPUS_ARG_NONNULL(4) OPUS_ARG_NONNULL(5);
  143. /** Initialize a previously allocated projection encoder state.
  144. * The memory pointed to by \a st must be at least the size returned by
  145. * opus_projection_ambisonics_encoder_get_size().
  146. * This is intended for applications which use their own allocator instead of
  147. * malloc.
  148. * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL.
  149. * @see opus_projection_ambisonics_encoder_create
  150. * @see opus_projection_ambisonics_encoder_get_size
  151. * @param st <tt>OpusProjectionEncoder*</tt>: Projection encoder state to initialize.
  152. * @param Fs <tt>opus_int32</tt>: Sampling rate of the input signal (in Hz).
  153. * This must be one of 8000, 12000, 16000,
  154. * 24000, or 48000.
  155. * @param channels <tt>int</tt>: Number of channels in the input signal.
  156. * This must be at most 255.
  157. * It may be greater than the number of
  158. * coded channels (<code>streams +
  159. * coupled_streams</code>).
  160. * @param streams <tt>int</tt>: The total number of streams to encode from the
  161. * input.
  162. * This must be no more than the number of channels.
  163. * @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams
  164. * to encode.
  165. * This must be no larger than the total
  166. * number of streams.
  167. * Additionally, The total number of
  168. * encoded channels (<code>streams +
  169. * coupled_streams</code>) must be no
  170. * more than the number of input channels.
  171. * @param application <tt>int</tt>: The target encoder application.
  172. * This must be one of the following:
  173. * <dl>
  174. * <dt>#OPUS_APPLICATION_VOIP</dt>
  175. * <dd>Process signal for improved speech intelligibility.</dd>
  176. * <dt>#OPUS_APPLICATION_AUDIO</dt>
  177. * <dd>Favor faithfulness to the original input.</dd>
  178. * <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt>
  179. * <dd>Configure the minimum possible coding delay by disabling certain modes
  180. * of operation.</dd>
  181. * </dl>
  182. * @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes)
  183. * on failure.
  184. */
  185. OPUS_EXPORT int opus_projection_ambisonics_encoder_init(
  186. OpusProjectionEncoder *st,
  187. opus_int32 Fs,
  188. int channels,
  189. int mapping_family,
  190. int *streams,
  191. int *coupled_streams,
  192. int application
  193. ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(5) OPUS_ARG_NONNULL(6);
  194. /** Encodes a projection Opus frame.
  195. * @param st <tt>OpusProjectionEncoder*</tt>: Projection encoder state.
  196. * @param[in] pcm <tt>const opus_int16*</tt>: The input signal as interleaved
  197. * samples.
  198. * This must contain
  199. * <code>frame_size*channels</code>
  200. * samples.
  201. * @param frame_size <tt>int</tt>: Number of samples per channel in the input
  202. * signal.
  203. * This must be an Opus frame size for the
  204. * encoder's sampling rate.
  205. * For example, at 48 kHz the permitted values
  206. * are 120, 240, 480, 960, 1920, and 2880.
  207. * Passing in a duration of less than 10 ms
  208. * (480 samples at 48 kHz) will prevent the
  209. * encoder from using the LPC or hybrid modes.
  210. * @param[out] data <tt>unsigned char*</tt>: Output payload.
  211. * This must contain storage for at
  212. * least \a max_data_bytes.
  213. * @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated
  214. * memory for the output
  215. * payload. This may be
  216. * used to impose an upper limit on
  217. * the instant bitrate, but should
  218. * not be used as the only bitrate
  219. * control. Use #OPUS_SET_BITRATE to
  220. * control the bitrate.
  221. * @returns The length of the encoded packet (in bytes) on success or a
  222. * negative error code (see @ref opus_errorcodes) on failure.
  223. */
  224. OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_encode(
  225. OpusProjectionEncoder *st,
  226. const opus_int16 *pcm,
  227. int frame_size,
  228. unsigned char *data,
  229. opus_int32 max_data_bytes
  230. ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
  231. /** Encodes a projection Opus frame from floating point input.
  232. * @param st <tt>OpusProjectionEncoder*</tt>: Projection encoder state.
  233. * @param[in] pcm <tt>const float*</tt>: The input signal as interleaved
  234. * samples with a normal range of
  235. * +/-1.0.
  236. * Samples with a range beyond +/-1.0
  237. * are supported but will be clipped by
  238. * decoders using the integer API and
  239. * should only be used if it is known
  240. * that the far end supports extended
  241. * dynamic range.
  242. * This must contain
  243. * <code>frame_size*channels</code>
  244. * samples.
  245. * @param frame_size <tt>int</tt>: Number of samples per channel in the input
  246. * signal.
  247. * This must be an Opus frame size for the
  248. * encoder's sampling rate.
  249. * For example, at 48 kHz the permitted values
  250. * are 120, 240, 480, 960, 1920, and 2880.
  251. * Passing in a duration of less than 10 ms
  252. * (480 samples at 48 kHz) will prevent the
  253. * encoder from using the LPC or hybrid modes.
  254. * @param[out] data <tt>unsigned char*</tt>: Output payload.
  255. * This must contain storage for at
  256. * least \a max_data_bytes.
  257. * @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated
  258. * memory for the output
  259. * payload. This may be
  260. * used to impose an upper limit on
  261. * the instant bitrate, but should
  262. * not be used as the only bitrate
  263. * control. Use #OPUS_SET_BITRATE to
  264. * control the bitrate.
  265. * @returns The length of the encoded packet (in bytes) on success or a
  266. * negative error code (see @ref opus_errorcodes) on failure.
  267. */
  268. OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_encode_float(
  269. OpusProjectionEncoder *st,
  270. const float *pcm,
  271. int frame_size,
  272. unsigned char *data,
  273. opus_int32 max_data_bytes
  274. ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4);
  275. /** Frees an <code>OpusProjectionEncoder</code> allocated by
  276. * opus_projection_ambisonics_encoder_create().
  277. * @param st <tt>OpusProjectionEncoder*</tt>: Projection encoder state to be freed.
  278. */
  279. OPUS_EXPORT void opus_projection_encoder_destroy(OpusProjectionEncoder *st);
  280. /** Perform a CTL function on a projection Opus encoder.
  281. *
  282. * Generally the request and subsequent arguments are generated by a
  283. * convenience macro.
  284. * @param st <tt>OpusProjectionEncoder*</tt>: Projection encoder state.
  285. * @param request This and all remaining parameters should be replaced by one
  286. * of the convenience macros in @ref opus_genericctls,
  287. * @ref opus_encoderctls, @ref opus_multistream_ctls, or
  288. * @ref opus_projection_ctls
  289. * @see opus_genericctls
  290. * @see opus_encoderctls
  291. * @see opus_multistream_ctls
  292. * @see opus_projection_ctls
  293. */
  294. OPUS_EXPORT int opus_projection_encoder_ctl(OpusProjectionEncoder *st, int request, ...) OPUS_ARG_NONNULL(1);
  295. /**@}*/
  296. /**\name Projection decoder functions */
  297. /**@{*/
  298. /** Gets the size of an <code>OpusProjectionDecoder</code> structure.
  299. * @param channels <tt>int</tt>: The total number of output channels.
  300. * This must be no more than 255.
  301. * @param streams <tt>int</tt>: The total number of streams coded in the
  302. * input.
  303. * This must be no more than 255.
  304. * @param coupled_streams <tt>int</tt>: Number streams to decode as coupled
  305. * (2 channel) streams.
  306. * This must be no larger than the total
  307. * number of streams.
  308. * Additionally, The total number of
  309. * coded channels (<code>streams +
  310. * coupled_streams</code>) must be no
  311. * more than 255.
  312. * @returns The size in bytes on success, or a negative error code
  313. * (see @ref opus_errorcodes) on error.
  314. */
  315. OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_projection_decoder_get_size(
  316. int channels,
  317. int streams,
  318. int coupled_streams
  319. );
  320. /** Allocates and initializes a projection decoder state.
  321. * Call opus_projection_decoder_destroy() to release
  322. * this object when finished.
  323. * @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz).
  324. * This must be one of 8000, 12000, 16000,
  325. * 24000, or 48000.
  326. * @param channels <tt>int</tt>: Number of channels to output.
  327. * This must be at most 255.
  328. * It may be different from the number of coded
  329. * channels (<code>streams +
  330. * coupled_streams</code>).
  331. * @param streams <tt>int</tt>: The total number of streams coded in the
  332. * input.
  333. * This must be no more than 255.
  334. * @param coupled_streams <tt>int</tt>: Number of streams to decode as coupled
  335. * (2 channel) streams.
  336. * This must be no larger than the total
  337. * number of streams.
  338. * Additionally, The total number of
  339. * coded channels (<code>streams +
  340. * coupled_streams</code>) must be no
  341. * more than 255.
  342. * @param[in] demixing_matrix <tt>const unsigned char[demixing_matrix_size]</tt>: Demixing matrix
  343. * that mapping from coded channels to output channels,
  344. * as described in @ref opus_projection and
  345. * @ref opus_projection_ctls.
  346. * @param demixing_matrix_size <tt>opus_int32</tt>: The size in bytes of the
  347. * demixing matrix, as
  348. * described in @ref
  349. * opus_projection_ctls.
  350. * @param[out] error <tt>int *</tt>: Returns #OPUS_OK on success, or an error
  351. * code (see @ref opus_errorcodes) on
  352. * failure.
  353. */
  354. OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusProjectionDecoder *opus_projection_decoder_create(
  355. opus_int32 Fs,
  356. int channels,
  357. int streams,
  358. int coupled_streams,
  359. unsigned char *demixing_matrix,
  360. opus_int32 demixing_matrix_size,
  361. int *error
  362. ) OPUS_ARG_NONNULL(5);
  363. /** Intialize a previously allocated projection decoder state object.
  364. * The memory pointed to by \a st must be at least the size returned by
  365. * opus_projection_decoder_get_size().
  366. * This is intended for applications which use their own allocator instead of
  367. * malloc.
  368. * To reset a previously initialized state, use the #OPUS_RESET_STATE CTL.
  369. * @see opus_projection_decoder_create
  370. * @see opus_projection_deocder_get_size
  371. * @param st <tt>OpusProjectionDecoder*</tt>: Projection encoder state to initialize.
  372. * @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz).
  373. * This must be one of 8000, 12000, 16000,
  374. * 24000, or 48000.
  375. * @param channels <tt>int</tt>: Number of channels to output.
  376. * This must be at most 255.
  377. * It may be different from the number of coded
  378. * channels (<code>streams +
  379. * coupled_streams</code>).
  380. * @param streams <tt>int</tt>: The total number of streams coded in the
  381. * input.
  382. * This must be no more than 255.
  383. * @param coupled_streams <tt>int</tt>: Number of streams to decode as coupled
  384. * (2 channel) streams.
  385. * This must be no larger than the total
  386. * number of streams.
  387. * Additionally, The total number of
  388. * coded channels (<code>streams +
  389. * coupled_streams</code>) must be no
  390. * more than 255.
  391. * @param[in] demixing_matrix <tt>const unsigned char[demixing_matrix_size]</tt>: Demixing matrix
  392. * that mapping from coded channels to output channels,
  393. * as described in @ref opus_projection and
  394. * @ref opus_projection_ctls.
  395. * @param demixing_matrix_size <tt>opus_int32</tt>: The size in bytes of the
  396. * demixing matrix, as
  397. * described in @ref
  398. * opus_projection_ctls.
  399. * @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes)
  400. * on failure.
  401. */
  402. OPUS_EXPORT int opus_projection_decoder_init(
  403. OpusProjectionDecoder *st,
  404. opus_int32 Fs,
  405. int channels,
  406. int streams,
  407. int coupled_streams,
  408. unsigned char *demixing_matrix,
  409. opus_int32 demixing_matrix_size
  410. ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6);
  411. /** Decode a projection Opus packet.
  412. * @param st <tt>OpusProjectionDecoder*</tt>: Projection decoder state.
  413. * @param[in] data <tt>const unsigned char*</tt>: Input payload.
  414. * Use a <code>NULL</code>
  415. * pointer to indicate packet
  416. * loss.
  417. * @param len <tt>opus_int32</tt>: Number of bytes in payload.
  418. * @param[out] pcm <tt>opus_int16*</tt>: Output signal, with interleaved
  419. * samples.
  420. * This must contain room for
  421. * <code>frame_size*channels</code>
  422. * samples.
  423. * @param frame_size <tt>int</tt>: The number of samples per channel of
  424. * available space in \a pcm.
  425. * If this is less than the maximum packet duration
  426. * (120 ms; 5760 for 48kHz), this function will not be capable
  427. * of decoding some packets. In the case of PLC (data==NULL)
  428. * or FEC (decode_fec=1), then frame_size needs to be exactly
  429. * the duration of audio that is missing, otherwise the
  430. * decoder will not be in the optimal state to decode the
  431. * next incoming packet. For the PLC and FEC cases, frame_size
  432. * <b>must</b> be a multiple of 2.5 ms.
  433. * @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band
  434. * forward error correction data be decoded.
  435. * If no such data is available, the frame is
  436. * decoded as if it were lost.
  437. * @returns Number of samples decoded on success or a negative error code
  438. * (see @ref opus_errorcodes) on failure.
  439. */
  440. OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_decode(
  441. OpusProjectionDecoder *st,
  442. const unsigned char *data,
  443. opus_int32 len,
  444. opus_int16 *pcm,
  445. int frame_size,
  446. int decode_fec
  447. ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
  448. /** Decode a projection Opus packet with floating point output.
  449. * @param st <tt>OpusProjectionDecoder*</tt>: Projection decoder state.
  450. * @param[in] data <tt>const unsigned char*</tt>: Input payload.
  451. * Use a <code>NULL</code>
  452. * pointer to indicate packet
  453. * loss.
  454. * @param len <tt>opus_int32</tt>: Number of bytes in payload.
  455. * @param[out] pcm <tt>opus_int16*</tt>: Output signal, with interleaved
  456. * samples.
  457. * This must contain room for
  458. * <code>frame_size*channels</code>
  459. * samples.
  460. * @param frame_size <tt>int</tt>: The number of samples per channel of
  461. * available space in \a pcm.
  462. * If this is less than the maximum packet duration
  463. * (120 ms; 5760 for 48kHz), this function will not be capable
  464. * of decoding some packets. In the case of PLC (data==NULL)
  465. * or FEC (decode_fec=1), then frame_size needs to be exactly
  466. * the duration of audio that is missing, otherwise the
  467. * decoder will not be in the optimal state to decode the
  468. * next incoming packet. For the PLC and FEC cases, frame_size
  469. * <b>must</b> be a multiple of 2.5 ms.
  470. * @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band
  471. * forward error correction data be decoded.
  472. * If no such data is available, the frame is
  473. * decoded as if it were lost.
  474. * @returns Number of samples decoded on success or a negative error code
  475. * (see @ref opus_errorcodes) on failure.
  476. */
  477. OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_projection_decode_float(
  478. OpusProjectionDecoder *st,
  479. const unsigned char *data,
  480. opus_int32 len,
  481. float *pcm,
  482. int frame_size,
  483. int decode_fec
  484. ) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);
  485. /** Perform a CTL function on a projection Opus decoder.
  486. *
  487. * Generally the request and subsequent arguments are generated by a
  488. * convenience macro.
  489. * @param st <tt>OpusProjectionDecoder*</tt>: Projection decoder state.
  490. * @param request This and all remaining parameters should be replaced by one
  491. * of the convenience macros in @ref opus_genericctls,
  492. * @ref opus_decoderctls, @ref opus_multistream_ctls, or
  493. * @ref opus_projection_ctls.
  494. * @see opus_genericctls
  495. * @see opus_decoderctls
  496. * @see opus_multistream_ctls
  497. * @see opus_projection_ctls
  498. */
  499. OPUS_EXPORT int opus_projection_decoder_ctl(OpusProjectionDecoder *st, int request, ...) OPUS_ARG_NONNULL(1);
  500. /** Frees an <code>OpusProjectionDecoder</code> allocated by
  501. * opus_projection_decoder_create().
  502. * @param st <tt>OpusProjectionDecoder</tt>: Projection decoder state to be freed.
  503. */
  504. OPUS_EXPORT void opus_projection_decoder_destroy(OpusProjectionDecoder *st);
  505. /**@}*/
  506. /**@}*/
  507. #ifdef __cplusplus
  508. }
  509. #endif
  510. #endif /* OPUS_PROJECTION_H */