You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

583 lines
21KB

  1. /*
  2. * G.722 ADPCM audio encoder/decoder
  3. *
  4. * Copyright (c) CMU 1993 Computer Science, Speech Group
  5. * Chengxiang Lu and Alex Hauptmann
  6. * Copyright (c) 2005 Steve Underwood <steveu at coppice.org>
  7. * Copyright (c) 2009 Kenan Gillet
  8. * Copyright (c) 2010 Martin Storsjo
  9. *
  10. * This file is part of FFmpeg.
  11. *
  12. * FFmpeg is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU Lesser General Public
  14. * License as published by the Free Software Foundation; either
  15. * version 2.1 of the License, or (at your option) any later version.
  16. *
  17. * FFmpeg is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  20. * Lesser General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Lesser General Public
  23. * License along with FFmpeg; if not, write to the Free Software
  24. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  25. */
  26. /**
  27. * @file
  28. * G.722 ADPCM audio codec
  29. *
  30. * This G.722 decoder is a bit-exact implementation of the ITU G.722
  31. * specification for all three specified bitrates - 64000bps, 56000bps
  32. * and 48000bps. It passes the ITU tests.
  33. *
  34. * @note For the 56000bps and 48000bps bitrates, the lowest 1 or 2 bits
  35. * respectively of each byte are ignored.
  36. */
  37. #include "avcodec.h"
  38. #include "mathops.h"
  39. #include "get_bits.h"
  40. #define PREV_SAMPLES_BUF_SIZE 1024
  41. #define FREEZE_INTERVAL 128
  42. typedef struct {
  43. int16_t prev_samples[PREV_SAMPLES_BUF_SIZE]; ///< memory of past decoded samples
  44. int prev_samples_pos; ///< the number of values in prev_samples
  45. /**
  46. * The band[0] and band[1] correspond respectively to the lower band and higher band.
  47. */
  48. struct G722Band {
  49. int16_t s_predictor; ///< predictor output value
  50. int32_t s_zero; ///< previous output signal from zero predictor
  51. int8_t part_reconst_mem[2]; ///< signs of previous partially reconstructed signals
  52. int16_t prev_qtzd_reconst; ///< previous quantized reconstructed signal (internal value, using low_inv_quant4)
  53. int16_t pole_mem[2]; ///< second-order pole section coefficient buffer
  54. int32_t diff_mem[6]; ///< quantizer difference signal memory
  55. int16_t zero_mem[6]; ///< Seventh-order zero section coefficient buffer
  56. int16_t log_factor; ///< delayed 2-logarithmic quantizer factor
  57. int16_t scale_factor; ///< delayed quantizer scale factor
  58. } band[2];
  59. struct TrellisNode {
  60. struct G722Band state;
  61. uint32_t ssd;
  62. int path;
  63. } *node_buf[2], **nodep_buf[2];
  64. struct TrellisPath {
  65. int value;
  66. int prev;
  67. } *paths[2];
  68. } G722Context;
  69. static const int8_t sign_lookup[2] = { -1, 1 };
  70. static const int16_t inv_log2_table[32] = {
  71. 2048, 2093, 2139, 2186, 2233, 2282, 2332, 2383,
  72. 2435, 2489, 2543, 2599, 2656, 2714, 2774, 2834,
  73. 2896, 2960, 3025, 3091, 3158, 3228, 3298, 3371,
  74. 3444, 3520, 3597, 3676, 3756, 3838, 3922, 4008
  75. };
  76. static const int16_t high_log_factor_step[2] = { 798, -214 };
  77. static const int16_t high_inv_quant[4] = { -926, -202, 926, 202 };
  78. /**
  79. * low_log_factor_step[index] == wl[rl42[index]]
  80. */
  81. static const int16_t low_log_factor_step[16] = {
  82. -60, 3042, 1198, 538, 334, 172, 58, -30,
  83. 3042, 1198, 538, 334, 172, 58, -30, -60
  84. };
  85. static const int16_t low_inv_quant4[16] = {
  86. 0, -2557, -1612, -1121, -786, -530, -323, -150,
  87. 2557, 1612, 1121, 786, 530, 323, 150, 0
  88. };
  89. static const int16_t low_inv_quant6[64] = {
  90. -17, -17, -17, -17, -3101, -2738, -2376, -2088,
  91. -1873, -1689, -1535, -1399, -1279, -1170, -1072, -982,
  92. -899, -822, -750, -682, -618, -558, -501, -447,
  93. -396, -347, -300, -254, -211, -170, -130, -91,
  94. 3101, 2738, 2376, 2088, 1873, 1689, 1535, 1399,
  95. 1279, 1170, 1072, 982, 899, 822, 750, 682,
  96. 618, 558, 501, 447, 396, 347, 300, 254,
  97. 211, 170, 130, 91, 54, 17, -54, -17
  98. };
  99. /**
  100. * quadrature mirror filter (QMF) coefficients
  101. *
  102. * ITU-T G.722 Table 11
  103. */
  104. static const int16_t qmf_coeffs[12] = {
  105. 3, -11, 12, 32, -210, 951, 3876, -805, 362, -156, 53, -11,
  106. };
  107. /**
  108. * adaptive predictor
  109. *
  110. * @param cur_diff the dequantized and scaled delta calculated from the
  111. * current codeword
  112. */
  113. static void do_adaptive_prediction(struct G722Band *band, const int cur_diff)
  114. {
  115. int sg[2], limit, i, cur_qtzd_reconst;
  116. const int cur_part_reconst = band->s_zero + cur_diff < 0;
  117. sg[0] = sign_lookup[cur_part_reconst != band->part_reconst_mem[0]];
  118. sg[1] = sign_lookup[cur_part_reconst == band->part_reconst_mem[1]];
  119. band->part_reconst_mem[1] = band->part_reconst_mem[0];
  120. band->part_reconst_mem[0] = cur_part_reconst;
  121. band->pole_mem[1] = av_clip((sg[0] * av_clip(band->pole_mem[0], -8191, 8191) >> 5) +
  122. (sg[1] << 7) + (band->pole_mem[1] * 127 >> 7), -12288, 12288);
  123. limit = 15360 - band->pole_mem[1];
  124. band->pole_mem[0] = av_clip(-192 * sg[0] + (band->pole_mem[0] * 255 >> 8), -limit, limit);
  125. if (cur_diff) {
  126. for (i = 0; i < 6; i++)
  127. band->zero_mem[i] = ((band->zero_mem[i]*255) >> 8) +
  128. ((band->diff_mem[i]^cur_diff) < 0 ? -128 : 128);
  129. } else
  130. for (i = 0; i < 6; i++)
  131. band->zero_mem[i] = (band->zero_mem[i]*255) >> 8;
  132. for (i = 5; i > 0; i--)
  133. band->diff_mem[i] = band->diff_mem[i-1];
  134. band->diff_mem[0] = av_clip_int16(cur_diff << 1);
  135. band->s_zero = 0;
  136. for (i = 5; i >= 0; i--)
  137. band->s_zero += (band->zero_mem[i]*band->diff_mem[i]) >> 15;
  138. cur_qtzd_reconst = av_clip_int16((band->s_predictor + cur_diff) << 1);
  139. band->s_predictor = av_clip_int16(band->s_zero +
  140. (band->pole_mem[0] * cur_qtzd_reconst >> 15) +
  141. (band->pole_mem[1] * band->prev_qtzd_reconst >> 15));
  142. band->prev_qtzd_reconst = cur_qtzd_reconst;
  143. }
  144. static int inline linear_scale_factor(const int log_factor)
  145. {
  146. const int wd1 = inv_log2_table[(log_factor >> 6) & 31];
  147. const int shift = log_factor >> 11;
  148. return shift < 0 ? wd1 >> -shift : wd1 << shift;
  149. }
  150. static void update_low_predictor(struct G722Band *band, const int ilow)
  151. {
  152. do_adaptive_prediction(band,
  153. band->scale_factor * low_inv_quant4[ilow] >> 10);
  154. // quantizer adaptation
  155. band->log_factor = av_clip((band->log_factor * 127 >> 7) +
  156. low_log_factor_step[ilow], 0, 18432);
  157. band->scale_factor = linear_scale_factor(band->log_factor - (8 << 11));
  158. }
  159. static void update_high_predictor(struct G722Band *band, const int dhigh,
  160. const int ihigh)
  161. {
  162. do_adaptive_prediction(band, dhigh);
  163. // quantizer adaptation
  164. band->log_factor = av_clip((band->log_factor * 127 >> 7) +
  165. high_log_factor_step[ihigh&1], 0, 22528);
  166. band->scale_factor = linear_scale_factor(band->log_factor - (10 << 11));
  167. }
  168. static void apply_qmf(const int16_t *prev_samples, int *xout1, int *xout2)
  169. {
  170. int i;
  171. *xout1 = 0;
  172. *xout2 = 0;
  173. for (i = 0; i < 12; i++) {
  174. MAC16(*xout2, prev_samples[2*i ], qmf_coeffs[i ]);
  175. MAC16(*xout1, prev_samples[2*i+1], qmf_coeffs[11-i]);
  176. }
  177. }
  178. static av_cold int g722_init(AVCodecContext * avctx)
  179. {
  180. G722Context *c = avctx->priv_data;
  181. if (avctx->channels != 1) {
  182. av_log(avctx, AV_LOG_ERROR, "Only mono tracks are allowed.\n");
  183. return AVERROR_INVALIDDATA;
  184. }
  185. avctx->sample_fmt = AV_SAMPLE_FMT_S16;
  186. switch (avctx->bits_per_coded_sample) {
  187. case 8:
  188. case 7:
  189. case 6:
  190. break;
  191. default:
  192. av_log(avctx, AV_LOG_WARNING, "Unsupported bits_per_coded_sample [%d], "
  193. "assuming 8\n",
  194. avctx->bits_per_coded_sample);
  195. case 0:
  196. avctx->bits_per_coded_sample = 8;
  197. break;
  198. }
  199. c->band[0].scale_factor = 8;
  200. c->band[1].scale_factor = 2;
  201. c->prev_samples_pos = 22;
  202. if (avctx->lowres)
  203. avctx->sample_rate /= 2;
  204. if (avctx->trellis) {
  205. int frontier = 1 << avctx->trellis;
  206. int max_paths = frontier * FREEZE_INTERVAL;
  207. int i;
  208. for (i = 0; i < 2; i++) {
  209. c->paths[i] = av_mallocz(max_paths * sizeof(**c->paths));
  210. c->node_buf[i] = av_mallocz(2 * frontier * sizeof(**c->node_buf));
  211. c->nodep_buf[i] = av_mallocz(2 * frontier * sizeof(**c->nodep_buf));
  212. }
  213. }
  214. return 0;
  215. }
  216. static av_cold int g722_close(AVCodecContext *avctx)
  217. {
  218. G722Context *c = avctx->priv_data;
  219. int i;
  220. for (i = 0; i < 2; i++) {
  221. av_freep(&c->paths[i]);
  222. av_freep(&c->node_buf[i]);
  223. av_freep(&c->nodep_buf[i]);
  224. }
  225. return 0;
  226. }
  227. #if CONFIG_ADPCM_G722_DECODER
  228. static const int16_t low_inv_quant5[32] = {
  229. -35, -35, -2919, -2195, -1765, -1458, -1219, -1023,
  230. -858, -714, -587, -473, -370, -276, -190, -110,
  231. 2919, 2195, 1765, 1458, 1219, 1023, 858, 714,
  232. 587, 473, 370, 276, 190, 110, 35, -35
  233. };
  234. static const int16_t *low_inv_quants[3] = { low_inv_quant6, low_inv_quant5,
  235. low_inv_quant4 };
  236. static int g722_decode_frame(AVCodecContext *avctx, void *data,
  237. int *data_size, AVPacket *avpkt)
  238. {
  239. G722Context *c = avctx->priv_data;
  240. int16_t *out_buf = data;
  241. int j, out_len = 0;
  242. const int skip = 8 - avctx->bits_per_coded_sample;
  243. const int16_t *quantizer_table = low_inv_quants[skip];
  244. GetBitContext gb;
  245. init_get_bits(&gb, avpkt->data, avpkt->size * 8);
  246. for (j = 0; j < avpkt->size; j++) {
  247. int ilow, ihigh, rlow;
  248. ihigh = get_bits(&gb, 2);
  249. ilow = get_bits(&gb, 6 - skip);
  250. skip_bits(&gb, skip);
  251. rlow = av_clip((c->band[0].scale_factor * quantizer_table[ilow] >> 10)
  252. + c->band[0].s_predictor, -16384, 16383);
  253. update_low_predictor(&c->band[0], ilow >> (2 - skip));
  254. if (!avctx->lowres) {
  255. const int dhigh = c->band[1].scale_factor *
  256. high_inv_quant[ihigh] >> 10;
  257. const int rhigh = av_clip(dhigh + c->band[1].s_predictor,
  258. -16384, 16383);
  259. int xout1, xout2;
  260. update_high_predictor(&c->band[1], dhigh, ihigh);
  261. c->prev_samples[c->prev_samples_pos++] = rlow + rhigh;
  262. c->prev_samples[c->prev_samples_pos++] = rlow - rhigh;
  263. apply_qmf(c->prev_samples + c->prev_samples_pos - 24,
  264. &xout1, &xout2);
  265. out_buf[out_len++] = av_clip_int16(xout1 >> 12);
  266. out_buf[out_len++] = av_clip_int16(xout2 >> 12);
  267. if (c->prev_samples_pos >= PREV_SAMPLES_BUF_SIZE) {
  268. memmove(c->prev_samples,
  269. c->prev_samples + c->prev_samples_pos - 22,
  270. 22 * sizeof(c->prev_samples[0]));
  271. c->prev_samples_pos = 22;
  272. }
  273. } else
  274. out_buf[out_len++] = rlow;
  275. }
  276. *data_size = out_len << 1;
  277. return avpkt->size;
  278. }
  279. AVCodec ff_adpcm_g722_decoder = {
  280. .name = "g722",
  281. .type = AVMEDIA_TYPE_AUDIO,
  282. .id = CODEC_ID_ADPCM_G722,
  283. .priv_data_size = sizeof(G722Context),
  284. .init = g722_init,
  285. .decode = g722_decode_frame,
  286. .long_name = NULL_IF_CONFIG_SMALL("G.722 ADPCM"),
  287. .max_lowres = 1,
  288. };
  289. #endif
  290. #if CONFIG_ADPCM_G722_ENCODER
  291. static const int16_t low_quant[33] = {
  292. 35, 72, 110, 150, 190, 233, 276, 323,
  293. 370, 422, 473, 530, 587, 650, 714, 786,
  294. 858, 940, 1023, 1121, 1219, 1339, 1458, 1612,
  295. 1765, 1980, 2195, 2557, 2919
  296. };
  297. static inline void filter_samples(G722Context *c, const int16_t *samples,
  298. int *xlow, int *xhigh)
  299. {
  300. int xout1, xout2;
  301. c->prev_samples[c->prev_samples_pos++] = samples[0];
  302. c->prev_samples[c->prev_samples_pos++] = samples[1];
  303. apply_qmf(c->prev_samples + c->prev_samples_pos - 24, &xout1, &xout2);
  304. *xlow = xout1 + xout2 >> 13;
  305. *xhigh = xout1 - xout2 >> 13;
  306. if (c->prev_samples_pos >= PREV_SAMPLES_BUF_SIZE) {
  307. memmove(c->prev_samples,
  308. c->prev_samples + c->prev_samples_pos - 22,
  309. 22 * sizeof(c->prev_samples[0]));
  310. c->prev_samples_pos = 22;
  311. }
  312. }
  313. static inline int encode_high(const struct G722Band *state, int xhigh)
  314. {
  315. int diff = av_clip_int16(xhigh - state->s_predictor);
  316. int pred = 141 * state->scale_factor >> 8;
  317. /* = diff >= 0 ? (diff < pred) + 2 : diff >= -pred */
  318. return ((diff ^ (diff >> (sizeof(diff)*8-1))) < pred) + 2*(diff >= 0);
  319. }
  320. static inline int encode_low(const struct G722Band* state, int xlow)
  321. {
  322. int diff = av_clip_int16(xlow - state->s_predictor);
  323. /* = diff >= 0 ? diff : -(diff + 1) */
  324. int limit = diff ^ (diff >> (sizeof(diff)*8-1));
  325. int i = 0;
  326. limit = limit + 1 << 10;
  327. if (limit > low_quant[8] * state->scale_factor)
  328. i = 9;
  329. while (i < 29 && limit > low_quant[i] * state->scale_factor)
  330. i++;
  331. return (diff < 0 ? (i < 2 ? 63 : 33) : 61) - i;
  332. }
  333. static int g722_encode_trellis(AVCodecContext *avctx,
  334. uint8_t *dst, int buf_size, void *data)
  335. {
  336. G722Context *c = avctx->priv_data;
  337. const int16_t *samples = data;
  338. int i, j, k;
  339. int frontier = 1 << avctx->trellis;
  340. struct TrellisNode **nodes[2];
  341. struct TrellisNode **nodes_next[2];
  342. int pathn[2] = {0, 0}, froze = -1;
  343. struct TrellisPath *p[2];
  344. for (i = 0; i < 2; i++) {
  345. nodes[i] = c->nodep_buf[i];
  346. nodes_next[i] = c->nodep_buf[i] + frontier;
  347. memset(c->nodep_buf[i], 0, 2 * frontier * sizeof(*c->nodep_buf));
  348. nodes[i][0] = c->node_buf[i] + frontier;
  349. nodes[i][0]->ssd = 0;
  350. nodes[i][0]->path = 0;
  351. nodes[i][0]->state = c->band[i];
  352. }
  353. for (i = 0; i < buf_size >> 1; i++) {
  354. int xlow, xhigh;
  355. struct TrellisNode *next[2];
  356. int heap_pos[2] = {0, 0};
  357. for (j = 0; j < 2; j++) {
  358. next[j] = c->node_buf[j] + frontier*(i & 1);
  359. memset(nodes_next[j], 0, frontier * sizeof(**nodes_next));
  360. }
  361. filter_samples(c, &samples[2*i], &xlow, &xhigh);
  362. for (j = 0; j < frontier && nodes[0][j]; j++) {
  363. /* Only k >> 2 affects the future adaptive state, therefore testing
  364. * small steps that don't change k >> 2 is useless, the orignal
  365. * value from encode_low is better than them. Since we step k
  366. * in steps of 4, make sure range is a multiple of 4, so that
  367. * we don't miss the original value from encode_low. */
  368. int range = j < frontier/2 ? 4 : 0;
  369. struct TrellisNode *cur_node = nodes[0][j];
  370. int ilow = encode_low(&cur_node->state, xlow);
  371. for (k = ilow - range; k <= ilow + range && k <= 63; k += 4) {
  372. int decoded, dec_diff, pos;
  373. uint32_t ssd;
  374. struct TrellisNode* node;
  375. if (k < 0)
  376. continue;
  377. decoded = av_clip((cur_node->state.scale_factor *
  378. low_inv_quant6[k] >> 10)
  379. + cur_node->state.s_predictor, -16384, 16383);
  380. dec_diff = xlow - decoded;
  381. #define STORE_NODE(index, UPDATE, VALUE)\
  382. ssd = cur_node->ssd + dec_diff*dec_diff;\
  383. /* Check for wraparound. Using 64 bit ssd counters would \
  384. * be simpler, but is slower on x86 32 bit. */\
  385. if (ssd < cur_node->ssd)\
  386. continue;\
  387. if (heap_pos[index] < frontier) {\
  388. pos = heap_pos[index]++;\
  389. assert(pathn[index] < FREEZE_INTERVAL * frontier);\
  390. node = nodes_next[index][pos] = next[index]++;\
  391. node->path = pathn[index]++;\
  392. } else {\
  393. /* Try to replace one of the leaf nodes with the new \
  394. * one, but not always testing the same leaf position */\
  395. pos = (frontier>>1) + (heap_pos[index] & ((frontier>>1) - 1));\
  396. if (ssd >= nodes_next[index][pos]->ssd)\
  397. continue;\
  398. heap_pos[index]++;\
  399. node = nodes_next[index][pos];\
  400. }\
  401. node->ssd = ssd;\
  402. node->state = cur_node->state;\
  403. UPDATE;\
  404. c->paths[index][node->path].value = VALUE;\
  405. c->paths[index][node->path].prev = cur_node->path;\
  406. /* Sift the newly inserted node up in the heap to restore \
  407. * the heap property */\
  408. while (pos > 0) {\
  409. int parent = (pos - 1) >> 1;\
  410. if (nodes_next[index][parent]->ssd <= ssd)\
  411. break;\
  412. FFSWAP(struct TrellisNode*, nodes_next[index][parent],\
  413. nodes_next[index][pos]);\
  414. pos = parent;\
  415. }
  416. STORE_NODE(0, update_low_predictor(&node->state, k >> 2), k);
  417. }
  418. }
  419. for (j = 0; j < frontier && nodes[1][j]; j++) {
  420. int ihigh;
  421. struct TrellisNode *cur_node = nodes[1][j];
  422. /* We don't try to get any initial guess for ihigh via
  423. * encode_high - since there's only 4 possible values, test
  424. * them all. Testing all of these gives a much, much larger
  425. * gain than testing a larger range around ilow. */
  426. for (ihigh = 0; ihigh < 4; ihigh++) {
  427. int dhigh, decoded, dec_diff, pos;
  428. uint32_t ssd;
  429. struct TrellisNode* node;
  430. dhigh = cur_node->state.scale_factor *
  431. high_inv_quant[ihigh] >> 10;
  432. decoded = av_clip(dhigh + cur_node->state.s_predictor,
  433. -16384, 16383);
  434. dec_diff = xhigh - decoded;
  435. STORE_NODE(1, update_high_predictor(&node->state, dhigh, ihigh), ihigh);
  436. }
  437. }
  438. for (j = 0; j < 2; j++) {
  439. FFSWAP(struct TrellisNode**, nodes[j], nodes_next[j]);
  440. if (nodes[j][0]->ssd > (1 << 16)) {
  441. for (k = 1; k < frontier && nodes[j][k]; k++)
  442. nodes[j][k]->ssd -= nodes[j][0]->ssd;
  443. nodes[j][0]->ssd = 0;
  444. }
  445. }
  446. if (i == froze + FREEZE_INTERVAL) {
  447. p[0] = &c->paths[0][nodes[0][0]->path];
  448. p[1] = &c->paths[1][nodes[1][0]->path];
  449. for (j = i; j > froze; j--) {
  450. dst[j] = p[1]->value << 6 | p[0]->value;
  451. p[0] = &c->paths[0][p[0]->prev];
  452. p[1] = &c->paths[1][p[1]->prev];
  453. }
  454. froze = i;
  455. pathn[0] = pathn[1] = 0;
  456. memset(nodes[0] + 1, 0, (frontier - 1)*sizeof(**nodes));
  457. memset(nodes[1] + 1, 0, (frontier - 1)*sizeof(**nodes));
  458. }
  459. }
  460. p[0] = &c->paths[0][nodes[0][0]->path];
  461. p[1] = &c->paths[1][nodes[1][0]->path];
  462. for (j = i; j > froze; j--) {
  463. dst[j] = p[1]->value << 6 | p[0]->value;
  464. p[0] = &c->paths[0][p[0]->prev];
  465. p[1] = &c->paths[1][p[1]->prev];
  466. }
  467. c->band[0] = nodes[0][0]->state;
  468. c->band[1] = nodes[1][0]->state;
  469. return i;
  470. }
  471. static int g722_encode_frame(AVCodecContext *avctx,
  472. uint8_t *dst, int buf_size, void *data)
  473. {
  474. G722Context *c = avctx->priv_data;
  475. const int16_t *samples = data;
  476. int i;
  477. if (avctx->trellis)
  478. return g722_encode_trellis(avctx, dst, buf_size, data);
  479. for (i = 0; i < buf_size >> 1; i++) {
  480. int xlow, xhigh, ihigh, ilow;
  481. filter_samples(c, &samples[2*i], &xlow, &xhigh);
  482. ihigh = encode_high(&c->band[1], xhigh);
  483. ilow = encode_low(&c->band[0], xlow);
  484. update_high_predictor(&c->band[1], c->band[1].scale_factor *
  485. high_inv_quant[ihigh] >> 10, ihigh);
  486. update_low_predictor(&c->band[0], ilow >> 2);
  487. *dst++ = ihigh << 6 | ilow;
  488. }
  489. return i;
  490. }
  491. AVCodec ff_adpcm_g722_encoder = {
  492. .name = "g722",
  493. .type = AVMEDIA_TYPE_AUDIO,
  494. .id = CODEC_ID_ADPCM_G722,
  495. .priv_data_size = sizeof(G722Context),
  496. .init = g722_init,
  497. .close = g722_close,
  498. .encode = g722_encode_frame,
  499. .long_name = NULL_IF_CONFIG_SMALL("G.722 ADPCM"),
  500. .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
  501. };
  502. #endif