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 if (freebits < 0)
443 return AVERROR_INVALIDDATA;
444
445 for (i = 0; i < BANDS; i++)
446 highest = FFMAX(highest, chctx->flcoeffs1[i]);
447
448 for (i = 0; i < BANDS - 1; i++) {
449 if (chctx->flcoeffs5[i] <= 0) {
450 av_log(q->avctx, AV_LOG_ERROR, "flcoeffs5 %f invalid\n", chctx->flcoeffs5[i]);
451 return AVERROR_INVALIDDATA;
452 }
453 chctx->flcoeffs4[i] = chctx->flcoeffs3[i] - log2f(chctx->flcoeffs5[i]);
454 }
455 chctx->flcoeffs4[BANDS - 1] = limit;
456
457 highest = highest * 0.25;
458
459 for (i = 0; i < BANDS; i++) {
460 indx = -1;
461 if ((band_tab[i + 1] - band_tab[i]) == chctx->bandWidthT[i])
462 indx = 0;
463
464 if ((band_tab[i + 1] - band_tab[i]) > chctx->bandWidthT[i])
465 indx = 1;
466
467 if (((band_tab[i + 1] - band_tab[i]) / 2) >= chctx->bandWidthT[i])
468 indx = 2;
469
470 if (indx == -1)
471 return AVERROR_INVALIDDATA;
472
473 chctx->flcoeffs4[i] += xTab[(indx * 2 + (chctx->flcoeffs1[i] < highest)) * 2 + flag];
474 }
475
476 if (stream_format_code & 0x2) {
477 chctx->flcoeffs4[0] = limit;
478 chctx->flcoeffs4[1] = limit;
479 chctx->flcoeffs4[2] = limit;
480 chctx->flcoeffs4[3] = limit;
481 }
482
483 for (i = (stream_format_code & 0x2) ? 4 : 0; i < BANDS - 1; i++) {
484 iacc += chctx->bandWidthT[i];
485 summa += chctx->bandWidthT[i] * chctx->flcoeffs4[i];
486 }
487
488 if (!iacc)
489 return AVERROR_INVALIDDATA;
490
491 chctx->bandWidthT[BANDS - 1] = 0;
492 summa = (summa * 0.5 - freebits) / iacc;
493
494
495 for (i = 0; i < BANDS / 2; i++) {
496 rres = summer - freebits;
497 if ((rres >= -8) && (rres <= 8))
498 break;
499
500 summer = 0;
501 iacc = 0;
502
503 for (j = (stream_format_code & 0x2) ? 4 : 0; j < BANDS; j++) {
504 cwlen = av_clipf(((chctx->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6);
505
506 chctx->bitsBandT[j] = cwlen;
507 summer += chctx->bandWidthT[j] * cwlen;
508
509 if (cwlen > 0)
510 iacc += chctx->bandWidthT[j];
511 }
512
513 flg = t2;
514 t2 = 1;
515 if (freebits < summer)
516 t2 = -1;
517 if (i == 0)
518 flg = t2;
519 if (flg != t2)
520 t1++;
521
522 summa = (float)(summer - freebits) / ((t1 + 1) * iacc) + summa;
523 }
524
525 for (i = (stream_format_code & 0x2) ? 4 : 0; i < BANDS; i++) {
526 for (j = band_tab[i]; j < band_tab[i + 1]; j++)
527 chctx->CWlengthT[j] = chctx->bitsBandT[i];
528 }
529
530 if (freebits > summer) {
531 for (i = 0; i < BANDS; i++) {
532 workT[i] = (chctx->bitsBandT[i] == 6) ? -1.e20
533 : (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] - 0.415);
534 }
535
536 highest = 0.0;
537
538 do {
539 if (highest <= -1.e20)
540 break;
541
542 found_indx = 0;
543 highest = -1.e20;
544
545 for (i = 0; i < BANDS; i++) {
546 if (workT[i] > highest) {
547 highest = workT[i];
548 found_indx = i;
549 }
550 }
551
552 if (highest > -1.e20) {
553 workT[found_indx] -= 2.0;
554 if (++chctx->bitsBandT[found_indx] == 6)
555 workT[found_indx] = -1.e20;
556
557 for (j = band_tab[found_indx]; j < band_tab[found_indx + 1] && (freebits > summer); j++) {
558 chctx->CWlengthT[j]++;
559 summer++;
560 }
561 }
562 } while (freebits > summer);
563 }
564 if (freebits < summer) {
565 for (i = 0; i < BANDS; i++) {
566 workT[i] = chctx->bitsBandT[i] ? (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] + 1.585)
567 : 1.e20;
568 }
569 if (stream_format_code & 0x2) {
570 workT[0] = 1.e20;
571 workT[1] = 1.e20;
572 workT[2] = 1.e20;
573 workT[3] = 1.e20;
574 }
575 while (freebits < summer) {
576 lowest = 1.e10;
577 low_indx = 0;
578 for (i = 0; i < BANDS; i++) {
579 if (workT[i] < lowest) {
580 lowest = workT[i];
581 low_indx = i;
582 }
583 }
584 // if (lowest >= 1.e10)
585 // break;
586 workT[low_indx] = lowest + 2.0;
587
588 if (!--chctx->bitsBandT[low_indx])
589 workT[low_indx] = 1.e20;
590
591 for (j = band_tab[low_indx]; j < band_tab[low_indx+1] && (freebits < summer); j++) {
592 if (chctx->CWlengthT[j] > 0) {
593 chctx->CWlengthT[j]--;
594 summer--;
595 }
596 }
597 }
598 }
599 return 0;
600}
601
603{
604 int i, j;
605
606 memset(chctx->skipFlagBits, 0, sizeof(chctx->skipFlagBits));
607 memset(chctx->skipFlagCount, 0, sizeof(chctx->skipFlagCount));
608 for (i = 0; i < BANDS; i++) {
609 if (!chctx->bandFlagsBuf[i] || !chctx->bandWidthT[i])
610 continue;
611
612 if (!chctx->skipFlagRaw[i]) {
613 chctx->skipFlagBits[i] = band_tab[i + 1] - band_tab[i];
614
615 for (j = band_tab[i]; j < band_tab[i + 1]; j++) {
616 chctx->skipFlags[j] = get_bits1(&q->gb);
617 if (chctx->skipFlags[j])
618 chctx->skipFlagCount[i]++;
619 }
620 } else {
621 for (j = band_tab[i]; j < band_tab[i + 1] - 1; j += 2) {
622 if (!get_bits1(&q->gb)) { // 0
623 chctx->skipFlagBits[i]++;
624 chctx->skipFlags[j] = 1;
625 chctx->skipFlags[j + 1] = 1;
626 chctx->skipFlagCount[i] += 2;
627 } else {
628 if (get_bits1(&q->gb)) { // 11
629 chctx->skipFlagBits[i] += 2;
630 chctx->skipFlags[j] = 0;
631 chctx->skipFlags[j + 1] = 1;
632 chctx->skipFlagCount[i]++;
633 } else {
634 chctx->skipFlagBits[i] += 3;
635 chctx->skipFlags[j + 1] = 0;
636 if (!get_bits1(&q->gb)) { // 100
637 chctx->skipFlags[j] = 1;
638 chctx->skipFlagCount[i]++;
639 } else { // 101
640 chctx->skipFlags[j] = 0;
641 }
642 }
643 }
644 }
645
646 if (j < band_tab[i + 1]) {
647 chctx->skipFlagBits[i]++;
648 if ((chctx->skipFlags[j] = get_bits1(&q->gb)))
649 chctx->skipFlagCount[i]++;
650 }
651 }
652 }
653}
654
655/**
656 * Increase highest' band coefficient sizes as some bits won't be used
657 */
659 int summer)
660{
661 float workT[32];
662 int corrected = 0;
663 int i, j;
664 float highest = 0;
665 int found_indx = 0;
666
667 for (i = 0; i < BANDS; i++) {
668 workT[i] = (chctx->bitsBandT[i] == 6) ? -1.e20
669 : (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] - 0.415);
670 }
671
672 while (corrected < summer) {
673 if (highest <= -1.e20)
674 break;
675
676 highest = -1.e20;
677
678 for (i = 0; i < BANDS; i++) {
679 if (workT[i] > highest) {
680 highest = workT[i];
681 found_indx = i;
682 }
683 }
684
685 if (highest > -1.e20) {
686 workT[found_indx] -= 2.0;
687 if (++(chctx->bitsBandT[found_indx]) == 6)
688 workT[found_indx] = -1.e20;
689
690 for (j = band_tab[found_indx]; j < band_tab[found_indx+1] && (corrected < summer); j++) {
691 if (!chctx->skipFlags[j] && (chctx->CWlengthT[j] < 6)) {
692 chctx->CWlengthT[j]++;
693 corrected++;
694 }
695 }
696 }
697 }
698}
699
701 int stream_format_code)
702{
703 int i, j;
704 int middle_value, cw_len, max_size;
705 const float *quantizer;
706
707 for (i = 0; i < BANDS; i++) {
708 for (j = band_tab[i]; j < band_tab[i + 1]; j++) {
709 chctx->CWdecoded[j] = 0;
710 cw_len = chctx->CWlengthT[j];
711
712 if (cw_len <= 0 || chctx->skipFlags[j])
713 continue;
714
715 max_size = 1 << cw_len;
716 middle_value = max_size >> 1;
717
718 if (chctx->codewords[j] >= max_size || chctx->codewords[j] < 0)
719 return AVERROR_INVALIDDATA;
720
721 if (cw_len >= 4) {
722 quantizer = imc_quantizer2[(stream_format_code & 2) >> 1];
723 if (chctx->codewords[j] >= middle_value)
724 chctx->CWdecoded[j] = quantizer[chctx->codewords[j] - 8] * chctx->flcoeffs6[i];
725 else
726 chctx->CWdecoded[j] = -quantizer[max_size - chctx->codewords[j] - 8 - 1] * chctx->flcoeffs6[i];
727 }else{
728 quantizer = imc_quantizer1[((stream_format_code & 2) >> 1) | (chctx->bandFlagsBuf[i] << 1)];
729 if (chctx->codewords[j] >= middle_value)
730 chctx->CWdecoded[j] = quantizer[chctx->codewords[j] - 1] * chctx->flcoeffs6[i];
731 else
732 chctx->CWdecoded[j] = -quantizer[max_size - 2 - chctx->codewords[j]] * chctx->flcoeffs6[i];
733 }
734 }
735 }
736 return 0;
737}
738
739
741 IMCContext *q, IMCChannel *chctx)
742{
743 int i, j, cw_len, cw;
744
745 for (i = 0; i < BANDS; i++) {
746 if (!chctx->sumLenArr[i])
747 continue;
748 if (chctx->bandFlagsBuf[i] || chctx->bandWidthT[i]) {
749 for (j = band_tab[i]; j < band_tab[i + 1]; j++) {
750 cw_len = chctx->CWlengthT[j];
751 cw = 0;
752
753 if (cw_len && (!chctx->bandFlagsBuf[i] || !chctx->skipFlags[j])) {
754 if (get_bits_count(&q->gb) + cw_len > 512) {
755 av_log(avctx, AV_LOG_WARNING,
756 "Potential problem on band %i, coefficient %i"
757 ": cw_len=%i\n", i, j, cw_len);
758 } else
759 cw = get_bits(&q->gb, cw_len);
760 }
761
762 chctx->codewords[j] = cw;
763 }
764 }
765 }
766}
767
769{
770 int i, j;
771 int summer;
772
773 for (i = 0; i < BANDS; i++) {
774 chctx->sumLenArr[i] = 0;
775 chctx->skipFlagRaw[i] = 0;
776 for (j = band_tab[i]; j < band_tab[i + 1]; j++)
777 chctx->sumLenArr[i] += chctx->CWlengthT[j];
778 if (chctx->bandFlagsBuf[i])
779 if (((int)((band_tab[i + 1] - band_tab[i]) * 1.5) > chctx->sumLenArr[i]) && (chctx->sumLenArr[i] > 0))
780 chctx->skipFlagRaw[i] = 1;
781 }
782
783 imc_get_skip_coeff(q, chctx);
784
785 for (i = 0; i < BANDS; i++) {
786 chctx->flcoeffs6[i] = chctx->flcoeffs1[i];
787 /* band has flag set and at least one coded coefficient */
788 if (chctx->bandFlagsBuf[i] && (band_tab[i + 1] - band_tab[i]) != chctx->skipFlagCount[i]) {
789 chctx->flcoeffs6[i] *= q->sqrt_tab[ band_tab[i + 1] - band_tab[i]] /
790 q->sqrt_tab[(band_tab[i + 1] - band_tab[i] - chctx->skipFlagCount[i])];
791 }
792 }
793
794 /* calculate bits left, bits needed and adjust bit allocation */
795 summer = 0;
796
797 for (i = 0; i < BANDS; i++) {
798 if (chctx->bandFlagsBuf[i]) {
799 for (j = band_tab[i]; j < band_tab[i + 1]; j++) {
800 if (chctx->skipFlags[j]) {
801 summer += chctx->CWlengthT[j];
802 chctx->CWlengthT[j] = 0;
803 }
804 }
805 summer -= chctx->skipFlagBits[i];
806 }
807 }
808 imc_adjust_bit_allocation(q, chctx, summer);
809}
810
811static int imc_decode_block(AVCodecContext *avctx, IMCContext *q, int ch)
812{
813 int stream_format_code;
814 int imc_hdr, i, j, ret;
815 int flag;
816 int bits;
817 int bitscount;
818 IMCChannel *chctx = q->chctx + ch;
819
820
821 /* Check the frame header */
822 imc_hdr = get_bits(&q->gb, 9);
823 if (imc_hdr & 0x18) {
824 av_log(avctx, AV_LOG_ERROR, "frame header check failed!\n");
825 av_log(avctx, AV_LOG_ERROR, "got %X.\n", imc_hdr);
826 return AVERROR_INVALIDDATA;
827 }
828 stream_format_code = get_bits(&q->gb, 3);
829
830 if (stream_format_code & 0x04)
831 chctx->decoder_reset = 1;
832
833 if (chctx->decoder_reset) {
834 for (i = 0; i < BANDS; i++)
835 chctx->old_floor[i] = 1.0;
836 for (i = 0; i < COEFFS; i++)
837 chctx->CWdecoded[i] = 0;
838 chctx->decoder_reset = 0;
839 }
840
841 flag = get_bits1(&q->gb);
842 if (stream_format_code & 0x1)
843 imc_read_level_coeffs_raw(q, stream_format_code, chctx->levlCoeffBuf);
844 else
845 imc_read_level_coeffs(q, stream_format_code, chctx->levlCoeffBuf);
846
847 if (stream_format_code & 0x1)
849 chctx->flcoeffs1, chctx->flcoeffs2);
850 else if (stream_format_code & 0x4)
852 chctx->flcoeffs1, chctx->flcoeffs2);
853 else
855 chctx->flcoeffs1, chctx->flcoeffs2);
856
857 for(i=0; i<BANDS; i++) {
858 if(chctx->flcoeffs1[i] > INT_MAX) {
859 av_log(avctx, AV_LOG_ERROR, "scalefactor out of range\n");
860 return AVERROR_INVALIDDATA;
861 }
862 }
863
864 memcpy(chctx->old_floor, chctx->flcoeffs1, 32 * sizeof(float));
865
866 if (stream_format_code & 0x1) {
867 for (i = 0; i < BANDS; i++) {
868 chctx->bandWidthT[i] = band_tab[i + 1] - band_tab[i];
869 chctx->bandFlagsBuf[i] = 0;
870 chctx->flcoeffs3[i] = chctx->flcoeffs2[i] * 2;
871 chctx->flcoeffs5[i] = 1.0;
872 }
873 } else {
874 for (i = 0; i < BANDS; i++) {
875 if (chctx->levlCoeffBuf[i] == 16) {
876 chctx->bandWidthT[i] = 0;
877 } else
878 chctx->bandWidthT[i] = band_tab[i + 1] - band_tab[i];
879 }
880
881 memset(chctx->bandFlagsBuf, 0, BANDS * sizeof(int));
882 for (i = 0; i < BANDS - 1; i++)
883 if (chctx->bandWidthT[i])
884 chctx->bandFlagsBuf[i] = get_bits1(&q->gb);
885
886 imc_calculate_coeffs(q, chctx->flcoeffs1, chctx->flcoeffs2,
887 chctx->bandWidthT, chctx->flcoeffs3,
888 chctx->flcoeffs5);
889 }
890
891 bitscount = 0;
892 /* first 4 bands will be assigned 5 bits per coefficient */
893 if (stream_format_code & 0x2) {
894 bitscount += 15;
895
896 chctx->bitsBandT[0] = 5;
897 chctx->CWlengthT[0] = 5;
898 chctx->CWlengthT[1] = 5;
899 chctx->CWlengthT[2] = 5;
900 for (i = 1; i < 4; i++) {
901 if (stream_format_code & 0x1)
902 bits = 5;
903 else
904 bits = (chctx->levlCoeffBuf[i] == 16) ? 0 : 5;
905 chctx->bitsBandT[i] = bits;
906 for (j = band_tab[i]; j < band_tab[i + 1]; j++) {
907 chctx->CWlengthT[j] = bits;
908 bitscount += bits;
909 }
910 }
911 }
912 if (avctx->codec_id == AV_CODEC_ID_IAC) {
913 bitscount += !!chctx->bandWidthT[BANDS - 1];
914 if (!(stream_format_code & 0x2))
915 bitscount += 16;
916 }
917
918 if ((ret = bit_allocation(q, chctx, stream_format_code,
919 512 - bitscount - get_bits_count(&q->gb),
920 flag)) < 0) {
921 av_log(avctx, AV_LOG_ERROR, "Bit allocations failed\n");
922 chctx->decoder_reset = 1;
923 return ret;
924 }
925
926 if (stream_format_code & 0x1) {
927 for (i = 0; i < BANDS; i++)
928 chctx->skipFlags[i] = 0;
929 } else {
931 }
932
933 for (i = 0; i < BANDS; i++) {
934 chctx->sumLenArr[i] = 0;
935
936 for (j = band_tab[i]; j < band_tab[i + 1]; j++)
937 if (!chctx->skipFlags[j])
938 chctx->sumLenArr[i] += chctx->CWlengthT[j];
939 }
940
941 memset(chctx->codewords, 0, sizeof(chctx->codewords));
942
943 imc_get_coeffs(avctx, q, chctx);
944
945 if (inverse_quant_coeff(q, chctx, stream_format_code) < 0) {
946 av_log(avctx, AV_LOG_ERROR, "Inverse quantization of coefficients failed\n");
947 chctx->decoder_reset = 1;
948 return AVERROR_INVALIDDATA;
949 }
950
951 memset(chctx->skipFlags, 0, sizeof(chctx->skipFlags));
952
953 q->mdct_fn(q->mdct, q->temp, chctx->CWdecoded, sizeof(float));
955 q->mdct_sine_window, 128);
956 memcpy(chctx->prev_win, q->temp + 128, sizeof(float)*128);
957
958 return 0;
959}
960
962 int *got_frame_ptr, AVPacket *avpkt)
963{
964 const uint8_t *buf = avpkt->data;
965 int buf_size = avpkt->size;
966 int ret, i;
967
968 IMCContext *q = avctx->priv_data;
969
971
973
974 q->avctx = avctx;
975
976 if (buf_size < IMC_BLOCK_SIZE * avctx->ch_layout.nb_channels) {
977 av_log(avctx, AV_LOG_ERROR, "frame too small!\n");
978 return AVERROR_INVALIDDATA;
979 }
980
981 /* get output buffer */
982 frame->nb_samples = COEFFS;
983 if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
984 return ret;
985
986 for (i = 0; i < avctx->ch_layout.nb_channels; i++) {
987 q->out_samples = (float *)frame->extended_data[i];
988
989 q->bdsp.bswap16_buf(buf16, (const uint16_t *) buf, IMC_BLOCK_SIZE / 2);
990
991 init_get_bits(&q->gb, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8);
992
993 buf += IMC_BLOCK_SIZE;
994
995 if ((ret = imc_decode_block(avctx, q, i)) < 0)
996 return ret;
997 }
998
999 if (avctx->ch_layout.nb_channels == 2) {
1000 q->fdsp->butterflies_float((float *)frame->extended_data[0],
1001 (float *)frame->extended_data[1], COEFFS);
1002 }
1003
1004 *got_frame_ptr = 1;
1005
1006 return IMC_BLOCK_SIZE * avctx->ch_layout.nb_channels;
1007}
1008
1010{
1011 IMCContext *q = avctx->priv_data;
1012
1013 av_free(q->fdsp);
1014 av_tx_uninit(&q->mdct);
1015
1016 return 0;
1017}
1018
1019static av_cold void flush(AVCodecContext *avctx)
1020{
1021 IMCContext *q = avctx->priv_data;
1022
1023 q->chctx[0].decoder_reset =
1024 q->chctx[1].decoder_reset = 1;
1025}
1026
1027#if CONFIG_IMC_DECODER
1028const FFCodec ff_imc_decoder = {
1029 .p.name = "imc",
1030 CODEC_LONG_NAME("IMC (Intel Music Coder)"),
1031 .p.type = AVMEDIA_TYPE_AUDIO,
1032 .p.id = AV_CODEC_ID_IMC,
1033 .priv_data_size = sizeof(IMCContext),
1037 .flush = flush,
1038 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
1039 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
1040};
1041#endif
1042#if CONFIG_IAC_DECODER
1043const FFCodec ff_iac_decoder = {
1044 .p.name = "iac",
1045 CODEC_LONG_NAME("IAC (Indeo Audio Coder)"),
1046 .p.type = AVMEDIA_TYPE_AUDIO,
1047 .p.id = AV_CODEC_ID_IAC,
1048 .priv_data_size = sizeof(IMCContext),
1052 .flush = flush,
1053 .p.capabilities = AV_CODEC_CAP_DR1,
1054 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
1055};
1056#endif
const FFCodec ff_imc_decoder
const FFCodec ff_iac_decoder
#define log2f(x)
Definition math.h:27
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:1814
static AVFrame * frame
void(* flush)(AVBSFContext *ctx)
Definition dts2pts.c:615
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:613
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:44
int ret
Definition ffplay.c:391
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:517
@ AV_CODEC_ID_IMC
Definition codec_id.h:486
#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 av_always_inline void scale(vec_s32 res[4], vec_s16 res_packed[2], const int shift)
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:700
#define COEFFS
Definition imc.c:58
static int imc_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Definition imc.c:961
#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:1009
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:768
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:740
static int imc_decode_block(AVCodecContext *avctx, IMCContext *q, int ch)
Definition imc.c:811
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:658
static void imc_get_skip_coeff(IMCContext *q, IMCChannel *chctx)
Definition imc.c:602
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
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
Definition bswapdsp.c:37
av_cold void CBS_FUNC close(CodedBitstreamContext **ctx_ptr)
Close a context and free all internal state.
Definition cbs.c:118
#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 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:1059
enum AVSampleFormat sample_fmt
audio sample format
Definition avcodec.h:1051
int sample_rate
samples per second
Definition avcodec.h:1044
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:479
This structure stores compressed data.
Definition packet.h:587
int size
Definition packet.h:611
uint8_t * data
Definition packet.h:610
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
static struct @232240247175332074307271266321204261331170211232 state
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