FFmpeg
Loading...
Searching...
No Matches
imc.c
Go to the documentation of this file.
1/*
2 * IMC compatible decoder
3 * Copyright (c) 2002-2004 Maxim Poliakovski
4 * Copyright (c) 2006 Benjamin Larsson
5 * Copyright (c) 2006 Konstantin Shishkov
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24/**
25 * @file
26 * IMC - Intel Music Coder
27 * A mdct based codec using a 256 points large transform
28 * divided into 32 bands with some mix of scale factors.
29 * Only mono is supported.
30 */
31
32#include "config_components.h"
33
34#include <math.h>
35#include <stddef.h>
36
38#include "libavutil/ffmath.h"
39#include "libavutil/float_dsp.h"
40#include "libavutil/internal.h"
41#include "libavutil/mem.h"
43#include "libavutil/thread.h"
44#include "libavutil/tx.h"
45
46#include "avcodec.h"
47#include "bswapdsp.h"
48#include "codec_internal.h"
49#include "decode.h"
50#include "get_bits.h"
51#include "sinewin.h"
52
53#include "imcdata.h"
54
55#define IMC_BLOCK_SIZE 64
56#define IMC_FRAME_ID 0x21
57#define BANDS 32
58#define COEFFS 256
59
60typedef struct IMCChannel {
69
70 int bandWidthT[BANDS]; ///< codewords per band
71 int bitsBandT[BANDS]; ///< how many bits per codeword in band
72 int CWlengthT[COEFFS]; ///< how many bits in each codeword
74 int bandFlagsBuf[BANDS]; ///< flags for each band
75 int sumLenArr[BANDS]; ///< bits for all coeffs in band
76 int skipFlagRaw[BANDS]; ///< skip flags are stored in raw form or not
77 int skipFlagBits[BANDS]; ///< bits used to code skip flags
78 int skipFlagCount[BANDS]; ///< skipped coefficients per band
79 int skipFlags[COEFFS]; ///< skip coefficient decoding or not
80 int codewords[COEFFS]; ///< raw codewords read from bitstream
81
83 DECLARE_ALIGNED(32, float, prev_win)[128];
85
109
110static const VLCElem *huffman_vlc[4][4];
111
112#define IMC_VLC_BITS 9
113#define VLC_TABLES_SIZE 9512
114
116
117static inline double freq2bark(double freq)
118{
119 return 3.5 * atan((freq / 7500.0) * (freq / 7500.0)) + 13.0 * atan(freq * 0.00076);
120}
121
122static av_cold void iac_generate_tabs(IMCContext *q, int sampling_rate)
123{
124 double freqmin[32], freqmid[32], freqmax[32];
125 double scale = sampling_rate / (256.0 * 2.0 * 2.0);
126 double nyquist_freq = sampling_rate * 0.5;
127 double freq, bark, prev_bark = 0, tf, tb;
128 int i, j;
129
130 for (i = 0; i < 32; i++) {
131 freq = (band_tab[i] + band_tab[i + 1] - 1) * scale;
132 bark = freq2bark(freq);
133
134 if (i > 0) {
135 tb = bark - prev_bark;
136 q->weights1[i - 1] = ff_exp10(-1.0 * tb);
137 q->weights2[i - 1] = ff_exp10(-2.7 * tb);
138 }
139 prev_bark = bark;
140
141 freqmid[i] = freq;
142
143 tf = freq;
144 while (tf < nyquist_freq) {
145 tf += 0.5;
146 tb = freq2bark(tf);
147 if (tb > bark + 0.5)
148 break;
149 }
150 freqmax[i] = tf;
151
152 tf = freq;
153 while (tf > 0.0) {
154 tf -= 0.5;
155 tb = freq2bark(tf);
156 if (tb <= bark - 0.5)
157 break;
158 }
159 freqmin[i] = tf;
160 }
161
162 for (i = 0; i < 32; i++) {
163 freq = freqmax[i];
164 for (j = 31; j > 0 && freq <= freqmid[j]; j--);
165 q->cyclTab[i] = j + 1;
166
167 freq = freqmin[i];
168 for (j = 0; j < 32 && freq >= freqmid[j]; j++);
169 q->cyclTab2[i] = j - 1;
170 }
171}
172
173static av_cold void imc_init_static(void)
174{
176 /* initialize the VLC tables */
177 for (int i = 0; i < 4 ; i++) {
178 for (int j = 0; j < 4; j++) {
179 huffman_vlc[i][j] =
181 imc_huffman_lens[i][j], 1,
182 imc_huffman_syms[i][j], 1, 1,
183 0, 0);
184 }
185 }
186}
187
189{
190 int i, j, ret;
191 IMCContext *q = avctx->priv_data;
192 static AVOnce init_static_once = AV_ONCE_INIT;
193 float scale = 1.0f / (16384);
194
195 if (avctx->codec_id == AV_CODEC_ID_IAC && avctx->sample_rate > 96000) {
196 av_log(avctx, AV_LOG_ERROR,
197 "Strange sample rate of %i, file likely corrupt or "
198 "needing a new table derivation method.\n",
199 avctx->sample_rate);
201 }
202
203 if (avctx->codec_id == AV_CODEC_ID_IMC) {
206 }
207
208 if (avctx->ch_layout.nb_channels > 2) {
209 avpriv_request_sample(avctx, "Number of channels > 2");
211 }
212
213 for (j = 0; j < avctx->ch_layout.nb_channels; j++) {
214 q->chctx[j].decoder_reset = 1;
215
216 for (i = 0; i < BANDS; i++)
217 q->chctx[j].old_floor[i] = 1.0;
218 }
219
220 /* Build mdct window, a simple sine window normalized with sqrt(2) */
222 for (i = 0; i < COEFFS; i++)
223 q->mdct_sine_window[i] *= sqrt(2.0);
224
225 /* Generate a square root table */
226 for (i = 0; i < 30; i++)
227 q->sqrt_tab[i] = sqrt(i);
228
229 if (avctx->codec_id == AV_CODEC_ID_IAC) {
231 } else {
232 memcpy(q->cyclTab, cyclTab, sizeof(cyclTab));
233 memcpy(q->cyclTab2, cyclTab2, sizeof(cyclTab2));
234 memcpy(q->weights1, imc_weights1, sizeof(imc_weights1));
235 memcpy(q->weights2, imc_weights2, sizeof(imc_weights2));
236 }
237
239 if (!q->fdsp)
240 return AVERROR(ENOMEM);
241
242 ret = av_tx_init(&q->mdct, &q->mdct_fn, AV_TX_FLOAT_MDCT, 1, COEFFS, &scale, 0);
243 if (ret < 0)
244 return ret;
245
247
249
250 ff_thread_once(&init_static_once, imc_init_static);
251
252 return 0;
253}
254
255static void imc_calculate_coeffs(IMCContext *q, float *flcoeffs1,
256 float *flcoeffs2, int *bandWidthT,
257 float *flcoeffs3, float *flcoeffs5)
258{
259 float workT1[BANDS];
260 float workT2[BANDS];
261 float workT3[BANDS];
262 float snr_limit = 1.e-30;
263 float accum = 0.0;
264 int i, cnt2;
265
266 for (i = 0; i < BANDS; i++) {
267 flcoeffs5[i] = workT2[i] = 0.0;
268 if (bandWidthT[i]) {
269 workT1[i] = flcoeffs1[i] * flcoeffs1[i];
270 flcoeffs3[i] = 2.0 * flcoeffs2[i];
271 } else {
272 workT1[i] = 0.0;
273 flcoeffs3[i] = -30000.0;
274 }
275 workT3[i] = bandWidthT[i] * workT1[i] * 0.01;
276 if (workT3[i] <= snr_limit)
277 workT3[i] = 0.0;
278 }
279
280 for (i = 0; i < BANDS; i++) {
281 for (cnt2 = i; cnt2 < q->cyclTab[i]; cnt2++)
282 flcoeffs5[cnt2] = flcoeffs5[cnt2] + workT3[i];
283 workT2[cnt2 - 1] = workT2[cnt2 - 1] + workT3[i];
284 }
285
286 for (i = 1; i < BANDS; i++) {
287 accum = (workT2[i - 1] + accum) * q->weights1[i - 1];
288 flcoeffs5[i] += accum;
289 }
290
291 for (i = 0; i < BANDS; i++)
292 workT2[i] = 0.0;
293
294 for (i = 0; i < BANDS; i++) {
295 for (cnt2 = i - 1; cnt2 > q->cyclTab2[i]; cnt2--)
296 flcoeffs5[cnt2] += workT3[i];
297 workT2[cnt2+1] += workT3[i];
298 }
299
300 accum = 0.0;
301
302 for (i = BANDS-2; i >= 0; i--) {
303 accum = (workT2[i+1] + accum) * q->weights2[i];
304 flcoeffs5[i] += accum;
305 // there is missing code here, but it seems to never be triggered
306 }
307}
308
309
310static void imc_read_level_coeffs(IMCContext *q, int stream_format_code,
311 int *levlCoeffs)
312{
313 int i;
314 int start = 0;
315 const uint8_t *cb_sel;
316 int s = stream_format_code >> 1;
317 const VLCElem * const *const hufftab = huffman_vlc[s];
318
319 cb_sel = imc_cb_select[s];
320
321 if (stream_format_code & 4)
322 start = 1;
323 if (start)
324 levlCoeffs[0] = get_bits(&q->gb, 7);
325 for (i = start; i < BANDS; i++) {
326 levlCoeffs[i] = get_vlc2(&q->gb, hufftab[cb_sel[i]],
327 IMC_VLC_BITS, 2);
328 if (levlCoeffs[i] == 17)
329 levlCoeffs[i] += get_bits(&q->gb, 4);
330 }
331}
332
333static void imc_read_level_coeffs_raw(IMCContext *q, int stream_format_code,
334 int *levlCoeffs)
335{
336 int i;
337
338 q->coef0_pos = get_bits(&q->gb, 5);
339 levlCoeffs[0] = get_bits(&q->gb, 7);
340 for (i = 1; i < BANDS; i++)
341 levlCoeffs[i] = get_bits(&q->gb, 4);
342}
343
344static void imc_decode_level_coefficients(IMCContext *q, int *levlCoeffBuf,
345 float *flcoeffs1, float *flcoeffs2)
346{
347 int i, level;
348 float tmp, tmp2;
349 // maybe some frequency division thingy
350
351 flcoeffs1[0] = 20000.0 / exp2 (levlCoeffBuf[0] * 0.18945); // 0.18945 = log2(10) * 0.05703125
352 flcoeffs2[0] = log2f(flcoeffs1[0]);
353 tmp = flcoeffs1[0];
354 tmp2 = flcoeffs2[0];
355
356 for (i = 1; i < BANDS; i++) {
357 level = levlCoeffBuf[i];
358 if (level == 16) {
359 flcoeffs1[i] = 1.0;
360 flcoeffs2[i] = 0.0;
361 } else {
362 if (level < 17)
363 level -= 7;
364 else if (level <= 24)
365 level -= 32;
366 else
367 level -= 16;
368
369 tmp *= imc_exp_tab[15 + level];
370 tmp2 += 0.83048 * level; // 0.83048 = log2(10) * 0.25
371 flcoeffs1[i] = tmp;
372 flcoeffs2[i] = tmp2;
373 }
374 }
375}
376
377
378static void imc_decode_level_coefficients2(IMCContext *q, int *levlCoeffBuf,
379 float *old_floor, float *flcoeffs1,
380 float *flcoeffs2)
381{
382 int i;
383 /* FIXME maybe flag_buf = noise coding and flcoeffs1 = new scale factors
384 * and flcoeffs2 old scale factors
385 * might be incomplete due to a missing table that is in the binary code
386 */
387 for (i = 0; i < BANDS; i++) {
388 flcoeffs1[i] = 0;
389 if (levlCoeffBuf[i] < 16) {
390 flcoeffs1[i] = imc_exp_tab2[levlCoeffBuf[i]] * old_floor[i];
391 flcoeffs2[i] = (levlCoeffBuf[i] - 7) * 0.83048 + flcoeffs2[i]; // 0.83048 = log2(10) * 0.25
392 } else {
393 flcoeffs1[i] = old_floor[i];
394 }
395 }
396}
397
398static void imc_decode_level_coefficients_raw(IMCContext *q, int *levlCoeffBuf,
399 float *flcoeffs1, float *flcoeffs2)
400{
401 int i, level, pos;
402 float tmp, tmp2;
403
404 pos = q->coef0_pos;
405 flcoeffs1[pos] = 20000.0 / pow (2, levlCoeffBuf[0] * 0.18945); // 0.18945 = log2(10) * 0.05703125
406 flcoeffs2[pos] = log2f(flcoeffs1[pos]);
407 tmp = flcoeffs1[pos];
408 tmp2 = flcoeffs2[pos];
409
410 levlCoeffBuf++;
411 for (i = 0; i < BANDS; i++) {
412 if (i == pos)
413 continue;
414 level = *levlCoeffBuf++;
415 flcoeffs1[i] = tmp * powf(10.0, -level * 0.4375); //todo tab
416 flcoeffs2[i] = tmp2 - 1.4533435415 * level; // 1.4533435415 = log2(10) * 0.4375
417 }
418}
419
420/**
421 * Perform bit allocation depending on bits available
422 */
424 int stream_format_code, int freebits, int flag)
425{
426 int i, j;
427 const float limit = -1.e20;
428 float highest = 0.0;
429 int indx;
430 int t1 = 0;
431 int t2 = 1;
432 float summa = 0.0;
433 int iacc = 0;
434 int summer = 0;
435 int rres, cwlen;
436 float lowest = 1.e10;
437 int low_indx = 0;
438 float workT[32];
439 int flg;
440 int found_indx = 0;
441
442 for (i = 0; i < BANDS; i++)
443 highest = FFMAX(highest, chctx->flcoeffs1[i]);
444
445 for (i = 0; i < BANDS - 1; i++) {
446 if (chctx->flcoeffs5[i] <= 0) {
447 av_log(q->avctx, AV_LOG_ERROR, "flcoeffs5 %f invalid\n", chctx->flcoeffs5[i]);
448 return AVERROR_INVALIDDATA;
449 }
450 chctx->flcoeffs4[i] = chctx->flcoeffs3[i] - log2f(chctx->flcoeffs5[i]);
451 }
452 chctx->flcoeffs4[BANDS - 1] = limit;
453
454 highest = highest * 0.25;
455
456 for (i = 0; i < BANDS; i++) {
457 indx = -1;
458 if ((band_tab[i + 1] - band_tab[i]) == chctx->bandWidthT[i])
459 indx = 0;
460
461 if ((band_tab[i + 1] - band_tab[i]) > chctx->bandWidthT[i])
462 indx = 1;
463
464 if (((band_tab[i + 1] - band_tab[i]) / 2) >= chctx->bandWidthT[i])
465 indx = 2;
466
467 if (indx == -1)
468 return AVERROR_INVALIDDATA;
469
470 chctx->flcoeffs4[i] += xTab[(indx * 2 + (chctx->flcoeffs1[i] < highest)) * 2 + flag];
471 }
472
473 if (stream_format_code & 0x2) {
474 chctx->flcoeffs4[0] = limit;
475 chctx->flcoeffs4[1] = limit;
476 chctx->flcoeffs4[2] = limit;
477 chctx->flcoeffs4[3] = limit;
478 }
479
480 for (i = (stream_format_code & 0x2) ? 4 : 0; i < BANDS - 1; i++) {
481 iacc += chctx->bandWidthT[i];
482 summa += chctx->bandWidthT[i] * chctx->flcoeffs4[i];
483 }
484
485 if (!iacc)
486 return AVERROR_INVALIDDATA;
487
488 chctx->bandWidthT[BANDS - 1] = 0;
489 summa = (summa * 0.5 - freebits) / iacc;
490
491
492 for (i = 0; i < BANDS / 2; i++) {
493 rres = summer - freebits;
494 if ((rres >= -8) && (rres <= 8))
495 break;
496
497 summer = 0;
498 iacc = 0;
499
500 for (j = (stream_format_code & 0x2) ? 4 : 0; j < BANDS; j++) {
501 cwlen = av_clipf(((chctx->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6);
502
503 chctx->bitsBandT[j] = cwlen;
504 summer += chctx->bandWidthT[j] * cwlen;
505
506 if (cwlen > 0)
507 iacc += chctx->bandWidthT[j];
508 }
509
510 flg = t2;
511 t2 = 1;
512 if (freebits < summer)
513 t2 = -1;
514 if (i == 0)
515 flg = t2;
516 if (flg != t2)
517 t1++;
518
519 summa = (float)(summer - freebits) / ((t1 + 1) * iacc) + summa;
520 }
521
522 for (i = (stream_format_code & 0x2) ? 4 : 0; i < BANDS; i++) {
523 for (j = band_tab[i]; j < band_tab[i + 1]; j++)
524 chctx->CWlengthT[j] = chctx->bitsBandT[i];
525 }
526
527 if (freebits > summer) {
528 for (i = 0; i < BANDS; i++) {
529 workT[i] = (chctx->bitsBandT[i] == 6) ? -1.e20
530 : (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] - 0.415);
531 }
532
533 highest = 0.0;
534
535 do {
536 if (highest <= -1.e20)
537 break;
538
539 found_indx = 0;
540 highest = -1.e20;
541
542 for (i = 0; i < BANDS; i++) {
543 if (workT[i] > highest) {
544 highest = workT[i];
545 found_indx = i;
546 }
547 }
548
549 if (highest > -1.e20) {
550 workT[found_indx] -= 2.0;
551 if (++chctx->bitsBandT[found_indx] == 6)
552 workT[found_indx] = -1.e20;
553
554 for (j = band_tab[found_indx]; j < band_tab[found_indx + 1] && (freebits > summer); j++) {
555 chctx->CWlengthT[j]++;
556 summer++;
557 }
558 }
559 } while (freebits > summer);
560 }
561 if (freebits < summer) {
562 for (i = 0; i < BANDS; i++) {
563 workT[i] = chctx->bitsBandT[i] ? (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] + 1.585)
564 : 1.e20;
565 }
566 if (stream_format_code & 0x2) {
567 workT[0] = 1.e20;
568 workT[1] = 1.e20;
569 workT[2] = 1.e20;
570 workT[3] = 1.e20;
571 }
572 while (freebits < summer) {
573 lowest = 1.e10;
574 low_indx = 0;
575 for (i = 0; i < BANDS; i++) {
576 if (workT[i] < lowest) {
577 lowest = workT[i];
578 low_indx = i;
579 }
580 }
581 // if (lowest >= 1.e10)
582 // break;
583 workT[low_indx] = lowest + 2.0;
584
585 if (!--chctx->bitsBandT[low_indx])
586 workT[low_indx] = 1.e20;
587
588 for (j = band_tab[low_indx]; j < band_tab[low_indx+1] && (freebits < summer); j++) {
589 if (chctx->CWlengthT[j] > 0) {
590 chctx->CWlengthT[j]--;
591 summer--;
592 }
593 }
594 }
595 }
596 return 0;
597}
598
600{
601 int i, j;
602
603 memset(chctx->skipFlagBits, 0, sizeof(chctx->skipFlagBits));
604 memset(chctx->skipFlagCount, 0, sizeof(chctx->skipFlagCount));
605 for (i = 0; i < BANDS; i++) {
606 if (!chctx->bandFlagsBuf[i] || !chctx->bandWidthT[i])
607 continue;
608
609 if (!chctx->skipFlagRaw[i]) {
610 chctx->skipFlagBits[i] = band_tab[i + 1] - band_tab[i];
611
612 for (j = band_tab[i]; j < band_tab[i + 1]; j++) {
613 chctx->skipFlags[j] = get_bits1(&q->gb);
614 if (chctx->skipFlags[j])
615 chctx->skipFlagCount[i]++;
616 }
617 } else {
618 for (j = band_tab[i]; j < band_tab[i + 1] - 1; j += 2) {
619 if (!get_bits1(&q->gb)) { // 0
620 chctx->skipFlagBits[i]++;
621 chctx->skipFlags[j] = 1;
622 chctx->skipFlags[j + 1] = 1;
623 chctx->skipFlagCount[i] += 2;
624 } else {
625 if (get_bits1(&q->gb)) { // 11
626 chctx->skipFlagBits[i] += 2;
627 chctx->skipFlags[j] = 0;
628 chctx->skipFlags[j + 1] = 1;
629 chctx->skipFlagCount[i]++;
630 } else {
631 chctx->skipFlagBits[i] += 3;
632 chctx->skipFlags[j + 1] = 0;
633 if (!get_bits1(&q->gb)) { // 100
634 chctx->skipFlags[j] = 1;
635 chctx->skipFlagCount[i]++;
636 } else { // 101
637 chctx->skipFlags[j] = 0;
638 }
639 }
640 }
641 }
642
643 if (j < band_tab[i + 1]) {
644 chctx->skipFlagBits[i]++;
645 if ((chctx->skipFlags[j] = get_bits1(&q->gb)))
646 chctx->skipFlagCount[i]++;
647 }
648 }
649 }
650}
651
652/**
653 * Increase highest' band coefficient sizes as some bits won't be used
654 */
656 int summer)
657{
658 float workT[32];
659 int corrected = 0;
660 int i, j;
661 float highest = 0;
662 int found_indx = 0;
663
664 for (i = 0; i < BANDS; i++) {
665 workT[i] = (chctx->bitsBandT[i] == 6) ? -1.e20
666 : (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] - 0.415);
667 }
668
669 while (corrected < summer) {
670 if (highest <= -1.e20)
671 break;
672
673 highest = -1.e20;
674
675 for (i = 0; i < BANDS; i++) {
676 if (workT[i] > highest) {
677 highest = workT[i];
678 found_indx = i;
679 }
680 }
681
682 if (highest > -1.e20) {
683 workT[found_indx] -= 2.0;
684 if (++(chctx->bitsBandT[found_indx]) == 6)
685 workT[found_indx] = -1.e20;
686
687 for (j = band_tab[found_indx]; j < band_tab[found_indx+1] && (corrected < summer); j++) {
688 if (!chctx->skipFlags[j] && (chctx->CWlengthT[j] < 6)) {
689 chctx->CWlengthT[j]++;
690 corrected++;
691 }
692 }
693 }
694 }
695}
696
698 int stream_format_code)
699{
700 int i, j;
701 int middle_value, cw_len, max_size;
702 const float *quantizer;
703
704 for (i = 0; i < BANDS; i++) {
705 for (j = band_tab[i]; j < band_tab[i + 1]; j++) {
706 chctx->CWdecoded[j] = 0;
707 cw_len = chctx->CWlengthT[j];
708
709 if (cw_len <= 0 || chctx->skipFlags[j])
710 continue;
711
712 max_size = 1 << cw_len;
713 middle_value = max_size >> 1;
714
715 if (chctx->codewords[j] >= max_size || chctx->codewords[j] < 0)
716 return AVERROR_INVALIDDATA;
717
718 if (cw_len >= 4) {
719 quantizer = imc_quantizer2[(stream_format_code & 2) >> 1];
720 if (chctx->codewords[j] >= middle_value)
721 chctx->CWdecoded[j] = quantizer[chctx->codewords[j] - 8] * chctx->flcoeffs6[i];
722 else
723 chctx->CWdecoded[j] = -quantizer[max_size - chctx->codewords[j] - 8 - 1] * chctx->flcoeffs6[i];
724 }else{
725 quantizer = imc_quantizer1[((stream_format_code & 2) >> 1) | (chctx->bandFlagsBuf[i] << 1)];
726 if (chctx->codewords[j] >= middle_value)
727 chctx->CWdecoded[j] = quantizer[chctx->codewords[j] - 1] * chctx->flcoeffs6[i];
728 else
729 chctx->CWdecoded[j] = -quantizer[max_size - 2 - chctx->codewords[j]] * chctx->flcoeffs6[i];
730 }
731 }
732 }
733 return 0;
734}
735
736
738 IMCContext *q, IMCChannel *chctx)
739{
740 int i, j, cw_len, cw;
741
742 for (i = 0; i < BANDS; i++) {
743 if (!chctx->sumLenArr[i])
744 continue;
745 if (chctx->bandFlagsBuf[i] || chctx->bandWidthT[i]) {
746 for (j = band_tab[i]; j < band_tab[i + 1]; j++) {
747 cw_len = chctx->CWlengthT[j];
748 cw = 0;
749
750 if (cw_len && (!chctx->bandFlagsBuf[i] || !chctx->skipFlags[j])) {
751 if (get_bits_count(&q->gb) + cw_len > 512) {
752 av_log(avctx, AV_LOG_WARNING,
753 "Potential problem on band %i, coefficient %i"
754 ": cw_len=%i\n", i, j, cw_len);
755 } else
756 cw = get_bits(&q->gb, cw_len);
757 }
758
759 chctx->codewords[j] = cw;
760 }
761 }
762 }
763}
764
766{
767 int i, j;
768 int summer;
769
770 for (i = 0; i < BANDS; i++) {
771 chctx->sumLenArr[i] = 0;
772 chctx->skipFlagRaw[i] = 0;
773 for (j = band_tab[i]; j < band_tab[i + 1]; j++)
774 chctx->sumLenArr[i] += chctx->CWlengthT[j];
775 if (chctx->bandFlagsBuf[i])
776 if (((int)((band_tab[i + 1] - band_tab[i]) * 1.5) > chctx->sumLenArr[i]) && (chctx->sumLenArr[i] > 0))
777 chctx->skipFlagRaw[i] = 1;
778 }
779
780 imc_get_skip_coeff(q, chctx);
781
782 for (i = 0; i < BANDS; i++) {
783 chctx->flcoeffs6[i] = chctx->flcoeffs1[i];
784 /* band has flag set and at least one coded coefficient */
785 if (chctx->bandFlagsBuf[i] && (band_tab[i + 1] - band_tab[i]) != chctx->skipFlagCount[i]) {
786 chctx->flcoeffs6[i] *= q->sqrt_tab[ band_tab[i + 1] - band_tab[i]] /
787 q->sqrt_tab[(band_tab[i + 1] - band_tab[i] - chctx->skipFlagCount[i])];
788 }
789 }
790
791 /* calculate bits left, bits needed and adjust bit allocation */
792 summer = 0;
793
794 for (i = 0; i < BANDS; i++) {
795 if (chctx->bandFlagsBuf[i]) {
796 for (j = band_tab[i]; j < band_tab[i + 1]; j++) {
797 if (chctx->skipFlags[j]) {
798 summer += chctx->CWlengthT[j];
799 chctx->CWlengthT[j] = 0;
800 }
801 }
802 summer -= chctx->skipFlagBits[i];
803 }
804 }
805 imc_adjust_bit_allocation(q, chctx, summer);
806}
807
808static int imc_decode_block(AVCodecContext *avctx, IMCContext *q, int ch)
809{
810 int stream_format_code;
811 int imc_hdr, i, j, ret;
812 int flag;
813 int bits;
814 int bitscount;
815 IMCChannel *chctx = q->chctx + ch;
816
817
818 /* Check the frame header */
819 imc_hdr = get_bits(&q->gb, 9);
820 if (imc_hdr & 0x18) {
821 av_log(avctx, AV_LOG_ERROR, "frame header check failed!\n");
822 av_log(avctx, AV_LOG_ERROR, "got %X.\n", imc_hdr);
823 return AVERROR_INVALIDDATA;
824 }
825 stream_format_code = get_bits(&q->gb, 3);
826
827 if (stream_format_code & 0x04)
828 chctx->decoder_reset = 1;
829
830 if (chctx->decoder_reset) {
831 for (i = 0; i < BANDS; i++)
832 chctx->old_floor[i] = 1.0;
833 for (i = 0; i < COEFFS; i++)
834 chctx->CWdecoded[i] = 0;
835 chctx->decoder_reset = 0;
836 }
837
838 flag = get_bits1(&q->gb);
839 if (stream_format_code & 0x1)
840 imc_read_level_coeffs_raw(q, stream_format_code, chctx->levlCoeffBuf);
841 else
842 imc_read_level_coeffs(q, stream_format_code, chctx->levlCoeffBuf);
843
844 if (stream_format_code & 0x1)
846 chctx->flcoeffs1, chctx->flcoeffs2);
847 else if (stream_format_code & 0x4)
849 chctx->flcoeffs1, chctx->flcoeffs2);
850 else
852 chctx->flcoeffs1, chctx->flcoeffs2);
853
854 for(i=0; i<BANDS; i++) {
855 if(chctx->flcoeffs1[i] > INT_MAX) {
856 av_log(avctx, AV_LOG_ERROR, "scalefactor out of range\n");
857 return AVERROR_INVALIDDATA;
858 }
859 }
860
861 memcpy(chctx->old_floor, chctx->flcoeffs1, 32 * sizeof(float));
862
863 if (stream_format_code & 0x1) {
864 for (i = 0; i < BANDS; i++) {
865 chctx->bandWidthT[i] = band_tab[i + 1] - band_tab[i];
866 chctx->bandFlagsBuf[i] = 0;
867 chctx->flcoeffs3[i] = chctx->flcoeffs2[i] * 2;
868 chctx->flcoeffs5[i] = 1.0;
869 }
870 } else {
871 for (i = 0; i < BANDS; i++) {
872 if (chctx->levlCoeffBuf[i] == 16) {
873 chctx->bandWidthT[i] = 0;
874 } else
875 chctx->bandWidthT[i] = band_tab[i + 1] - band_tab[i];
876 }
877
878 memset(chctx->bandFlagsBuf, 0, BANDS * sizeof(int));
879 for (i = 0; i < BANDS - 1; i++)
880 if (chctx->bandWidthT[i])
881 chctx->bandFlagsBuf[i] = get_bits1(&q->gb);
882
883 imc_calculate_coeffs(q, chctx->flcoeffs1, chctx->flcoeffs2,
884 chctx->bandWidthT, chctx->flcoeffs3,
885 chctx->flcoeffs5);
886 }
887
888 bitscount = 0;
889 /* first 4 bands will be assigned 5 bits per coefficient */
890 if (stream_format_code & 0x2) {
891 bitscount += 15;
892
893 chctx->bitsBandT[0] = 5;
894 chctx->CWlengthT[0] = 5;
895 chctx->CWlengthT[1] = 5;
896 chctx->CWlengthT[2] = 5;
897 for (i = 1; i < 4; i++) {
898 if (stream_format_code & 0x1)
899 bits = 5;
900 else
901 bits = (chctx->levlCoeffBuf[i] == 16) ? 0 : 5;
902 chctx->bitsBandT[i] = bits;
903 for (j = band_tab[i]; j < band_tab[i + 1]; j++) {
904 chctx->CWlengthT[j] = bits;
905 bitscount += bits;
906 }
907 }
908 }
909 if (avctx->codec_id == AV_CODEC_ID_IAC) {
910 bitscount += !!chctx->bandWidthT[BANDS - 1];
911 if (!(stream_format_code & 0x2))
912 bitscount += 16;
913 }
914
915 if ((ret = bit_allocation(q, chctx, stream_format_code,
916 512 - bitscount - get_bits_count(&q->gb),
917 flag)) < 0) {
918 av_log(avctx, AV_LOG_ERROR, "Bit allocations failed\n");
919 chctx->decoder_reset = 1;
920 return ret;
921 }
922
923 if (stream_format_code & 0x1) {
924 for (i = 0; i < BANDS; i++)
925 chctx->skipFlags[i] = 0;
926 } else {
928 }
929
930 for (i = 0; i < BANDS; i++) {
931 chctx->sumLenArr[i] = 0;
932
933 for (j = band_tab[i]; j < band_tab[i + 1]; j++)
934 if (!chctx->skipFlags[j])
935 chctx->sumLenArr[i] += chctx->CWlengthT[j];
936 }
937
938 memset(chctx->codewords, 0, sizeof(chctx->codewords));
939
940 imc_get_coeffs(avctx, q, chctx);
941
942 if (inverse_quant_coeff(q, chctx, stream_format_code) < 0) {
943 av_log(avctx, AV_LOG_ERROR, "Inverse quantization of coefficients failed\n");
944 chctx->decoder_reset = 1;
945 return AVERROR_INVALIDDATA;
946 }
947
948 memset(chctx->skipFlags, 0, sizeof(chctx->skipFlags));
949
950 q->mdct_fn(q->mdct, q->temp, chctx->CWdecoded, sizeof(float));
952 q->mdct_sine_window, 128);
953 memcpy(chctx->prev_win, q->temp + 128, sizeof(float)*128);
954
955 return 0;
956}
957
959 int *got_frame_ptr, AVPacket *avpkt)
960{
961 const uint8_t *buf = avpkt->data;
962 int buf_size = avpkt->size;
963 int ret, i;
964
965 IMCContext *q = avctx->priv_data;
966
968
970
971 q->avctx = avctx;
972
973 if (buf_size < IMC_BLOCK_SIZE * avctx->ch_layout.nb_channels) {
974 av_log(avctx, AV_LOG_ERROR, "frame too small!\n");
975 return AVERROR_INVALIDDATA;
976 }
977
978 /* get output buffer */
979 frame->nb_samples = COEFFS;
980 if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
981 return ret;
982
983 for (i = 0; i < avctx->ch_layout.nb_channels; i++) {
984 q->out_samples = (float *)frame->extended_data[i];
985
986 q->bdsp.bswap16_buf(buf16, (const uint16_t *) buf, IMC_BLOCK_SIZE / 2);
987
988 init_get_bits(&q->gb, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8);
989
990 buf += IMC_BLOCK_SIZE;
991
992 if ((ret = imc_decode_block(avctx, q, i)) < 0)
993 return ret;
994 }
995
996 if (avctx->ch_layout.nb_channels == 2) {
997 q->fdsp->butterflies_float((float *)frame->extended_data[0],
998 (float *)frame->extended_data[1], COEFFS);
999 }
1000
1001 *got_frame_ptr = 1;
1002
1003 return IMC_BLOCK_SIZE * avctx->ch_layout.nb_channels;
1004}
1005
1007{
1008 IMCContext *q = avctx->priv_data;
1009
1010 av_free(q->fdsp);
1011 av_tx_uninit(&q->mdct);
1012
1013 return 0;
1014}
1015
1016static av_cold void flush(AVCodecContext *avctx)
1017{
1018 IMCContext *q = avctx->priv_data;
1019
1020 q->chctx[0].decoder_reset =
1021 q->chctx[1].decoder_reset = 1;
1022}
1023
1024#if CONFIG_IMC_DECODER
1025const FFCodec ff_imc_decoder = {
1026 .p.name = "imc",
1027 CODEC_LONG_NAME("IMC (Intel Music Coder)"),
1028 .p.type = AVMEDIA_TYPE_AUDIO,
1029 .p.id = AV_CODEC_ID_IMC,
1030 .priv_data_size = sizeof(IMCContext),
1034 .flush = flush,
1035 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
1036 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
1037};
1038#endif
1039#if CONFIG_IAC_DECODER
1040const FFCodec ff_iac_decoder = {
1041 .p.name = "iac",
1042 CODEC_LONG_NAME("IAC (Indeo Audio Coder)"),
1043 .p.type = AVMEDIA_TYPE_AUDIO,
1044 .p.id = AV_CODEC_ID_IAC,
1045 .priv_data_size = sizeof(IMCContext),
1049 .flush = flush,
1050 .p.capabilities = AV_CODEC_CAP_DR1,
1051 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
1052};
1053#endif
const FFCodec ff_imc_decoder
const FFCodec ff_iac_decoder
static av_cold void close(AVCodecParserContext *s)
Definition apv_parser.c:197
Libavcodec external API header.
#define flag(name)
Definition cbs_h264.c:60
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
Public libavutil channel layout APIs header.
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define av_clipf
Definition common.h:145
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition decode.c:1777
static AVFrame * frame
void(* flush)(AVBSFContext *ctx)
Definition dts2pts.c:610
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
static struct @346255127015250356166251341105367306144006377143 state
static const uint8_t bits[8]
Definition fastaudio.c:100
internal math functions header
static av_always_inline double ff_exp10(double x)
Compute 10^x for floating point values.
Definition ffmath.h:42
bitstream reader API header.
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
Definition get_bits.h:645
static unsigned int get_bits1(GetBitContext *s)
Definition get_bits.h:391
static int get_bits_count(const GetBitContext *s)
Definition get_bits.h:254
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition get_bits.h:337
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
Definition get_bits.h:517
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
Definition avcodec.h:322
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition codec.h:49
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition codec.h:94
@ AV_CODEC_ID_IAC
Definition codec_id.h:511
@ AV_CODEC_ID_IMC
Definition codec_id.h:480
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
Definition defs.h:40
#define AV_CHANNEL_LAYOUT_MONO
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition error.h:64
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition samplefmt.h:66
static const VLCElem * huffman_vlc[4][4]
Definition imc.c:110
#define BANDS
Definition imc.c:57
static int inverse_quant_coeff(IMCContext *q, IMCChannel *chctx, int stream_format_code)
Definition imc.c:697
#define COEFFS
Definition imc.c:58
static int imc_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Definition imc.c:958
#define IMC_BLOCK_SIZE
Definition imc.c:55
static void imc_decode_level_coefficients_raw(IMCContext *q, int *levlCoeffBuf, float *flcoeffs1, float *flcoeffs2)
Definition imc.c:398
static av_cold int imc_decode_close(AVCodecContext *avctx)
Definition imc.c:1006
static int bit_allocation(IMCContext *q, IMCChannel *chctx, int stream_format_code, int freebits, int flag)
Perform bit allocation depending on bits available.
Definition imc.c:423
static av_cold int imc_decode_init(AVCodecContext *avctx)
Definition imc.c:188
#define VLC_TABLES_SIZE
Definition imc.c:113
static void imc_calculate_coeffs(IMCContext *q, float *flcoeffs1, float *flcoeffs2, int *bandWidthT, float *flcoeffs3, float *flcoeffs5)
Definition imc.c:255
static void imc_read_level_coeffs(IMCContext *q, int stream_format_code, int *levlCoeffs)
Definition imc.c:310
static void imc_read_level_coeffs_raw(IMCContext *q, int stream_format_code, int *levlCoeffs)
Definition imc.c:333
static av_cold void iac_generate_tabs(IMCContext *q, int sampling_rate)
Definition imc.c:122
static void imc_decode_level_coefficients(IMCContext *q, int *levlCoeffBuf, float *flcoeffs1, float *flcoeffs2)
Definition imc.c:344
static double freq2bark(double freq)
Definition imc.c:117
static void imc_refine_bit_allocation(IMCContext *q, IMCChannel *chctx)
Definition imc.c:765
static av_cold void imc_init_static(void)
Definition imc.c:173
static VLCElem vlc_tables[VLC_TABLES_SIZE]
Definition imc.c:115
#define IMC_VLC_BITS
Definition imc.c:112
static void imc_decode_level_coefficients2(IMCContext *q, int *levlCoeffBuf, float *old_floor, float *flcoeffs1, float *flcoeffs2)
Definition imc.c:378
static void imc_get_coeffs(AVCodecContext *avctx, IMCContext *q, IMCChannel *chctx)
Definition imc.c:737
static int imc_decode_block(AVCodecContext *avctx, IMCContext *q, int ch)
Definition imc.c:808
static void imc_adjust_bit_allocation(IMCContext *q, IMCChannel *chctx, int summer)
Increase highest' band coefficient sizes as some bits won't be used.
Definition imc.c:655
static void imc_get_skip_coeff(IMCContext *q, IMCChannel *chctx)
Definition imc.c:599
static const int8_t cyclTab[32]
Definition imcdata.h:36
static const float imc_quantizer2[2][56]
Definition imcdata.h:66
static const float xTab[14]
Definition imcdata.h:84
static const float *const imc_exp_tab2
Definition imcdata.h:97
static const float imc_quantizer1[4][8]
Definition imcdata.h:59
static const uint8_t imc_huffman_syms[4][4][18]
Definition imcdata.h:142
static const uint8_t imc_huffman_lens[4][4][18]
Definition imcdata.h:115
static const uint8_t imc_cb_select[4][32]
Definition imcdata.h:100
static const float imc_exp_tab[32]
Definition imcdata.h:87
static const float imc_weights2[31]
Definition imcdata.h:53
static const int8_t cyclTab2[32]
Definition imcdata.h:42
static const uint8_t imc_huffman_sizes[4]
Definition imcdata.h:111
static const uint16_t band_tab[33]
Definition imcdata.h:29
static const float imc_weights1[31]
Definition imcdata.h:47
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition intra.c:278
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
Definition bswapdsp.c:37
#define av_cold
Definition attributes.h:117
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
Definition float_dsp.c:135
common internal API header
#define AVOnce
Definition thread.h:202
static int ff_thread_once(char *control, void(*routine)(void))
Definition thread.h:205
#define AV_ONCE_INIT
Definition thread.h:203
#define log2f(x)
Definition libm.h:411
#define exp2(x)
Definition libm.h:290
#define powf(x, y)
Definition libm.h:52
#define FFMAX(a, b)
Definition macros.h:47
Memory handling functions.
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
#define LOCAL_ALIGNED_16(t, v,...)
void ff_sine_window_init(float *window, int n)
Generate a sine window.
unsigned int pos
Definition spdifenc.c:431
An AVChannelLayout holds information about the channel layout of audio data.
int nb_channels
Number of channels in this layout.
main external API structure.
Definition avcodec.h:443
AVChannelLayout ch_layout
Audio channel layout.
Definition avcodec.h:1055
enum AVSampleFormat sample_fmt
audio sample format
Definition avcodec.h:1047
int sample_rate
samples per second
Definition avcodec.h:1040
int flags
AV_CODEC_FLAG_*.
Definition avcodec.h:500
enum AVCodecID codec_id
Definition avcodec.h:453
void * priv_data
Definition avcodec.h:470
void(* butterflies_float)(float *restrict v1, float *restrict v2, int len)
Calculate the sum and difference of two vectors of floats.
Definition float_dsp.h:164
void(* vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, int len)
Overlap/add with window function.
Definition float_dsp.h:119
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
This structure stores compressed data.
Definition packet.h:580
int size
Definition packet.h:604
uint8_t * data
Definition packet.h:603
void(* bswap16_buf)(uint16_t *dst, const uint16_t *src, int len)
Definition bswapdsp.h:26
float prev_win[128]
Definition imc.c:83
int levlCoeffBuf[BANDS]
Definition imc.c:73
int decoder_reset
Definition imc.c:82
float old_floor[BANDS]
Definition imc.c:61
int codewords[COEFFS]
raw codewords read from bitstream
Definition imc.c:80
int skipFlagBits[BANDS]
bits used to code skip flags
Definition imc.c:77
float flcoeffs5[BANDS]
Definition imc.c:66
int CWlengthT[COEFFS]
how many bits in each codeword
Definition imc.c:72
int skipFlags[COEFFS]
skip coefficient decoding or not
Definition imc.c:79
float flcoeffs3[BANDS]
Definition imc.c:64
float flcoeffs6[BANDS]
Definition imc.c:67
float flcoeffs4[BANDS]
Definition imc.c:65
float flcoeffs1[BANDS]
Definition imc.c:62
int skipFlagRaw[BANDS]
skip flags are stored in raw form or not
Definition imc.c:76
int bandFlagsBuf[BANDS]
flags for each band
Definition imc.c:74
float flcoeffs2[BANDS]
Definition imc.c:63
float CWdecoded[COEFFS]
Definition imc.c:68
int bandWidthT[BANDS]
codewords per band
Definition imc.c:70
int skipFlagCount[BANDS]
skipped coefficients per band
Definition imc.c:78
int bitsBandT[BANDS]
how many bits per codeword in band
Definition imc.c:71
int sumLenArr[BANDS]
bits for all coeffs in band
Definition imc.c:75
int coef0_pos
Definition imc.c:102
int8_t cyclTab2[32]
Definition imc.c:104
float weights2[31]
Definition imc.c:105
IMCChannel chctx[2]
Definition imc.c:87
AVCodecContext * avctx
Definition imc.c:107
AVFloatDSPContext * fdsp
Definition imc.c:95
float temp[256]
Definition imc.c:100
float weights1[31]
Definition imc.c:105
float * out_samples
Definition imc.c:99
float sqrt_tab[30]
Definition imc.c:92
av_tx_fn mdct_fn
Definition imc.c:98
BswapDSPContext bdsp
Definition imc.c:96
AVTXContext * mdct
Definition imc.c:97
float mdct_sine_window[COEFFS]
MDCT tables.
Definition imc.c:90
GetBitContext gb
Definition imc.c:93
int8_t cyclTab[32]
Definition imc.c:104
Definition vlc.h:32
For static VLCs, the number of bits can often be hardcoded at each get_vlc2() callsite.
Definition vlc.h:220
uint8_t level
Definition svq3.c:208
#define av_free(p)
#define avpriv_request_sample(...)
#define av_log(a,...)
static uint8_t tmp[40]
Definition aes_ctr.c:52
uint16_t buf16[PRNG_CACHE_SIZE > > 1]
Definition utils.c:180
av_cold void av_tx_uninit(AVTXContext **ctx)
Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL.
Definition tx.c:295
av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags)
Initialize a transform context with the given configuration (i)MDCTs with an odd length are currently...
Definition tx.c:903
@ AV_TX_FLOAT_MDCT
Standard MDCT with a sample data type of float, double or int32_t, respectively.
Definition tx.h:68
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
Definition tx.h:151
static double limit(double x)
av_cold const VLCElem * ff_vlc_init_tables_from_lengths(VLCInitState *state, int nb_bits, int nb_codes, const int8_t *lens, int lens_wrap, const void *symbols, int symbols_wrap, int symbols_size, int offset, int flags)
Definition vlc.c:366
#define VLC_INIT_STATE(_table)
Definition vlc.h:225