1 /*
2 * DCA encoder
3 * Copyright (C) 2008-2012 Alexander E. Patrakov
4 * 2010 Benjamin Larsson
5 * 2011 Xiang Wang
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
35
36 #define MAX_CHANNELS 6
37 #define DCA_MAX_FRAME_SIZE 16384
38 #define DCA_HEADER_SIZE 13
39 #define DCA_LFE_SAMPLES 8
40
41 #define DCAENC_SUBBANDS 32
43 #define SUBSUBFRAMES 2
44 #define SUBBAND_SAMPLES (SUBFRAMES * SUBSUBFRAMES * 8)
46
63
79
87
88 /* Transfer function of outer and middle ear, Hz -> dB */
89 static double hom(
double f)
90 {
91 double f1 = f / 1000;
92
93 return -3.64 * pow(f1, -0.8)
94 + 6.8 *
exp(-0.6 * (f1 - 3.4) * (f1 - 3.4))
95 - 6.0 *
exp(-0.15 * (f1 - 8.7) * (f1 - 8.7))
96 - 0.0006 * (f1 * f1) * (f1 * f1);
97 }
98
100 {
101 double h = (f -
fc[i]) /
erb[i];
102
105 return 20 * log10(h);
106 }
107
109 {
112 int i, min_frame_bits;
113
120
121 if (!layout) {
123 "encoder will guess the layout, but it "
124 "might be incorrect.\n");
126 }
127 switch (layout) {
133 default:
136 }
137
141 } else {
143 }
144
145 for (i = 0; i < 9; i++) {
147 break;
148 }
149 if (i == 9)
152
156 }
158 ;
164
166
168
170 int j, k;
171
175 for (i = 1; i < 512; i++) {
180 }
181 for (i = 0; i < 2048; i++) {
183 }
184
185 for (k = 0; k < 32; k++) {
186 for (j = 0; j < 8; j++) {
189 }
190 }
191
192 for (i = 0; i < 512; i++) {
195 }
196
197 for (i = 0; i < 9; i++) {
198 for (j = 0; j <
AUBANDS; j++) {
199 for (k = 0; k < 256; k++) {
201
203 }
204 }
205 }
206
207 for (i = 0; i < 256; i++) {
208 double add = 1 +
ff_exp10(-0.01 * i);
210 }
211 for (j = 0; j < 8; j++) {
212 double accum = 0;
213 for (i = 0; i < 512; i++) {
215 accum += reconst * cos(2 *
M_PI * (i + 0.5 - 256) * (j + 0.5) / 512);
216 }
218 }
219 for (j = 0; j < 8; j++) {
220 double accum = 0;
221 for (i = 0; i < 512; i++) {
223 accum += reconst * cos(2 *
M_PI * (i + 0.5 - 256) * (j + 0.5) / 512);
224 }
226 }
227 }
228 return 0;
229 }
230
232 {
234 }
235
237 {
238 return cos_t(x - 512);
239 }
240
242 {
243 return (a + 1) >> 1;
244 }
245
247 {
248 int64_t
r = (int64_t)a * b + 0x80000000ULL;
249 return r >> 32;
250 }
251
253 {
254 int ch, subs, i, k, j;
255
257 /* History is copied because it is also needed for PSY */
259 int hist_start = 0;
261
262 for (i = 0; i < 512; i++)
264
269
270 /* Calculate the convolutions at once */
271 for (i = 0; i < 64; i++)
272 accum[i] = 0;
273
274 for (k = 0, i = hist_start, j = 0;
275 i < 512; k = (k + 1) & 63, i++, j++)
277 for (i = 0; i < hist_start; k = (k + 1) & 63, i++, j++)
279
280 for (k = 16; k < 32; k++)
281 accum[k] = accum[k] - accum[31 - k];
282 for (k = 32; k < 48; k++)
283 accum[k] = accum[k] + accum[95 - k];
284
285 for (band = 0; band < 32; band++) {
286 resp = 0;
287 for (i = 16; i < 48; i++) {
288 int s = (2 * band + 1) * (2 * (i + 16) + 1);
290 }
291
292 c->
subband[subs][
band][ch] = ((band + 1) & 2) ? -resp : resp;
293 }
294
295 /* Copy in 32 new samples from input */
296 for (i = 0; i < 32; i++)
297 hist[i + hist_start] = input[(subs * 32 + i) * c->
channels + chi];
298 hist_start = (hist_start + 32) & 511;
299 }
300 }
301 }
302
304 {
305 /* FIXME: make 128x LFE downsampling possible */
307 int i, j, lfes;
310 int hist_start = 0;
311
312 for (i = 0; i < 512; i++)
314
316 /* Calculate the convolution */
317 accum = 0;
318
319 for (i = hist_start, j = 0; i < 512; i++, j++)
321 for (i = 0; i < hist_start; i++, j++)
323
325
326 /* Copy in 64 new samples from input */
327 for (i = 0; i < 64; i++)
328 hist[i + hist_start] = input[(lfes * 64 + i) * c->
channels + lfech];
329
330 hist_start = (hist_start + 64) & 511;
331 }
332 }
333
338
340 {
342 int i, j, k, l;
343
344 /* do two transforms in parallel */
345 for (i = 0; i < 256; i++) {
346 /* Apply the Hann window */
347 rin[i].
re =
mul32(in[2 * i], 0x3fffffff - (
cos_t(8 * i + 2) >> 1));
348 rin[i].
im =
mul32(in[2 * i + 1], 0x3fffffff - (
cos_t(8 * i + 6) >> 1));
349 }
350 /* pre-rotation */
351 for (i = 0; i < 256; i++) {
356 }
357
358 for (j = 256, l = 1; j != 1; j >>= 1, l <<= 1) {
359 for (k = 0; k < 256; k += j) {
360 for (i = k; i < k + j / 2; i++) {
362 int t = 8 * l * i;
363
364 sum.
re = buf[i].
re + buf[i + j / 2].
re;
365 sum.
im = buf[i].
im + buf[i + j / 2].
im;
366
367 diff.
re = buf[i].
re - buf[i + j / 2].
re;
368 diff.
im = buf[i].
im - buf[i + j / 2].
im;
369
372
377 }
378 }
379 }
380 /* post-rotation */
381 for (i = 0; i < 256; i++) {
387 }
388 for (i = 0; i < 256; i++) {
389 /* separate the results of the two transforms */
391
392 o1.
re = rout[i].
re - rout[255 - i].
re;
393 o1.
im = rout[i].
im + rout[255 - i].
im;
394
395 o2.
re = rout[i].
im - rout[255 - i].
im;
396 o2.
im = -rout[i].
re - rout[255 - i].
re;
397
398 /* combine them into one long transform */
403 }
404 }
405
407 {
408 int i, res;
409
410 res = 0;
411 if (in < 0)
413 for (i = 1024; i > 0; i >>= 1) {
415 res += i;
416 }
417 return -res;
418 }
419
421 {
422 if (a < b)
424
425 if (a - b >= 256)
428 }
429
432 {
439 int i, j;
440
442
443 for (j = 0; j < 256; j++) {
445 out_cb_unnorm[j] = -2047; /* and can only grow */
446 }
447
448 for (i = 0; i <
AUBANDS; i++) {
449 denom = ca_cb; /* and can only grow */
450 for (j = 0; j < 256; j++)
451 denom =
add_cb(denom, power[j] +
auf[samplerate_index][i][j]);
452 for (j = 0; j < 256; j++)
453 out_cb_unnorm[j] =
add_cb(out_cb_unnorm[j],
454 -denom +
auf[samplerate_index][i][j]);
455 }
456
457 for (j = 0; j < 256; j++)
458 out_cb[j] =
add_cb(out_cb[j], -out_cb_unnorm[j] - ca_cb - cs_cb);
459 }
460
464
467 {
468 int f;
469
470 if (band == 0) {
471 for (f = 0; f < 4; f++)
472 walk(c, 0, 0, f, 0, -2047, channel, arg);
473 } else {
474 for (f = 0; f < 8; f++)
475 walk(c, band, band - 1, 8 * band - 4 + f,
477 }
478 }
479
482 {
483 int f;
484
485 if (band == 31) {
486 for (f = 0; f < 4; f++)
487 walk(c, 31, 31, 256 - 4 + f, 0, -2047, channel, arg);
488 } else {
489 for (f = 0; f < 8; f++)
490 walk(c, band, band + 1, 8 * band + 4 + f,
492 }
493 }
494
498 {
500
503 }
504
506 {
507 int i, k,
band, ch, ssf;
509
510 for (i = 0; i < 256; i++)
513
517
518 for (i = 0, k = 128 + 256 * ssf; k < 512; i++, k++)
520 for (k -= 512; i < 512; i++, k++)
521 data[i] = input[k * c->
channels + chi];
523 }
524 for (i = 0; i < 256; i++) {
526
531 }
532
533 for (band = 0; band < 32; band++) {
537 }
538 }
539
541 {
543
544 for (band = 0; band < 32; band++)
548
551 if (m < s)
553 }
555 }
556
560
565 }
566 }
567
569 #define USED_1ABITS 1
570 #define USED_NABITS 2
571 #define USED_26ABITS 4
572
574 {
575 int ch,
band, ret = 0;
576
580
581 /* attempt to guess the bit distribution based on the prevoius frame */
583 for (band = 0; band < 32; band++) {
585
586 if (snr_cb >= 1312) {
589 } else if (snr_cb >= 222) {
592 } else if (snr_cb >= 0) {
595 } else {
598 }
599 }
600 }
601
602 for (band = 0; band < 32; band++)
605 }
606
607 return ret;
608 }
609
611 {
612 /* Find the bounds where the binary search should work */
613 int low, high, down;
614 int used_abits = 0;
615
621 low = high;
624 }
625 } else {
627 high = low;
629 goto out;
/* The requested bitrate is too high, pad with zeros */
632 }
633 }
634
635 /* Now do a binary search between low and high to see what fits */
636 for (down =
snr_fudge >> 1; down; down >>= 1) {
639 high -= down;
640 }
646 }
647
649 {
650 int k, ch;
651
652 for (k = 0; k < 512; k++)
653 for (ch = 0; ch < c->
channels; ch++) {
655
657 }
658 }
659
661 {
663
665 value = value >> quant.
e;
667 }
668
670 {
672 int our_nscale, try_remove;
674
677
678 our_nscale = 127;
680
681 for (try_remove = 64; try_remove > 0; try_remove >>= 1) {
683 continue;
687 continue;
688 our_nscale -= try_remove;
689 }
690
691 if (our_nscale >= 125)
692 our_nscale = 124;
693
697
698 return our_nscale;
699 }
700
702 {
704
705 for (band = 0; band < 32; band++)
709 &c->
quant[band][ch]);
710
713 }
714
716 {
718
720 for (band = 0; band < 32; band++)
723 }
724
726 {
727 /* SYNC */
730
731 /* Frame type: normal */
733
734 /* Deficit sample count: none */
736
737 /* CRC is not present */
739
740 /* Number of PCM sample blocks */
742
743 /* Primary frame byte size */
745
746 /* Audio channel arrangement */
748
749 /* Core audio sampling frequency */
751
752 /* Transmission bit rate */
754
755 /* Embedded down mix: disabled */
757
758 /* Embedded dynamic range flag: not present */
760
761 /* Embedded time stamp flag: not present */
763
764 /* Auxiliary data flag: not present */
766
767 /* HDCD source: no */
769
770 /* Extension audio ID: N/A */
772
773 /* Extended audio data: not present */
775
776 /* Audio sync word insertion flag: after each sub-frame */
778
779 /* Low frequency effects flag: not present or 64x subsampling */
781
782 /* Predictor history switch flag: on */
784
785 /* No CRC */
786 /* Multirate interpolator switch: non-perfect reconstruction */
788
789 /* Encoder software revision: 7 */
791
792 /* Copy history: 0 */
794
795 /* Source PCM resolution: 16 bits, not DTS ES */
797
798 /* Front sum/difference coding: no */
800
801 /* Surrounds sum/difference coding: no */
803
804 /* Dialog normalization: 0 dB */
806 }
807
809 {
810 static const int bitlen[11] = { 0, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 };
811 static const int thr[11] = { 0, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7 };
812
813 int ch, i;
814 /* Number of subframes */
816
817 /* Number of primary audio channels */
819
820 /* Subband activity count */
823
824 /* High frequency VQ start subband */
827
828 /* Joint intensity coding index: 0, 0 */
831
832 /* Transient mode codebook: A4, A4 (arbitrary) */
835
836 /* Scale factor code book: 7 bit linear, 7-bit sqrt table (for each channel) */
839
840 /* Bit allocation quantizer select: linear 5-bit */
843
844 /* Quantization index codebook select: dummy data
845 to avoid transmission of scale factor adjustment */
846 for (i = 1; i < 11; i++)
849
850 /* Scale factor adjustment index: not transmitted */
851 /* Audio header CRC check word: not transmitted */
852 }
853
855 {
856 if (c->
abits[band][ch] <= 7) {
857 int sum, i, j;
858 for (i = 0; i < 8; i += 4) {
859 sum = 0;
860 for (j = 3; j >= 0; j--) {
864 }
866 }
867 } else {
868 int i;
869 for (i = 0; i < 8; i++) {
872 }
873 }
874 }
875
877 {
879
880 /* Subsubframes count */
882
883 /* Partial subsubframe sample count: dummy */
885
886 /* Prediction mode: no ADPCM, in each channel and subband */
890
891 /* Prediction VQ address: not transmitted */
892 /* Bit allocation index */
896
898 /* Transition mode: none for each channel and subband */
902 }
903
904 /* Scale factors */
908
909 /* Joint subband scale factor codebook select: not transmitted */
910 /* Scale factors for joint subband coding: not transmitted */
911 /* Stereo down-mix coefficients: not transmitted */
912 /* Dynamic range coefficient: not transmitted */
913 /* Stde information CRC check word: not transmitted */
914 /* VQ encoded high frequency subbands: not transmitted */
915
916 /* LFE data: 8 samples and scalefactor */
921 }
922
923 /* Audio data (subsubframes) */
928
929 /* DSYNC */
931 }
932
935 {
938 int ret, i;
939
941 return ret;
942
944
948
955
961
962
965
967
971 *got_packet_ptr = 1;
972 return 0;
973 }
974
976 { "b", "1411200" },
978 };
979
997 0 },
999 };
This structure describes decoded (raw) audio or video data.
static int32_t cb_to_add[256]
ptrdiff_t const GLvoid * data
int32_t eff_masking_curve_cb[256]
static void put_sbits(PutBitContext *pb, int n, int32_t value)
static int32_t auf[9][AUBANDS][256]
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
#define AV_LOG_WARNING
Something somehow does not look correct.
static void put_frame_header(DCAEncContext *c)
int64_t bit_rate
the average bitrate
static av_cold int init(AVCodecContext *avctx)
const int8_t * channel_order_tab
channel reordering table, lfe and non lfe
static int32_t band_spectrum[2][8]
static const uint8_t bitstream_sfreq[]
static const uint16_t erb[]
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
static void shift_history(DCAEncContext *c, const int32_t *input)
#define AV_CH_LAYOUT_STEREO
static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
static void walk_band_high(DCAEncContext *c, int band, int channel, walk_band_t walk, int32_t *arg)
#define AV_CH_LAYOUT_5POINT0
int32_t subband[SUBBAND_SAMPLES][DCAENC_SUBBANDS][MAX_CHANNELS]
const float ff_dca_fir_32bands_nonperfect[512]
static void walk_band_low(DCAEncContext *c, int band, int channel, walk_band_t walk, int32_t *arg)
static const int quant_levels[27]
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static void calc_masking(DCAEncContext *c, const int32_t *input)
static const softfloat stepsize_inv[27]
const uint32_t ff_dca_bit_rates[32]
static int32_t lfe_fir_64i[512]
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
static int32_t cos_table[2048]
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static int calc_one_scale(int32_t peak_cb, int abits, softfloat *quant)
int scale_factor[DCAENC_SUBBANDS][MAX_CHANNELS]
int32_t history[512][MAX_CHANNELS]
int32_t masking_curve_cb[SUBSUBFRAMES][256]
static void quantize_all(DCAEncContext *c)
static int32_t sin_t(int x)
const int8_t ff_dca_channel_reorder_nolfe[16][9]
#define AV_CH_LAYOUT_5POINT1
static int32_t add_cb(int32_t a, int32_t b)
static const softfloat scalefactor_inv[128]
static void lfe_downsample(DCAEncContext *c, const int32_t *input)
softfloat quant[DCAENC_SUBBANDS][MAX_CHANNELS]
static double hom(double f)
int32_t band_masking_cb[32]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void put_subframe(DCAEncContext *c, int subframe)
static const int snr_fudge
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
const uint8_t ff_reverse[256]
int abits[DCAENC_SUBBANDS][MAX_CHANNELS]
const float ff_dca_lfe_fir_64[256]
static void update_band_masking(DCAEncContext *c, int band1, int band2, int f, int32_t spectrum1, int32_t spectrum2, int channel, int32_t *arg)
simple assert() macros that are a bit more flexible than ISO C assert().
const char * name
Name of the codec implementation.
static const uint8_t offset[127][2]
static int32_t quantize_value(int32_t value, softfloat quant)
static const int sample_rates[]
uint64_t channel_layout
Audio channel layout.
static int put_bits_count(PutBitContext *s)
common internal API header
static const uint16_t fc[]
static void assign_bits(DCAEncContext *c)
audio channel layout utility functions
static int init_quantization_noise(DCAEncContext *c, int noise)
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
GLsizei GLboolean const GLfloat * value
#define DCA_MAX_FRAME_SIZE
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int32_t quantized[SUBBAND_SAMPLES][DCAENC_SUBBANDS][MAX_CHANNELS]
int32_t peak_cb[DCAENC_SUBBANDS][MAX_CHANNELS]
int frame_size
Number of samples per channel in an audio frame.
static int noise(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int keyframe)
static void put_primary_audio_header(DCAEncContext *c)
static void find_peaks(DCAEncContext *c)
static int32_t mul32(int32_t a, int32_t b)
Libavcodec external API header.
const int32_t * band_spectrum
AVSampleFormat
Audio sample formats.
static int32_t cb_to_level[2048]
int sample_rate
samples per second
main external API structure.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
static void put_subframe_samples(DCAEncContext *c, int ss, int band, int ch)
static void adjust_jnd(int samplerate_index, const int32_t in[512], int32_t out_cb[256])
const int8_t ff_dca_channel_reorder_lfe[16][9]
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
int32_t worst_quantization_noise
static int encode_init(AVCodecContext *avctx)
static int32_t band_interpolation[2][512]
static int32_t cos_t(int x)
static void calc_scales(DCAEncContext *c)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static void subband_transform(DCAEncContext *c, const int32_t *input)
static void fft(const int32_t in[2 *256], cplx32 out[256])
common internal api header.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
common internal and external API header
static int32_t get_cb(int32_t in)
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static av_always_inline int diff(const uint32_t a, const uint32_t b)
int channels
number of audio channels
void(* walk_band_t)(DCAEncContext *c, int band1, int band2, int f, int32_t spectrum1, int32_t spectrum2, int channel, int32_t *arg)
static int32_t half32(int32_t a)
int64_t av_get_default_channel_layout(int nb_channels)
Return default channel layout for a given number of channels.
static enum AVSampleFormat sample_fmts[]
static av_always_inline double ff_exp10(double x)
Compute 10^x for floating point values.
const int32_t * band_interpolation
int32_t downsampled_lfe[DCA_LFE_SAMPLES]
static av_always_inline int64_t ff_samples_to_time_base(AVCodecContext *avctx, int64_t samples)
Rescale from sample rate to AVCodecContext.time_base.
#define FFSWAP(type, a, b)
static const AVCodecDefault defaults[]
static const int bit_consumption[27]
const float ff_dca_fir_32bands_perfect[512]
#define AV_CH_LAYOUT_MONO
const int8_t ff_dca_lfe_index[16]
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame
static double gammafilter(int i, double f)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...