2
0

opus_encode_regressions.c 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035
  1. /* Copyright (c) 2016 Mark Harris, Jean-Marc Valin */
  2. /*
  3. Redistribution and use in source and binary forms, with or without
  4. modification, are permitted provided that the following conditions
  5. are met:
  6. - Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. - Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  12. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  13. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  14. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
  15. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  16. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  18. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  19. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  20. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  21. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. */
  23. #ifdef HAVE_CONFIG_H
  24. #include "config.h"
  25. #endif
  26. #include <stdio.h>
  27. #include <stdlib.h>
  28. #include <limits.h>
  29. #include <stdint.h>
  30. #include <math.h>
  31. #include <string.h>
  32. #include <assert.h>
  33. #include "opus_multistream.h"
  34. #include "opus.h"
  35. #include "test_opus_common.h"
  36. static int celt_ec_internal_error(void)
  37. {
  38. OpusMSEncoder *enc;
  39. int err;
  40. unsigned char data[2460];
  41. int streams;
  42. int coupled_streams;
  43. unsigned char mapping[1];
  44. enc = opus_multistream_surround_encoder_create(16000, 1, 1, &streams,
  45. &coupled_streams, mapping, OPUS_APPLICATION_VOIP, &err);
  46. opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC));
  47. opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(0));
  48. opus_multistream_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(0));
  49. opus_multistream_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(1));
  50. opus_multistream_encoder_ctl(enc, OPUS_SET_PHASE_INVERSION_DISABLED(0));
  51. opus_multistream_encoder_ctl(enc, OPUS_SET_DTX(0));
  52. opus_multistream_encoder_ctl(enc, OPUS_SET_COMPLEXITY(0));
  53. opus_multistream_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_NARROWBAND));
  54. opus_multistream_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_AUTO));
  55. opus_multistream_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(8));
  56. opus_multistream_encoder_ctl(enc, OPUS_SET_INBAND_FEC(0));
  57. opus_multistream_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(0));
  58. opus_multistream_encoder_ctl(enc, OPUS_SET_BITRATE(OPUS_AUTO));
  59. {
  60. static const short pcm[320] =
  61. {
  62. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  63. 0, 0, 0, 0, 0, 0, 1792, 1799, 1799,
  64. 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1799,
  65. 1799, 1799, 1799, 1799, 1799, 0, 25600, 1799, 1799,
  66. 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1799,
  67. 1799, 1799, 1799, 1799, 7, 0, 255, 0, 0,
  68. 0, 0, 0, 0, 0, 0, 0, 32767, -1,
  69. 0, 0, 0, 100, 0, 16384, 0, 0, 0,
  70. 0, 0, 0, 4, 0, 0, -256, 255, 0,
  71. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  72. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  73. 0, 0,-32768, 0, 0, 0, 0, 0, 0,
  74. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  75. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  76. 0, 0, 0, 0, 128, 0, 0, 0, 0,
  77. 0, 0, 0, 0, -256, 0, 0, 32, 0,
  78. 0, 0, 0, 0, 0, 0, 4352, 4, 228,
  79. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  80. 0, 0, 0, 0, 0, 0, 5632, 0, 0,
  81. 0, 0,-32768, 0, 0, 0, 0, 0, 0,
  82. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  83. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  84. 0, 0, 0, 256, 0, 0, 0, 0, 0,
  85. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  86. -3944, 10500, 4285, 10459, -6474, 10204, -6539, 11601, -6824,
  87. 13385, -7142, 13872,-11553, 13670, -7725, 13463, -6887, 7874,
  88. -5580, 12600, -4964, 12480, 3254, 11741, -4210, 9741, -3155,
  89. 7558, -5468, 5431, -1073, 3641, -1304, 0, -1, 343,
  90. 26, 0, 0, 150, 0, 0, 0, 0, 0,
  91. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  92. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  93. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  94. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  95. 0, 0, 0, 1799, 1799, 1799, 1799, 1799, -2553,
  96. 7, 1792, 1799, 1799, 1799, 1799, 1799, 1799, 1799,
  97. 1799, 1799, 1799, 1799, -9721
  98. };
  99. err = opus_multistream_encode(enc, pcm, 320, data, 2460);
  100. assert(err > 0);
  101. }
  102. opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC));
  103. opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(0));
  104. opus_multistream_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(1));
  105. opus_multistream_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(1));
  106. opus_multistream_encoder_ctl(enc, OPUS_SET_PHASE_INVERSION_DISABLED(0));
  107. opus_multistream_encoder_ctl(enc, OPUS_SET_DTX(1));
  108. opus_multistream_encoder_ctl(enc, OPUS_SET_COMPLEXITY(10));
  109. opus_multistream_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND));
  110. opus_multistream_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND));
  111. opus_multistream_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(18));
  112. opus_multistream_encoder_ctl(enc, OPUS_SET_INBAND_FEC(1));
  113. opus_multistream_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(90));
  114. opus_multistream_encoder_ctl(enc, OPUS_SET_BITRATE(280130));
  115. {
  116. static const short pcm[160] =
  117. {
  118. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  119. -9510, -9510, -9510, -9510, -9510, -9510, -9526, -9510, -9510,
  120. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  121. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  122. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  123. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  124. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  125. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  126. -9510, -9510, -9510, -9510, -9510, 25600, -9510, -9510, -9510,
  127. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  128. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  129. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  130. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  131. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  132. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  133. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  134. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  135. -9510, -9510, -9510, -9510, -9510, -9510, -9510
  136. };
  137. err = opus_multistream_encode(enc, pcm, 160, data, 2460);
  138. assert(err > 0);
  139. }
  140. opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC));
  141. opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(0));
  142. opus_multistream_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(1));
  143. opus_multistream_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(1));
  144. opus_multistream_encoder_ctl(enc, OPUS_SET_PHASE_INVERSION_DISABLED(0));
  145. opus_multistream_encoder_ctl(enc, OPUS_SET_DTX(1));
  146. opus_multistream_encoder_ctl(enc, OPUS_SET_COMPLEXITY(10));
  147. opus_multistream_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND));
  148. opus_multistream_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND));
  149. opus_multistream_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(18));
  150. opus_multistream_encoder_ctl(enc, OPUS_SET_INBAND_FEC(1));
  151. opus_multistream_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(90));
  152. opus_multistream_encoder_ctl(enc, OPUS_SET_BITRATE(280130));
  153. {
  154. static const short pcm[160] =
  155. {
  156. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  157. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  158. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  159. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  160. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  161. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  162. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  163. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  164. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  165. -9510, -9494, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  166. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  167. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  168. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  169. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  170. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  171. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  172. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  173. -9510, -9510, -9510, -9510, -9510, -9510, -9510
  174. };
  175. err = opus_multistream_encode(enc, pcm, 160, data, 2460);
  176. assert(err > 0);
  177. }
  178. opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC));
  179. opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(0));
  180. opus_multistream_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(1));
  181. opus_multistream_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(1));
  182. opus_multistream_encoder_ctl(enc, OPUS_SET_PHASE_INVERSION_DISABLED(0));
  183. opus_multistream_encoder_ctl(enc, OPUS_SET_DTX(1));
  184. opus_multistream_encoder_ctl(enc, OPUS_SET_COMPLEXITY(10));
  185. opus_multistream_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND));
  186. opus_multistream_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND));
  187. opus_multistream_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(18));
  188. opus_multistream_encoder_ctl(enc, OPUS_SET_INBAND_FEC(1));
  189. opus_multistream_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(90));
  190. opus_multistream_encoder_ctl(enc, OPUS_SET_BITRATE(280130));
  191. {
  192. static const short pcm[160] =
  193. {
  194. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  195. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  196. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  197. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  198. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  199. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  200. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  201. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  202. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  203. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  204. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  205. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  206. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  207. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  208. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9479, -9510,
  209. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  210. -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510, -9510,
  211. -9510, -9510, -9510, -9510, -9510, -9510, -9510
  212. };
  213. err = opus_multistream_encode(enc, pcm, 160, data, 2460);
  214. assert(err > 0);
  215. }
  216. opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC));
  217. opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(0));
  218. opus_multistream_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(1));
  219. opus_multistream_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(1));
  220. opus_multistream_encoder_ctl(enc, OPUS_SET_PHASE_INVERSION_DISABLED(0));
  221. opus_multistream_encoder_ctl(enc, OPUS_SET_DTX(1));
  222. opus_multistream_encoder_ctl(enc, OPUS_SET_COMPLEXITY(10));
  223. opus_multistream_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND));
  224. opus_multistream_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND));
  225. opus_multistream_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(18));
  226. opus_multistream_encoder_ctl(enc, OPUS_SET_INBAND_FEC(1));
  227. opus_multistream_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(90));
  228. opus_multistream_encoder_ctl(enc, OPUS_SET_BITRATE(280130));
  229. {
  230. static const short pcm[160] =
  231. {
  232. -9510, -9510, 1799, 1799, 1799, 1799, 1799, 1799, 1799,
  233. 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1799, 0,
  234. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  235. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  236. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  237. -256, 255, 0, 0, 0, 0, 0, 0, 0,
  238. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  239. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  240. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  241. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  242. 0, 0, 0, 0, 0, 0, 0, 128, 0,
  243. 0, 0, 0, 0, 0, 0, 0, 0, 0,
  244. 0, 32, 0, 0, 0, 0, 0, 0, 0,
  245. 4352, 4, 0, 0, 0, 0, 0, 0, 0,
  246. 0, 0, 0, 0, 148, 0, 0, 0, 0,
  247. 5632
  248. };
  249. err = opus_multistream_encode(enc, pcm, 160, data, 2460);
  250. assert(err > 0);
  251. }
  252. opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE));
  253. opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(0));
  254. opus_multistream_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(1));
  255. opus_multistream_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(1));
  256. opus_multistream_encoder_ctl(enc, OPUS_SET_PHASE_INVERSION_DISABLED(1));
  257. opus_multistream_encoder_ctl(enc, OPUS_SET_DTX(1));
  258. opus_multistream_encoder_ctl(enc, OPUS_SET_COMPLEXITY(0));
  259. opus_multistream_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_NARROWBAND));
  260. opus_multistream_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_AUTO));
  261. opus_multistream_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(12));
  262. opus_multistream_encoder_ctl(enc, OPUS_SET_INBAND_FEC(0));
  263. opus_multistream_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(41));
  264. opus_multistream_encoder_ctl(enc, OPUS_SET_BITRATE(21425));
  265. {
  266. static const short pcm[40] =
  267. {
  268. 10459, -6474, 10204, -6539, 11601, -6824, 13385, -7142, 13872,
  269. -11553, 13670, -7725, 13463, -6887, 12482, -5580, 12600, -4964,
  270. 12480, 3254, 11741, -4210, 9741, -3155, 7558, -5468, 5431,
  271. -1073, 3641, -1304, 0, -1, 343, 26, 0, 0,
  272. 0, 0, -256, 226
  273. };
  274. err = opus_multistream_encode(enc, pcm, 40, data, 2460);
  275. assert(err > 0);
  276. /* returns -3 */
  277. }
  278. opus_multistream_encoder_destroy(enc);
  279. return 0;
  280. }
  281. static int mscbr_encode_fail10(void)
  282. {
  283. OpusMSEncoder *enc;
  284. int err;
  285. unsigned char data[627300];
  286. static const unsigned char mapping[255] =
  287. {
  288. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
  289. 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
  290. 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
  291. 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
  292. 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
  293. 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101,
  294. 102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,
  295. 119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,
  296. 136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,
  297. 153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,
  298. 170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,
  299. 187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,
  300. 204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,
  301. 221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,
  302. 238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254
  303. };
  304. enc = opus_multistream_encoder_create(8000, 255, 254, 1, mapping,
  305. OPUS_APPLICATION_RESTRICTED_LOWDELAY, &err);
  306. opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE));
  307. opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(0));
  308. opus_multistream_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(0));
  309. opus_multistream_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(0));
  310. opus_multistream_encoder_ctl(enc, OPUS_SET_FORCE_CHANNELS(2));
  311. opus_multistream_encoder_ctl(enc, OPUS_SET_PHASE_INVERSION_DISABLED(1));
  312. opus_multistream_encoder_ctl(enc, OPUS_SET_DTX(1));
  313. opus_multistream_encoder_ctl(enc, OPUS_SET_COMPLEXITY(2));
  314. opus_multistream_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_NARROWBAND));
  315. opus_multistream_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_AUTO));
  316. opus_multistream_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(14));
  317. opus_multistream_encoder_ctl(enc, OPUS_SET_INBAND_FEC(0));
  318. opus_multistream_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(57));
  319. opus_multistream_encoder_ctl(enc, OPUS_SET_BITRATE(3642675));
  320. {
  321. static const short pcm[20*255] =
  322. {
  323. 0
  324. };
  325. err = opus_multistream_encode(enc, pcm, 20, data, 627300);
  326. assert(err > 0);
  327. /* returns -1 */
  328. }
  329. opus_multistream_encoder_destroy(enc);
  330. return 0;
  331. }
  332. static int mscbr_encode_fail(void)
  333. {
  334. OpusMSEncoder *enc;
  335. int err;
  336. unsigned char data[472320];
  337. static const unsigned char mapping[192] =
  338. {
  339. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
  340. 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
  341. 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
  342. 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
  343. 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
  344. 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101,
  345. 102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,
  346. 119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,
  347. 136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,
  348. 153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,
  349. 170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,
  350. 187,188,189,190,191
  351. };
  352. enc = opus_multistream_encoder_create(8000, 192, 189, 3, mapping,
  353. OPUS_APPLICATION_RESTRICTED_LOWDELAY, &err);
  354. opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC));
  355. opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(0));
  356. opus_multistream_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(0));
  357. opus_multistream_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(0));
  358. opus_multistream_encoder_ctl(enc, OPUS_SET_FORCE_CHANNELS(OPUS_AUTO));
  359. opus_multistream_encoder_ctl(enc, OPUS_SET_PHASE_INVERSION_DISABLED(0));
  360. opus_multistream_encoder_ctl(enc, OPUS_SET_DTX(0));
  361. opus_multistream_encoder_ctl(enc, OPUS_SET_COMPLEXITY(0));
  362. opus_multistream_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_MEDIUMBAND));
  363. opus_multistream_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_AUTO));
  364. opus_multistream_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(8));
  365. opus_multistream_encoder_ctl(enc, OPUS_SET_INBAND_FEC(0));
  366. opus_multistream_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(0));
  367. opus_multistream_encoder_ctl(enc, OPUS_SET_BITRATE(15360));
  368. {
  369. static const short pcm[20*192] =
  370. {
  371. 0
  372. };
  373. err = opus_multistream_encode(enc, pcm, 20, data, 472320);
  374. assert(err > 0);
  375. /* returns -1 */
  376. }
  377. opus_multistream_encoder_destroy(enc);
  378. return 0;
  379. }
  380. static int surround_analysis_uninit(void)
  381. {
  382. OpusMSEncoder *enc;
  383. int err;
  384. unsigned char data[7380];
  385. int streams;
  386. int coupled_streams;
  387. unsigned char mapping[3];
  388. enc = opus_multistream_surround_encoder_create(24000, 3, 1, &streams,
  389. &coupled_streams, mapping, OPUS_APPLICATION_AUDIO, &err);
  390. opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE));
  391. opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(1));
  392. opus_multistream_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(1));
  393. opus_multistream_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(0));
  394. opus_multistream_encoder_ctl(enc, OPUS_SET_FORCE_CHANNELS(OPUS_AUTO));
  395. opus_multistream_encoder_ctl(enc, OPUS_SET_PHASE_INVERSION_DISABLED(0));
  396. opus_multistream_encoder_ctl(enc, OPUS_SET_DTX(0));
  397. opus_multistream_encoder_ctl(enc, OPUS_SET_COMPLEXITY(0));
  398. opus_multistream_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_NARROWBAND));
  399. opus_multistream_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_NARROWBAND));
  400. opus_multistream_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(8));
  401. opus_multistream_encoder_ctl(enc, OPUS_SET_INBAND_FEC(1));
  402. opus_multistream_encoder_ctl(enc, OPUS_SET_BITRATE(84315));
  403. {
  404. static const short pcm[960*3] =
  405. {
  406. -6896, 4901, -6158, 4120, -5164, 3631, -4442, 3153, -4070,
  407. 3349, -4577, 4474, -5541, 5058, -6701, 3881, -7933, 1863,
  408. -8041, 697, -6738,-31464, 14330,-12523, 4096, -6130, 29178,
  409. -250,-21252, 10467, 16907, -3359, -6644, 31965, 14607,-21544,
  410. -32497, 24020, 12557,-26926,-18421, -1842, 24587, 19659, 4878,
  411. 10954, 23060, 8907,-10215,-16179, 31772,-11825,-15590,-23089,
  412. 17173,-25903,-17387, 11733, 4884, 10204,-16476,-14367, 516,
  413. 20453,-16898, 20967,-23813, -20, 22011,-17167, 9459, 32499,
  414. -25855, -523, -3883, -390, -4206, 634, -3767, 2325, -2751,
  415. 3115, -2392, 2746, -2173, 2317, -1147, 2326, 23142, 11314,
  416. -15350,-24529, 3026, 6146, 2150, 2476, 1105, -830, 1775,
  417. -3425, 3674,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  418. 4293,-14023, 3879,-15553, 3158,-16161, 2629, 18433,-12535,
  419. -6645,-20735,-32763,-13824,-20992, 25859, 13052, -8731, 2292,
  420. -3860, 24049, 10225,-19220, 10478,-22294, 22773, 28137, 13816,
  421. 30953,-25863,-24598, 16888,-14612,-28942, 20974,-27397,-18944,
  422. -18690, 20991,-16638, 5632,-14330, 28911,-25594, 17408, 29958,
  423. -517,-20984, -1800, 11281, 9977,-21221,-14854, 23840, -9477,
  424. 3362,-12805,-22493, 32507, 156, 16384, -1163, 2301, -1874,
  425. 4600, -1748, 6950, 16557, 8192, -7372, -1033, -3278, 2806,
  426. 20275, 3317, -717, 9792, -767, 9099, -613, 8362, 5027,
  427. 7774, 2597, 8549, 5278, 8743, 9343, 6940, 13038, 4826,
  428. 14086, 2964, 13215, 1355, 11596, 455, 9850, -519, 10680,
  429. -2287, 12551, -3736, 13639, -4291, 13790, -2722, 14544, -866,
  430. 15050, -304, 22833, -1196, 13520, -2063, 13051, -2317, 13066,
  431. -2737, 13773, -2664, 14105, -3447, 13854, 24589, 24672, -5280,
  432. 10388, -4933, 7543, -4149, 3654, -1552, 1726, 661, 57,
  433. 2922, -751, 3917, 8419, 3840, -5218, 3435, 5540, -1073,
  434. 4153, -6656, 1649, -769, -7276,-13072, 6380, -7948, 20717,
  435. 18425, 17392, 14335,-18190, -1842, 24587, 19659, 11790, 10954,
  436. 23060, 8907,-10215,-16179, 31772,-11825,-15590,-23101, 17173,
  437. -25903,-17387, 11733, 4884, 10192,-16627,-14367, 516, 20453,
  438. -16898, 20967,-23813, -20, 22011,-17167, 9468, 32499,-25607,
  439. -523, -3883, -390, -4206, 634, -3767, 2325, -2751, 3115,
  440. -2392, 2746, -2161, 2317, -1147, 2326, 23142, 11314,-15350,
  441. -29137, 3026,-15056, -491,-15170, -386,-16015, -641,-16505,
  442. -930,-16206, -717,-16175, -2839,-16374, -4558,-16237, -5207,
  443. -15903, -6421, 6373, -1403, 5431, -1073, 3641, -1304, -4495,
  444. -769, -7276, 2856, -7870, 3314, -8730, 3964,-10183, 4011,
  445. -11135, 3421,-11727, 2966,-12360, 2818,-13472, 3660,-13805,
  446. 5162,-13478, 6434,-12840, 7335,-12420, 6865,-12349, 5541,
  447. -11965, 5530,-10820, 5132, -9197, 3367, -7745, 1223, -6910,
  448. -433, -6211, -1711, -4958, -1025, -3755, -836, -3292, -1666,
  449. -2661,-10755, 31472,-27906, 31471, 18690, 5617, 16649, 11253,
  450. -22516,-17674,-31990, 3575,-31479, 5883, 26121, 12890, -6612,
  451. 12228,-11634, 523, 26136,-21496, 20745,-15868, -4100,-24826,
  452. 23282, 22798, 491, -1774, 15075,-27373,-13094, 6417,-29487,
  453. 14608, 10185, 16143, 22211, -8436, 4288, -8694, 2375, 3023,
  454. 486, 1455, 128, 202, 942, -923, 2068, -1233, -717,
  455. -1042, -2167, 32255, -4632, 310, -4458, -3639, -5258, 2106,
  456. -6857, 2681, -7497, 2765, -6601, 1945, -5219, 19154, -4877,
  457. 619, -5719, -1928, -6208, -121, 593, 188, 1558, -4152,
  458. 1648, 156, 1604, -3664, -6862, -2851, -5112, -3600, -3747,
  459. -5081, -4428, -5592, 20974,-27397,-18944,-18690, 20991,-17406,
  460. 5632,-14330, 28911, 15934, 15934, 15934, 15934, 15934, 15934,
  461. 15934, 15934, 15934, 15934, 15934, 15934,-25594, 17408, 29958,
  462. -7173,-16888, 9098, -613, 8362, 675, 7774, 2597, 8549,
  463. 5278, 8743, 9375, 6940, 13038, 4826, 14598, 7721,-24308,
  464. -29905,-19703,-17106,-16124, -3287,-26118,-19709,-10769, 24353,
  465. 28648, 6946, -1363, 12485, -1187, 26074,-25055, 10004,-24798,
  466. 7204, -4581, -9678, 1554, 10553, 3102, 12193, 2443, 11955,
  467. 1213, 10689, -1293, 921, -4173, 10709, -6049, 8815, -7128,
  468. 8147, -8308, 6847, -2977, 4920,-11447,-22426,-11794, 3514,
  469. -10220, 3430, -7993, 1926, -7072, 327, -7569, -608, -7605,
  470. 3695, -6271, -1579, -4877, -1419, -3103, -2197, 128, -3904,
  471. 3760, -5401, 4906, -6051, 4250, -6272, 3492, -6343, 3197,
  472. -6397, 4041, -6341, 6255, -6381, 7905, 16504, 0, -6144,
  473. 8062, -5606, 8622, -5555, -9, -1, 7423, 0, 1,
  474. 238, 5148, 1309, 4700, 2218, 4403, 2573, 3568, 28303,
  475. 1758, 3454, -1247, 3434, -4912, 2862, -7844, 1718,-10095,
  476. 369,-12631, 128, -3904, 3632, -5401, 4906, -6051, 4250,
  477. -6272, 3492, -6343, 3197, -6397, 4041, -6341, 6255, -6381,
  478. 7905, 16504, 0, -6144, 8062, -5606, 8622, -5555, 8439,
  479. -3382, 7398, -1170, 6132, 238, 5148, 1309, 4700, 2218,
  480. 4403, 2573, 3568, 2703, 1758, 3454, -1247, 3434, -4912,
  481. 2862, -7844, 1718,-10095, 369,-12631, -259,-14632, 234,
  482. -15056, -521,-15170, -386,-16015, -641,-16505, -930,-16206,
  483. -1209,-16146, -2839,-16374, -4558,-16218, -5207,-15903, -6421,
  484. -15615, -6925,-14871, -6149,-13759, -5233,-12844, 18313, -4357,
  485. -5696, 2804, 12992,-22802, -6720, -9770, -7088, -8998, 14330,
  486. -12523, 14843, -6130, 29178, -250,-27396, 10467, 16907, -3359,
  487. -6644, 31965, 14607,-21544,-32497, 24020, 12557,-26926, -173,
  488. -129, -6401, -130,-25089, -3841, -4916, -3048, 224, -237,
  489. -3969, -189, -3529, -535, -3464,-14863,-14907,-14907,-14907,
  490. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  491. -14907,-14395,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  492. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  493. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  494. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  495. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  496. -14907,-14907, 0, 32512,-14907,-14907,-14907,-14907,-14907,
  497. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  498. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  499. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  500. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  501. -14907,-14907,-14907,-14907,-14907, 9925, -718, 9753, -767,
  502. 9099, -613, 8362, 675, 7774, 2597, 8549, 5278, 8743,
  503. 9375, 6940, 13038, 4826, 14598, 7721,-24308,-29905,-19703,
  504. -17106,-16124, -3287,-26118,-19709, 0, 24353, 28648, 10274,
  505. -11292,-29665,-16417, 24346, 14553, 18707, 26323, -4596,-17711,
  506. 5133, 26328, 13,-31168, 24583, 18404,-28927,-24350, 19453,
  507. 28642, 1019,-10777, -3079, 30188, -7686, 27635,-32521,-16384,
  508. 12528, -6386, 10986, 23827,-25880,-32752,-23321, 14605, 32231,
  509. 780,-13849, 15119, 28647, 4888, -7705, 30750, 64, 0,
  510. 32488, 6687,-20758, 19745, -2070,-13792, -6414, 28188, -2821,
  511. -4585, 7168, 7444, 23557,-21998, 13064, 3345, -4086,-28915,
  512. -8694, 32262, 8461, 27387,-12275, 12012, 23563,-18719,-28410,
  513. 29144,-22271, -562, -9986, -5434, 12288, 5573,-16642, 32448,
  514. 29182, 32705,-30723, 24255,-19716, 18368, -4357, -5696, 2804,
  515. 12992,-22802,-22080, -7701, -5183, 486, -3133, -5660, -1083,
  516. 16871,-28726,-11029,-30259, -1209,-16146, -2839,-16374, -4558,
  517. -16218,-10523, 20697, -9500, -1316, 5431, -1073, 3641, -1304,
  518. 1649, -769, -7276, 2856, -7870, 3314, -8730, 3964,-10183,
  519. 4011,-11135, 3421,-11727, 21398, 32767, -1, 32486, -1,
  520. 6301,-13071, 6380, -7948, -1, 32767, 240, 14081, -5646,
  521. 30973, -3598,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  522. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  523. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  524. -14907,-14907,-14907,-14907, 32767,-14907,-14907,-14907,-14907,
  525. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  526. -14907, 8901, 9375, 6940, 13038, 4826, 14598, 7721,-24308,
  527. -29905,-19703,-17106,-16124, -3287,-26118,-19709,-10769, 24361,
  528. 28648, 10274,-11292,-29665,-16417, 24346, 14580, 18707, 26323,
  529. -4440,-17711, 5133, 26328,-14579,-31008, 24583, 18404, 28417,
  530. -24350, 19453, 28642,-32513,-10777, -3079, 30188, -7686, 27635,
  531. -32521,-16384,-20240, -6386, 10986, 23827,-25880,-32752,-23321,
  532. 14605, 32231, 780,-13849, 15119, 28647, 4888, -7705,-15074,
  533. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  534. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  535. -14907,-14907,-14907, 8192,-14907,-14907,-14907,-14907,-14907,
  536. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  537. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  538. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  539. -14907,-14907,-14907,-14897,-14907,-14907,-14907,-14907,-14907,
  540. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  541. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  542. -15931,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  543. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  544. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  545. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  546. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  547. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  548. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  549. -14907,-14907,-14907,-14907,-14907,-14907, 26121, 12890, 2604,
  550. 12228,-11634, 12299, 5573,-16642, 32452, 29182, 32705,-30723,
  551. 24255,-19716, 13248,-11779, -5696, 2804, 12992,-27666,-22080,
  552. -7701, -5183, -6682,-31464, 14330,-12523, 14843, -6130, 29178,
  553. -18,-27396, 10467, 16907, -3359, -6644, 31965, 14607,-21544,
  554. -32497, 24020, 12557,-26926,-18421, 706, 24587, 19659, 4878,
  555. 10954, 23060, 8907,-10215,-22579, 31772,-11825,-15590,-23089,
  556. 17173,-25903,-17387, 3285, 4884, 10204,-16627,-14367, 516,
  557. 20453,-16898, 20967,-23815, -20, 22011,-17167, 9468, 32499,
  558. -25607, -523, -3883, -390, -4206, 634, -3767, 2325, -2751,
  559. 3115, -2392, 2746, -2173, 2317, -1147, 2326, 23142, 11314,
  560. -15130,-29137, 3026, 6146, 2150, 2476, 1105, -830, 1775,
  561. -3425, 3674, -5287, 4609, -7175, 4922, -9579, 4556,-12007,
  562. 4236,-14023, 3879,-15553, 3158,-16161, 2576, 18398,-12535,
  563. -6645,-20735,-32763,-13824,-20992, 25859, 5372, 12040, 13307,
  564. -4355,-30213, -9, -6019, 14061,-31487,-13842, 30449, 15083,
  565. 14088, 31205,-18678,-12830, 14090,-26138,-25337,-11541, -3254,
  566. 27628,-22270, 30953,-16136,-30745, 20991,-17406, 5632,-14330,
  567. 28911,-25594, 17408,-20474, 13041, -8731, 2292, -3860, 24049,
  568. 10225,-19220, 10478, -4374, -1199, 148, -330, -74, 593,
  569. 188, 1558, -4152, 15984, 15934, 15934, 15934, 15934, 15934,
  570. 15934, 15934, 15934, 15934, 15934, 15934, 1598, 156, 1604,
  571. -1163, 2278,-30018,-25821,-21763,-23776, 24066, 9502, 25866,
  572. -25055, 10004,-24798, 7204, -4581, -9678, 1554, 10553, 3102,
  573. 12193, 2443, 11955, 1213, 10689, -1293, 921, -4173, 8661,
  574. -6049, 8815,-21221,-14854, 23840, -9477, 8549, 5278, 8743,
  575. 9375, 6940, 13038, 4826, 14598, 7721,-24308,-29905,-19703,
  576. -17106,-16124, -3287,-26118,-19709,-10769, 24361, 28648, 10274,
  577. -11292,-29665,-16417, 24346, 14580, 18707, 26323, -4410,-17711,
  578. 5133, 26328,-14579,-31008, 24583, 18404, 28417,-24350, 19453,
  579. 28642,-32513,-10777, -3079, 30188, -7686, 27635,-32521,-16384,
  580. -20240, -6386, 10986, 23827,-25880,-32752,-23321, 14605, 32231,
  581. 780,-13849, 15119, 28647, 4888, -7705, 30750, 64, 0,
  582. 32488, 6687,-20758, 19745, -2070, -1, -1, 28, 256,
  583. -4608, 7168, 7444, 23557,-21998, 13064, 3345, -4086,-28915,
  584. -8594, 32262, 8461, 27387,-12275, 12012, 23563,-18719,-28410,
  585. 29144,-22271,-32562,-16384, 12528, -6386, 10986, 23827,-25880,
  586. -32752,-23321, 14605, 32231, 780,-13849, 15119, 28647, 4888,
  587. -7705, 30750, 64, 0, 32488, 6687,-20758, 19745, -2070,
  588. -13792, -6414, 28188, -2821, -4585, 7168, 7444, 23557,-21998,
  589. 13064, 3345, -4086,-28915, -8694, 32262, 8461, 27387,-12275,
  590. 12012, 23563,-18719,-28410, 29144,-22271, -562, -9986, -5434,
  591. 12288, -2107,-16643, 32452, 29182, 32705,-30723, 24255,-19716,
  592. 18368, -4357, -5696, 2804, 12992,-22802,-22080, -7701, -5183,
  593. 486, -3133, -5660, -1083, 16871,-28726,-11029,-30259, -1209,
  594. -16146, -2839,-16374, -4558,-16218,-10523, 20697, -9500, -1316,
  595. 5431, -1073, 3641, -1304, 1649, -769, -7276, 2856, -7870,
  596. 3314, -8730, 3964,-10183, 4011,-11135, 3421,-11727, 21398,
  597. 32767, -1, 32486, -1, -99,-13072, 6380, -7948, 4864,
  598. 32767, 17392, 14335, -5646, 30973, -3598,-10299,-14907,-14907,
  599. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  600. -14907,-14907,-14905,-14907,-14907,-14907,-14907,-14907,-14907,
  601. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  602. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  603. -14907,-14907,-14907,-14907,-14907,-19771,-14907,-14907,-14907,
  604. -14907,-14907,-14907,-14907,-14907,-16443,-14907,-14907,-14907,
  605. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  606. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  607. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  608. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  609. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  610. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  611. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  612. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  613. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  614. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  615. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  616. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  617. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  618. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  619. -14907,-14907,-14907,-14907,-15931,-14907,-14907,-14907,-14907,
  620. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  621. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  622. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  623. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  624. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  625. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  626. -14907,-14907,-14907,-14907,-14907,-14907, -1,-14907,-14907,
  627. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  628. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  629. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  630. -14907,-14907, 7877, 7710, 7710, 7710, 7710, 7710, 7710,
  631. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  632. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  633. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  634. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  635. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  636. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  637. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  638. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  639. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  640. 7710, 7710, 7710, 7710, 7710, -994, -7276, 2856, -7870,
  641. 3314, -8730, 3964,-10183, 4011,-11135, 3421,-11727, 21398,
  642. 32767, -1, 32486, -1, -99,-13072, 6380, -7948, 4864,
  643. 32767, 17392, 14335, -5646, 30973, -3598,-14907,-14907,-14907,
  644. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  645. -14907,-14907,-14905,-14907,-14907,-14907,-14907,-14907,-14907,
  646. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  647. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  648. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  649. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  650. -14907,-14907, 197, 0,-14977,-14907,-14907,-14907,-14907,
  651. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  652. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  653. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  654. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  655. -14907,-14907,-14907,-14907,-14907,-14907, 12838, 6653, 294,
  656. -29699,-25821,-21763,-23776, 24066, 9502, 25866,-25055, 10004,
  657. -24798, 7204, -4581, -9678, 1554, 10553, 3102, 12193, 2443,
  658. 11955, 1213, 10689, -1293, 921, 179, 8448, -6049, 8815,
  659. -7128, 8147, -8308, 6847, -9889, 4920,-11447, 3174,-11794,
  660. 3514,-10220, 3430, 16384, 1926, -7072, 327, -7537, -608,
  661. -7605, -1169, -6397, -1579, -4877, -1419, -3103, -2197, 128,
  662. -3904, 3632, -5401, 4906, -6051, 4250, -6272, 3492, -6343,
  663. 3197, -6397, 4041, -6341, 6255, -6381, 7905, 16504, 0,
  664. -6144, 8062, -5606, 8622, -5555, 8439, -3382, 7398, -1170,
  665. 6132, 238, 5148, 1309, 4700, 2218, 4403, 2573, 3568,
  666. 2703, 1758, 3454, -1247, 3434, -4912, 2862, -7844, 1718,
  667. -10095, 369,-12631, -259,-14632, 234,-15056, -491,-16194,
  668. -386,-16015, -641,-16505, -930,-16206, -1209,-16146, -2839,
  669. -16374, -4558,-16218, -5207,-15903, -6421,-15615, -6925,-14871,
  670. -6149,-13759, -5233,-12844, 18313, -4357, -5696, 2804, 12992,
  671. -22802, -6720, -9770, -7088, -8998, 14330,-12523, 14843, -6130,
  672. 29178, -250,-27396, 10467, 16907, -3359, -6644, 31965, 14607,
  673. -21544,-32497, 24020, 12557,-26926, -173, -129, -6401, -130,
  674. -25089, -3816, -4916, -3048, -32, -1, -3969, 256, -3529,
  675. -535, -3464,-14863,-14907,-14907,-14907,-14907,-14907,-14907,
  676. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  677. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  678. -1209,-16146, -2839,-16374, -4558,-16218,-10523, 20697, -9500,
  679. -1316, 5431, -1073, 3641, -1304, 1649, -769, -7276, 2856,
  680. -7870, 3314, -8730, 3964,-10183, 4011,-11135, 3421,-11727,
  681. 21398, 32767, -1, 32486, -1, 6301,-13071, 6380, -7948,
  682. -1, 32767, 240, 14081, -5646, 30973, -3598,-14907,-14907,
  683. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  684. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  685. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  686. 32767,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  687. -14907,-14907,-14907,-14907,-14907,-14907, 8901, 9375, 6940,
  688. 13038, 4826, 14598, 7721,-24308,-29905,-19703,-17106,-16124,
  689. -3287,-26118,-19709,-10769, 24361, 28648, 10274,-11292,-29665,
  690. -16417, 24346, 14580, 18707, 26323, -4440,-17711, 5133, 26328,
  691. -14579,-31008, 24583, 18404, 28417,-24350, 19453, 28642,-32513,
  692. -10777, -3079, 30188, -7686, 27635,-32521,-16384,-20240, -6386,
  693. 10986, 23827,-25880,-32752,-23321, 14605, 32231, 780,-13849,
  694. 15119, 28647, 4888, -7705,-15074,-14907,-14907,-14907,-14907,
  695. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  696. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907, 8192,
  697. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  698. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  699. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  700. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14897,
  701. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  702. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  703. -14907,-14907,-14907,-14907,-14907,-15931,-14907,-14907,-14907,
  704. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  705. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  706. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  707. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  708. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  709. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  710. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  711. -14907,-14907, 26121, 12890, 2604, 12228,-11634, 12299, 5573,
  712. -16642, 32452, 29182, 32705,-30723, 24255,-19716, 13248,-11779,
  713. -5696, 2804, 12992,-27666,-22080, -7701, -5183, -6682,-31464,
  714. 14330,-12523, 14843, -6130, 29178, -18,-27396, 10467, 16907,
  715. -3359, -6644, 31965, 14607,-21544,-32497, 24020, 12557,-26926,
  716. -18421, 706, 24587, 19659, 4878, 10954, 23060, 8907,-10215,
  717. -22579, 31772,-11825,-15590,-23089, 17173,-25903,-17387, 3285,
  718. 4884, 10204,-16627,-14367, 516, 20453,-16898, 20967,-23815,
  719. -20, 22011,-17167, 9468, 32499,-25607, -523, -3883, -390,
  720. -4206, 634, -3767, 2325, -2751, 3115, -2392, 2746, -2173,
  721. 2317, -1147, 2326, 23142, 11314,-15130,-29137, 3026, 6146,
  722. 2150, 2476, 1105, -830, 1775, -3425, 3674, -5287, 4609,
  723. -7175, 4922, -9579, 4556,-12007, 4236,-14023, 3879,-15553,
  724. 3158,-16161, 2576, 18398,-12535, -6645,-20735,-32763,-13824,
  725. -20992, 25859, 5372, 12040, 13307, -4355,-30213, -9, -6019
  726. };
  727. err = opus_multistream_encode(enc, pcm, 960, data, 7380);
  728. assert(err > 0);
  729. }
  730. opus_multistream_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC));
  731. opus_multistream_encoder_ctl(enc, OPUS_SET_VBR(1));
  732. opus_multistream_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(0));
  733. opus_multistream_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(1));
  734. opus_multistream_encoder_ctl(enc, OPUS_SET_FORCE_CHANNELS(OPUS_AUTO));
  735. opus_multistream_encoder_ctl(enc, OPUS_SET_PHASE_INVERSION_DISABLED(1));
  736. opus_multistream_encoder_ctl(enc, OPUS_SET_DTX(1));
  737. opus_multistream_encoder_ctl(enc, OPUS_SET_COMPLEXITY(6));
  738. opus_multistream_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_NARROWBAND));
  739. opus_multistream_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_AUTO));
  740. opus_multistream_encoder_ctl(enc, OPUS_SET_LSB_DEPTH(9));
  741. opus_multistream_encoder_ctl(enc, OPUS_SET_INBAND_FEC(1));
  742. opus_multistream_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(5));
  743. opus_multistream_encoder_ctl(enc, OPUS_SET_BITRATE(775410));
  744. {
  745. static const short pcm[1440*3] =
  746. {
  747. 30449, 15083, 14088, 31205,-18678,-12830, 14090,-26138,-25337,
  748. -11541, -3254, 27628,-22270, 30953,-16136,-30745, 20991,-17406,
  749. 5632,-14330, 28911,-25594, 17408,-20474, 13041, -8731, 2292,
  750. -3860, 24049, 10225,-19220, 10478, -4374, -1199, 148, -330,
  751. -74, 593, 188, 1558, -4152, 15984, 15934, 15934, 15934,
  752. 15934, 15934, 15934, 15934, 15934, 15934, 15934, 15934, 1598,
  753. 156, 1604, -1163, 2278,-30018,-25821,-21763,-23776, 24066,
  754. 9502, 25866,-25055, 10004,-24798, 7204, -4581, -9678, 1554,
  755. 10553, 3102, 12193, 2443, 11955, 1213, 10689, -1293, 921,
  756. -4173, 8661, -6049, 8815,-21221,-14854, 23840, -9477, 8549,
  757. 5278, 8743, 9375, 6940, 13038, 4826, 14598, 7721,-24308,
  758. -29905,-19703,-17106,-16124, -3287,-26118,-19709,-10769, 24361,
  759. 28648, 10274,-11292,-29665,-16417, 24346, 14580, 18707, 26323,
  760. -4410,-17711, 5133, 26328,-14579,-31008, 24583, 18404, 28417,
  761. -24350, 19453, 28642,-32513,-10777, -3079, 30188, -7686, 27635,
  762. -32521,-16384,-20240, -6386, 10986, 23827,-25880,-32752,-23321,
  763. 14605, 32231, 780,-13849, 15119, 28647, 4888, -7705, 30750,
  764. 64, 0, 32488, 6687,-20758, 19745, -2070, -1, -1,
  765. 28, 256, -4608, 7168, 7444, 23557,-21998, 13064, 3345,
  766. -4086,-28915, -8594, 32262, 8461, 27387,-12275, 12012, 23563,
  767. -18719,-28410, 29144,-22271,-32562,-16384, 12528, -6386, 10986,
  768. 23827,-25880,-32752,-23321, 14605, 32231, 780,-13849, 15119,
  769. 28647, 4888, -7705, 30750, 64, 0, 32488, 6687,-20758,
  770. 19745, -2070,-13792, -6414, 28188, -2821, -4585, 7168, 7444,
  771. 23557,-21998, 13064, 3345, -4086,-28915, -8694, 32262, 8461,
  772. -14853,-14907,-14907,-14907,-14907, 32767,-14907,-14907,-14907,
  773. -14907,-14907,-14907,-14907,-14907,-14891,-14907,-14907,-14907,
  774. -14907,-14907, 8901, 9375, 6940, 13038, 4826, 14598, 7721,
  775. -24308,-29905,-19703,-17106,-16124, -3287,-26118,-19709,-10769,
  776. 24361, 28648, 10274,-11292,-29665,-16417, 24346, 14580, 18707,
  777. 26323, -4440,-17711, 5133, 26328,-14579,-31008, 24583, 18404,
  778. 28417,-24350, 19453, 28642,-32513,-10777, -3079, 30188, -7686,
  779. 27635,-32521,-16384,-20240, -6386, 10986, 23827,-25880,-32752,
  780. -23321, 14605, 32231, 780,-13849, 15119, 28647, 4888, -7705,
  781. -15074,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  782. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  783. -14907,-14907,-14907,-14907, 8192,-14907,-14907,-14907,-14907,
  784. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  785. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  786. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  787. -14907,-14907,-14907,-14907,-14897,-14907,-14907,-14907,-14907,
  788. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  789. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  790. -14907,-15931,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  791. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  792. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  793. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  794. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  795. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  796. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  797. -14907,-14907,-14907,-14907,-14907,-14907,-14907, 26121, 12890,
  798. 2604, 12228,-11634, 12299, 5573,-16642, 32452, 29182, 7710,
  799. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  800. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  801. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  802. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  803. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  804. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  805. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  806. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  807. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  808. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  809. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  810. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  811. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  812. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  813. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  814. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  815. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  816. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  817. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  818. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  819. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  820. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  821. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  822. 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710, 7710,
  823. 7710,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  824. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  825. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  826. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  827. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  828. -14907,-14907,-14907,-14907,-14907,-14907,-10811,-14907,-14907,
  829. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  830. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  831. -14907,-14907,-14917,-14907,-14907,-14907,-14907,-14907,-14907,
  832. -14907,-14907,-14907,-14907,-14907,-14907,-14938,-14907,-14907,
  833. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  834. -14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,-14907,
  835. -14907,-14907,-14907,-14907, -571, -9986, -58, 12542,-18491,
  836. 32507, 12838, 6653, 294, -1, 0,-19968, 18368, -4357,
  837. -5696, 2804, 12998,-22802,-22080, -7701, -5183, 486, -3133,
  838. -5660, -1083, 13799,-28726,-11029, 205,-14848, 32464, -1,
  839. -129,-13072, 6380, -7948, 20717, 18425, 17392, 14335, -5646,
  840. 30973, -3598, 7188, -3867, 3055, -4247, 5597, -4011,-26427,
  841. -11,-30418, 7922, 2614, 237, -5839,-27413,-17624,-29716,
  842. -13539, 239, 20991, 18164, -4082,-16647,-27386, 19458, 20224,
  843. 4619, 19728, -7409,-18186,-25073, 27627,-23539, -7945,-31464,
  844. 14330,-12523,-22021, -7701, -5183, 486, -3133, -5660, -1083,
  845. 13799,-28726,-11029, 205,-14848, 32464, -1, -129,-13072,
  846. 6380, -7948, 20717, 18425, 17392, 14093, -5646, 30973, -3598,
  847. 7188, -3867, 3055, 3689, -5401, 4906, -6051, 4250, -6272,
  848. 3492, -6343, 3197, -6397, 4041, -6341, 6255, -6381, 239,
  849. 20991, 18164, -4082,-16647,-27386, 19458, 20224, 4619, 19728,
  850. -7409,-18186,-25073, 27627,-23539, -7945,-31464, 14330,-12523,
  851. 14843, -6130, 30202, -250,-28420, 10467, 16907, -3359, -6644,
  852. 31965, 3343,-11727, 2966,-12616, 3064,-13472, 6732,-12349,
  853. 5541,-11965, 5530,-10820, -1912, -3637, 32285, -4607, 310,
  854. -32768, 0, -5258, 2106, -6857, 2681, -5449, -3606, -6717,
  855. -5482, -3606, -1853, 4082, -7631, -9808, -1742, -2851, -5112,
  856. 64, -868,-13546,-13365,-13365,-13365,-13365,-13365,-13365,
  857. -13365,-13365,-13365,-13365,-13365,-13365,-13365,-13365,-13365,
  858. -13365,-13365,-13365,-13365,-13365,-13365,-13365,-13365,-13365,
  859. -13365,-13365,-13365,-13365,-13365,-13365,-13365,-13365,-13365,
  860. -13365,-13365,-13365,-13365,-13365,-13365,-13365, 7883, -2316,
  861. 9086, -3944, 10500, 4285, 10459, -6474, 10204, -6539, 11601,
  862. -6824, 13385, -7142, 13872, -7457, 13670, -7725, 13463, -6887,
  863. 12482, -5580, 12600, -4964, 12480, 3254, 11741, -4210,-24819,
  864. 23282, 22798, 491, -1774, -1073, 3641, -1304, 28928, -250,
  865. -27396, 6657, -8961, 22524, 19987, 10231, 1791, 8947,-32763,
  866. -26385,-31227, -792,-30461, 8926, 4866, 27863, 27756, 27756,
  867. 27756, 27756, 27756, 27756, 27756, 27756, 5630,-11070,-16136,
  868. 20671,-11530, 27328, 8179, 5059,-31503,-24379,-19472, 17863,
  869. -29202, 22986, -23, 8909, 8422, 10450
  870. };
  871. err = opus_multistream_encode(enc, pcm, 1440, data, 7380);
  872. /* reads uninitialized data at src/opus_multistream_encoder.c:293 */
  873. assert(err > 0);
  874. }
  875. opus_multistream_encoder_destroy(enc);
  876. return 0;
  877. }
  878. static int ec_enc_shrink_assert(void)
  879. {
  880. OpusEncoder *enc;
  881. int err;
  882. int data_len;
  883. unsigned char data[2000];
  884. static const short pcm1[960] = { 5140 };
  885. static const short pcm2[2880] =
  886. {
  887. -256,-12033, 0, -2817, 6912, 0, -5359, 5200, 3061,
  888. 0, -2903, 5652, -1281,-24656,-14433,-24678, 32,-29793,
  889. 2870, 0, 4096, 5120, 5140, -234,-20230,-24673,-24633,
  890. -24673,-24705, 0,-32768,-25444,-25444, 0,-25444,-25444,
  891. 156,-20480, -7948, -5920, -7968, -7968, 224, 0, 20480,
  892. 11, 20496, 13, 20496, 11,-20480, 2292,-20240, 244,
  893. 20480, 11, 20496, 11,-20480, 244,-20240, 7156, 20456,
  894. -246,-20243, 244, 128, 244, 20480, 11, 20496, 11,
  895. -20480, 244,-20256, 244, 20480, 256, 0, -246, 16609,
  896. -176, 0, 29872, -4096, -2888, 516, 2896, 4096, 2896,
  897. -20480, -3852, -2896, -1025,-31056,-14433, 244, 1792, -256,
  898. -12033, 0, -2817, 0, 0, -5359, 5200, 3061, 16,
  899. -2903, 5652, -1281,-24656,-14433,-24678, 32,-29793, 2870,
  900. 0, 4096, 5120, 5140, -234,-20230,-24673,-24633,-24673,
  901. -24705, 0,-32768,-25444,-25444, 0,-25444,-25444, 156,
  902. -20480, -7973, -5920, -7968, -7968, 224, 0, 20480, 11,
  903. 20496, 11, 20496, 11,-20480, 2292,-20213, 244, 20480,
  904. 11, 20496, 11,-24698, -2873, 0, 7, -1, 208,
  905. -256, 244, 0, 4352, 20715, -2796, 11,-22272, 5364,
  906. -234,-20230,-24673,-25913, 8351,-24832, 13963, 11, 0,
  907. 16, 5140, 5652, -1281,-24656,-14433,-24673, 32671, 159,
  908. 0,-25472,-25444, 156,-25600,-25444,-25444, 0, -2896,
  909. -7968, -7960, -7968, -7968, 0, 0, 2896, 4096, 2896,
  910. 4096, 2896, 0, -2896, -4088, -2896, 0, 2896, 0,
  911. -2896, -4096, -2896, 11, 2640, -4609, -2896,-32768, -3072,
  912. 0, 2896, 4096, 2896, 0, -2896, -4096, -2896, 0,
  913. 80, 1, 2816, 0, 20656, 255,-20480, 116,-18192
  914. };
  915. static const short pcm3[2880] = { 0 };
  916. enc = opus_encoder_create(48000, 1, OPUS_APPLICATION_AUDIO, &err);
  917. opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(10));
  918. opus_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(6));
  919. opus_encoder_ctl(enc, OPUS_SET_BITRATE(6000));
  920. data_len = opus_encode(enc, pcm1, 960, data, 2000);
  921. assert(data_len > 0);
  922. opus_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE));
  923. opus_encoder_ctl(enc, OPUS_SET_PREDICTION_DISABLED(1));
  924. opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_SUPERWIDEBAND));
  925. opus_encoder_ctl(enc, OPUS_SET_INBAND_FEC(1));
  926. opus_encoder_ctl(enc, OPUS_SET_BITRATE(15600));
  927. data_len = opus_encode(enc, pcm2, 2880, data, 122);
  928. assert(data_len > 0);
  929. opus_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC));
  930. opus_encoder_ctl(enc, OPUS_SET_BITRATE(27000));
  931. data_len = opus_encode(enc, pcm3, 2880, data, 122); /* assertion failure */
  932. assert(data_len > 0);
  933. opus_encoder_destroy(enc);
  934. return 0;
  935. }
  936. static int ec_enc_shrink_assert2(void)
  937. {
  938. OpusEncoder *enc;
  939. int err;
  940. int data_len;
  941. unsigned char data[2000];
  942. enc = opus_encoder_create(48000, 1, OPUS_APPLICATION_AUDIO, &err);
  943. opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(6));
  944. opus_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE));
  945. opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND));
  946. opus_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(26));
  947. opus_encoder_ctl(enc, OPUS_SET_BITRATE(27000));
  948. {
  949. static const short pcm[960] = { 0 };
  950. data_len = opus_encode(enc, pcm, 960, data, 2000);
  951. assert(data_len > 0);
  952. }
  953. opus_encoder_ctl(enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC));
  954. {
  955. static const short pcm[480] =
  956. {
  957. 32767, 32767, 0, 0, 32767, 32767, 0, 0, 32767, 32767,
  958. -32768, -32768, 0, 0, -32768, -32768, 0, 0, -32768, -32768
  959. };
  960. data_len = opus_encode(enc, pcm, 480, data, 19);
  961. assert(data_len > 0);
  962. }
  963. opus_encoder_destroy(enc);
  964. return 0;
  965. }
  966. static int silk_gain_assert(void)
  967. {
  968. OpusEncoder *enc;
  969. int err;
  970. int data_len;
  971. unsigned char data[1000];
  972. static const short pcm1[160] = { 0 };
  973. static const short pcm2[960] =
  974. {
  975. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  976. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  977. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  978. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  979. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  980. 32767, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  981. 0, 0, 0, 0, 32767
  982. };
  983. enc = opus_encoder_create(8000, 1, OPUS_APPLICATION_AUDIO, &err);
  984. opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(3));
  985. opus_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_NARROWBAND));
  986. opus_encoder_ctl(enc, OPUS_SET_BITRATE(6000));
  987. data_len = opus_encode(enc, pcm1, 160, data, 1000);
  988. assert(data_len > 0);
  989. opus_encoder_ctl(enc, OPUS_SET_VBR(0));
  990. opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(0));
  991. opus_encoder_ctl(enc, OPUS_SET_MAX_BANDWIDTH(OPUS_BANDWIDTH_MEDIUMBAND));
  992. opus_encoder_ctl(enc, OPUS_SET_BITRATE(2867));
  993. data_len = opus_encode(enc, pcm2, 960, data, 1000);
  994. assert(data_len > 0);
  995. opus_encoder_destroy(enc);
  996. return 0;
  997. }
  998. void regression_test(void)
  999. {
  1000. fprintf(stderr, "Running simple tests for bugs that have been fixed previously\n");
  1001. celt_ec_internal_error();
  1002. mscbr_encode_fail10();
  1003. mscbr_encode_fail();
  1004. surround_analysis_uninit();
  1005. ec_enc_shrink_assert();
  1006. ec_enc_shrink_assert2();
  1007. silk_gain_assert();
  1008. }