56 #define DCA_PRIM_CHANNELS_MAX (7)
57 #define DCA_ABITS_MAX (32)
58 #define DCA_SUBSUBFRAMES_MAX (4)
59 #define DCA_SUBFRAMES_MAX (16)
60 #define DCA_BLOCKS_MAX (16)
61 #define DCA_LFE_MAX (3)
123 #define DCA_CORE_EXTS (DCA_EXT_XCH | DCA_EXT_XXCH | DCA_EXT_X96)
172 1, 2, 2, 2, 2, 3, 2, 3, 2, 3, 2, 3, 1, 3, 2, 3
176 { 0, -1, -1, -1, -1, -1, -1, -1, -1},
177 { 0, 1, -1, -1, -1, -1, -1, -1, -1},
178 { 0, 1, -1, -1, -1, -1, -1, -1, -1},
179 { 0, 1, -1, -1, -1, -1, -1, -1, -1},
180 { 0, 1, -1, -1, -1, -1, -1, -1, -1},
181 { 2, 0, 1, -1, -1, -1, -1, -1, -1},
182 { 0, 1, 3, -1, -1, -1, -1, -1, -1},
183 { 2, 0, 1, 4, -1, -1, -1, -1, -1},
184 { 0, 1, 3, 4, -1, -1, -1, -1, -1},
185 { 2, 0, 1, 4, 5, -1, -1, -1, -1},
186 { 3, 4, 0, 1, 5, 6, -1, -1, -1},
187 { 2, 0, 1, 4, 5, 6, -1, -1, -1},
188 { 0, 6, 4, 5, 2, 3, -1, -1, -1},
189 { 4, 2, 5, 0, 1, 6, 7, -1, -1},
190 { 5, 6, 0, 1, 7, 3, 8, 4, -1},
191 { 4, 2, 5, 0, 1, 6, 8, 7, -1},
195 { 0, 2, -1, -1, -1, -1, -1, -1, -1},
196 { 0, 1, 3, -1, -1, -1, -1, -1, -1},
197 { 0, 1, 3, -1, -1, -1, -1, -1, -1},
198 { 0, 1, 3, -1, -1, -1, -1, -1, -1},
199 { 0, 1, 3, -1, -1, -1, -1, -1, -1},
200 { 2, 0, 1, 4, -1, -1, -1, -1, -1},
201 { 0, 1, 3, 4, -1, -1, -1, -1, -1},
202 { 2, 0, 1, 4, 5, -1, -1, -1, -1},
203 { 0, 1, 4, 5, 3, -1, -1, -1, -1},
204 { 2, 0, 1, 5, 6, 4, -1, -1, -1},
205 { 3, 4, 0, 1, 6, 7, 5, -1, -1},
206 { 2, 0, 1, 4, 5, 6, 7, -1, -1},
207 { 0, 6, 4, 5, 2, 3, 7, -1, -1},
208 { 4, 2, 5, 0, 1, 7, 8, 6, -1},
209 { 5, 6, 0, 1, 8, 3, 9, 4, 7},
210 { 4, 2, 5, 0, 1, 6, 9, 8, 7},
214 { 0, -1, -1, -1, -1, -1, -1, -1, -1},
215 { 0, 1, -1, -1, -1, -1, -1, -1, -1},
216 { 0, 1, -1, -1, -1, -1, -1, -1, -1},
217 { 0, 1, -1, -1, -1, -1, -1, -1, -1},
218 { 0, 1, -1, -1, -1, -1, -1, -1, -1},
219 { 2, 0, 1, -1, -1, -1, -1, -1, -1},
220 { 0, 1, 2, -1, -1, -1, -1, -1, -1},
221 { 2, 0, 1, 3, -1, -1, -1, -1, -1},
222 { 0, 1, 2, 3, -1, -1, -1, -1, -1},
223 { 2, 0, 1, 3, 4, -1, -1, -1, -1},
224 { 2, 3, 0, 1, 4, 5, -1, -1, -1},
225 { 2, 0, 1, 3, 4, 5, -1, -1, -1},
226 { 0, 5, 3, 4, 1, 2, -1, -1, -1},
227 { 3, 2, 4, 0, 1, 5, 6, -1, -1},
228 { 4, 5, 0, 1, 6, 2, 7, 3, -1},
229 { 3, 2, 4, 0, 1, 5, 7, 6, -1},
233 { 0, 1, -1, -1, -1, -1, -1, -1, -1},
234 { 0, 1, 2, -1, -1, -1, -1, -1, -1},
235 { 0, 1, 2, -1, -1, -1, -1, -1, -1},
236 { 0, 1, 2, -1, -1, -1, -1, -1, -1},
237 { 0, 1, 2, -1, -1, -1, -1, -1, -1},
238 { 2, 0, 1, 3, -1, -1, -1, -1, -1},
239 { 0, 1, 2, 3, -1, -1, -1, -1, -1},
240 { 2, 0, 1, 3, 4, -1, -1, -1, -1},
241 { 0, 1, 3, 4, 2, -1, -1, -1, -1},
242 { 2, 0, 1, 4, 5, 3, -1, -1, -1},
243 { 2, 3, 0, 1, 5, 6, 4, -1, -1},
244 { 2, 0, 1, 3, 4, 5, 6, -1, -1},
245 { 0, 5, 3, 4, 1, 2, 6, -1, -1},
246 { 3, 2, 4, 0, 1, 6, 7, 5, -1},
247 { 4, 5, 0, 1, 7, 2, 8, 3, 6},
248 { 3, 2, 4, 0, 1, 5, 8, 7, 6},
251 #define DCA_DOLBY 101
253 #define DCA_CHANNEL_BITS 6
254 #define DCA_CHANNEL_MASK 0x3F
258 #define HEADER_SIZE 14
260 #define DCA_MAX_FRAME_SIZE 16384
261 #define DCA_MAX_EXSS_HEADER_SIZE 4096
263 #define DCA_BUFFER_PADDING_SIZE 1024
265 #define DCA_NSYNCAUX 0x9A1105A0
392 int mix_config_num_ch[4];
405 0, 512, 640, 768, 1282, 1794, 2436, 3080, 3770, 4454, 5364,
406 5372, 5380, 5388, 5392, 5396, 5412, 5420, 5428, 5460, 5492, 5508,
407 5572, 5604, 5668, 5796, 5860, 5892, 6412, 6668, 6796, 7308, 7564,
408 7820, 8076, 8620, 9132, 9388, 9910, 10166, 10680, 11196, 11726, 12240,
409 12752, 13298, 13810, 14326, 14840, 15500, 16022, 16540, 17158, 17678, 18264,
410 18796, 19352, 19926, 20468, 21472, 22398, 23014, 23622,
415 static int vlcs_initialized = 0;
417 static VLC_TYPE dca_table[23622][2];
419 if (vlcs_initialized)
422 dca_bitalloc_index.
offset = 1;
423 dca_bitalloc_index.
wrap = 2;
424 for (i = 0; i < 5; i++) {
431 dca_scalefactor.
offset = -64;
432 dca_scalefactor.
wrap = 2;
433 for (i = 0; i < 5; i++) {
442 for (i = 0; i < 4; i++) {
450 for (i = 0; i < 10; i++)
451 for (j = 0; j < 7; j++) {
455 dca_smpl_bitalloc[i + 1].
wrap = 1 + (j > 4);
457 dca_smpl_bitalloc[i + 1].
vlc[j].
table_allocated = dca_vlc_offs[c + 1] - dca_vlc_offs[c];
465 vlcs_initialized = 1;
477 static const float adj_table[4] = { 1.0, 1.1250, 1.2500, 1.4375 };
478 static const int bitlen[11] = { 0, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 };
479 static const int thr[11] = { 0, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7 };
506 for (j = 1; j < 11; j++)
511 for (j = 0; j < 11; j++)
515 for (j = 1; j < 11; j++)
545 for (j = 0; j < 11; j++)
549 for (j = 0; j < 11; j++)
644 "source pcm resolution: %i (%i bits/sample)\n",
664 value = av_clip(value, 0, (1 << log2range) - 1);
665 }
else if (level < 8) {
666 if (level + 1 > log2range) {
713 "Invalid bit allocation index\n");
721 av_dlog(s->
avctx,
"bitalloc index [%i][%i] too big (%i)\n",
733 k < s->vq_start_subband[j] && s->
bitalloc[j][k] > 0) {
744 const uint32_t *scale_table;
745 int scale_sum, log_size;
797 for (k = s->
subband_activity[j]; k < s->subband_activity[source_channel]; k++) {
804 "Joint stereo coding not supported\n");
830 if (!base_channel && s->
lfe) {
832 int lfe_samples = 2 * s->
lfe * (4 + block_index);
836 for (j = lfe_samples; j < lfe_end_sample; j++) {
848 for (j = lfe_samples; j < lfe_end_sample; j++)
867 "prediction coefs: %f, %f, %f, %f\n",
899 for (k = s->
subband_activity[j]; k < s->subband_activity[source_channel]; k++)
907 if (!base_channel && s->
lfe) {
908 int lfe_samples = 2 * s->
lfe * (4 + block_index);
912 for (j = lfe_samples; j < lfe_end_sample; j++)
922 float samples_in[32][8],
float *samples_out,
925 const float *prCoeff;
929 scale *= sqrt(1 / 8.0);
941 samples_out, s->
raXin, scale);
945 int num_deci_sample,
float *samples_in,
957 const float *prCoeff;
961 if (decimation_select == 1) {
969 for (deciindex = 0; deciindex < num_deci_sample; deciindex++) {
972 samples_out += 2 * 32 * (1 + idx);
977 #define MIX_REAR1(samples, s1, rs, coef) \
978 samples[0][i] += samples[s1][i] * coef[rs][0]; \
979 samples[1][i] += samples[s1][i] * coef[rs][1];
981 #define MIX_REAR2(samples, s1, s2, rs, coef) \
982 samples[0][i] += samples[s1][i] * coef[rs][0] + samples[s2][i] * coef[rs + 1][0]; \
983 samples[1][i] += samples[s1][i] * coef[rs][1] + samples[s2][i] * coef[rs + 1][1];
985 #define MIX_FRONT3(samples, coef) \
989 samples[0][i] = t * coef[0][0] + u * coef[1][0] + v * coef[2][0]; \
990 samples[1][i] = t * coef[0][1] + u * coef[1][1] + v * coef[2][1];
992 #define DOWNMIX_TO_STEREO(op1, op2) \
993 for (i = 0; i < 256; i++) { \
998 static void dca_downmix(
float **samples,
int srcfmt,
int lfe_present,
1000 const int8_t *channel_mapping)
1002 int c, l,
r, sl, sr, s;
1017 c = channel_mapping[0];
1018 l = channel_mapping[1];
1019 r = channel_mapping[2];
1023 s = channel_mapping[2];
1027 c = channel_mapping[0];
1028 l = channel_mapping[1];
1029 r = channel_mapping[2];
1030 s = channel_mapping[3];
1035 sl = channel_mapping[2];
1036 sr = channel_mapping[3];
1040 c = channel_mapping[0];
1041 l = channel_mapping[1];
1042 r = channel_mapping[2];
1043 sl = channel_mapping[3];
1044 sr = channel_mapping[4];
1052 for (i = 0; i < 256; i++) {
1053 samples[0][i] += samples[lf_buf][i] * coef[lf_idx][0];
1054 samples[1][i] += samples[lf_buf][i] * coef[lf_idx][1];
1060 #ifndef decode_blockcodes
1066 int offset = (levels - 1) >> 1;
1068 for (i = 0; i < 4; i++) {
1069 int div =
FASTDIV(code, levels);
1070 values[i] = code - offset - div * levels;
1092 const float *quant_step_table;
1120 float quant_step_size = quant_step_table[abits];
1134 memset(
block + 8 * l, 0, 8 *
sizeof(
block[0]));
1138 rscale[l] = quant_step_size * s->
scale_factor[k][l][sfi] *
1141 if (abits >= 11 || !dca_smpl_bitalloc[abits].vlc[sel].table) {
1144 int block_code1, block_code2,
size, levels, err;
1152 levels,
block + 8 * l);
1155 "ERROR: block code look-up failed\n");
1160 for (m = 0; m < 8; m++)
1165 for (m = 0; m < 8; m++)
1167 &dca_smpl_bitalloc[abits], sel);
1193 for (m = 1; m < 8; m++) {
1195 subband_samples[k][l][m - 1];
1196 for (n = 2; n <= 4; n++)
1199 subband_samples[k][l][m - n];
1203 subband_samples[k][l][m] += sum * 1.0f / 8192;
1214 "Stream with high frequencies VQ coding\n");
1256 M_SQRT1_2 / 32768.0 );
1280 int in,
out, aux_data_count, aux_data_end, reserved;
1288 if (!base_channel) {
1308 "Auxiliary Decode Time Stamp Flag");
1341 "Invalid mode %d for embedded downmix coefficients\n",
1348 if ((tmp & 0xFF) > 241) {
1350 "Invalid downmix coefficient code %"PRIu16
"\n",
1365 "Overread auxiliary data by %d bits\n", -reserved);
1367 }
else if (reserved) {
1369 "Core auxiliary data reserved content");
1438 return av_popcount(mask) +
1457 for (i = 0; i < channels; i++) {
1458 int mix_map_mask =
get_bits(gb, out_ch);
1459 int num_coeffs = av_popcount(mix_map_mask);
1472 int embedded_stereo = 0;
1473 int embedded_6ch = 0;
1474 int drc_code_present;
1475 int extensions_mask;
1507 int spkr_remap_sets;
1508 int spkr_mask_size = 16;
1517 spkr_mask_size = (
get_bits(&s->
gb, 2) + 1) << 2;
1523 for (i = 0; i < spkr_remap_sets; i++) {
1528 for (i = 0; i < spkr_remap_sets; i++) {
1529 int num_dec_ch_remaps =
get_bits(&s->
gb, 5) + 1;
1533 for (j = 0; j < num_spkrs[i]; j++) {
1535 int num_dec_ch = av_popcount(remap_dec_ch_mask);
1546 if (drc_code_present)
1552 if (drc_code_present && embedded_stereo)
1576 if (embedded_stereo)
1582 case 0: extensions_mask =
get_bits(&s->
gb, 12);
break;
1585 case 3: extensions_mask = 0;
break;
1609 "DTS extensions detection mismatch (%d, %d)\n",
1624 int active_ss_mask[8];
1649 if (num_audiop > 1) {
1651 "Multiple DTS-HD audio presentations");
1657 if (num_assets > 1) {
1663 for (i = 0; i < num_audiop; i++)
1664 active_ss_mask[i] =
get_bits(&s->
gb, ss_index + 1);
1666 for (i = 0; i < num_audiop; i++)
1667 for (j = 0; j <= ss_index; j++)
1668 if (active_ss_mask[i] & (1 << j))
1673 int mix_out_mask_size;
1676 mix_out_mask_size = (
get_bits(&s->
gb, 2) + 1) << 2;
1680 int mix_out_mask =
get_bits(&s->
gb, mix_out_mask_size);
1686 for (i = 0; i < num_assets; i++)
1689 for (i = 0; i < num_assets; i++) {
1700 int sign = (code >> 8) - 1;
1702 return ((
dca_dmixtable[code] ^ sign) - sign) * (1.0 / (1
U << 15));
1710 int *got_frame_ptr,
AVPacket *avpkt)
1714 int buf_size = avpkt->
size;
1717 int num_core_channels = 0;
1719 float **samples_flt;
1721 int channels, full_channels;
1777 int ext_amode, xch_fsize;
1794 if ((ext_amode =
get_bits(&s->
gb, 4)) != 1) {
1796 " supported!\n", ext_amode);
1856 if (s->
amode < 16) {
1869 #if FF_API_REQUEST_CHANNELS
1886 channels = num_core_channels + !!s->
lfe;
1895 if (channels > !!s->
lfe &&
1899 if (num_core_channels + !!s->
lfe > 2 &&
1912 for (i = 0; i < num_core_channels + !!s->
lfe; i++) {
1922 "Invalid channel mode %d\n", am);
1925 if (num_core_channels + !!s->
lfe >
1931 for (i = 0; i < num_core_channels + !!s->
lfe; i++) {
1937 for (i = 0; i < num_core_channels + !!s->
lfe; i++) {
1974 full_channels - channels,
1984 for (ch = 0; ch < channels; ch++)
1986 for (; ch < full_channels; ch++)
2004 for (i = 0; i < 2 * s->
lfe * 4; i++)
2045 #if FF_API_REQUEST_CHANNELS
int wrap
wrap for get_vlc2()
int ext_descr
extension audio descriptor flag
static const int8_t bitalloc_offsets[10]
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int quant_index_huffman[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX]
quantization index codebook select
int bitalloc_huffman[DCA_PRIM_CHANNELS_MAX]
bit allocation quantizer select
int crc_present
crc is present in the bitstream
This structure describes decoded (raw) audio or video data.
low bitrate component in ExSS
int timestamp
embedded time stamp flag
int amode
audio channels arrangement
static int decode_blockcodes(int code1, int code2, int levels, int32_t *values)
static const AVProfile profiles[]
static const uint16_t tmode_codes[TMODE_COUNT][4]
int transient_huffman[DCA_PRIM_CHANNELS_MAX]
transient mode code book
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
static const uint32_t scale_factor_quant6[64]
int mix_config_num_ch[4]
number of channels in each mix out configuration
static void skip_bits_long(GetBitContext *s, int n)
attribute_deprecated int request_channels
Decoder should decode to this many channels if it can (0 for default)
FmtConvertContext fmt_conv
static int dca_parse_frame_header(DCAContext *s)
static int dca_exss_parse_asset_header(DCAContext *s)
Parse extension substream asset header (HD)
static void dca_exss_skip_mix_coeffs(GetBitContext *gb, int channels, int out_ch)
Skip mixing coefficients of a single mix out configuration (HD)
void(* lfe_fir[2])(float *out, const float *in, const float *coefs)
#define FF_PROFILE_DTS_HD_HRA
int vq_start_subband[DCA_PRIM_CHANNELS_MAX]
high frequency vq start subband
XXCh channels extension in core substream.
#define AV_OPT_FLAG_AUDIO_PARAM
float subband_fir_noidea[DCA_PRIM_CHANNELS_MAX][32]
int hist_index[DCA_PRIM_CHANNELS_MAX]
int samples_deficit
deficit sample count
#define DECLARE_ALIGNED(n, t, v)
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_dlog(ac->avr,"%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
uint8_t core_downmix
embedded downmix coefficients available
static const float lossless_quant_d[32]
int ff_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, int max_size)
Convert bitstream to one representation based on sync marker.
int dynrange
embedded dynamic range flag
int joint_scale_factor[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]
joint subband scale factors
int version
encoder software revision
static const int8_t dca_channel_reorder_lfe_xch[][9]
#define FF_ARRAY_ELEMS(a)
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
#define AV_CH_LAYOUT_STEREO
static BitAlloc dca_scalefactor
scalefactor VLCs
#define DCA_BUFFER_PADDING_SIZE
static int get_sbits(GetBitContext *s, int n)
float subband_fir_hist[DCA_PRIM_CHANNELS_MAX][512]
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
float * extra_channels[DCA_PRIM_CHANNELS_MAX+1]
#define DCA_HD_MARKER
DCA-HD specific block starts with this marker.
static int dca_subframe_footer(DCAContext *s, int base_channel)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static BitAlloc dca_tmode
transition mode VLCs
void(* vector_fmac_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float and add to destination vector.
#define MIX_FRONT3(samples, coef)
static int dca_exss_mask2count(int mask)
Return the number of channels in an ExSS speaker mask (HD)
static int dca_subframe_header(DCAContext *s, int base_channel, int block_index)
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
int scalefactor_huffman[DCA_PRIM_CHANNELS_MAX]
scale factor code book
static int dca_decode_block(DCAContext *s, int base_channel, int block_index)
Decode a dca frame block.
static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
enum AVSampleFormat sample_fmt
audio sample format
static const uint16_t dca_vlc_offs[]
int xch_base_channel
index of first (only) channel containing XCH data
float subband_samples_hist[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][4]
int dca_buffer_size
how much data is in the dca_buffer
static const uint32_t scale_factor_quant7[128]
#define MIX_REAR2(samples, s1, s2, rs, coef)
static void get_array(GetBitContext *gb, int *dst, int len, int bits)
static av_cold int dca_decode_end(AVCodecContext *avctx)
#define AV_CH_LOW_FREQUENCY
int header_crc
header crc check bytes
int transition_mode[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]
transition mode (transients)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
av_cold void ff_dcadsp_init(DCADSPContext *s)
static int get_bits_count(const GetBitContext *s)
int sample_rate
audio sampling rate
bitstream reader API header.
XCh channel extension in core substream.
#define CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
static BitAlloc dca_bitalloc_index
indexes for samples VLC select
int lfe
low frequency effects flag
static const float fir_32bands_nonperfect[]
static BitAlloc dca_smpl_bitalloc[11]
samples VLCs
XXCh channels extension in ExSS.
static const uint8_t bitalloc_sizes[10]
static void dca_downmix(float **samples, int srcfmt, int lfe_present, float coef[DCA_PRIM_CHANNELS_MAX+1][2], const int8_t *channel_mapping)
void(* int32_to_float_fmul_array8)(struct FmtConvertContext *c, float *dst, const int32_t *src, const float *mul, int len)
Convert an array of int32_t to float and multiply by a float value from another array, stepping along the float array once for each 8 integers.
int predictor_history
predictor history flag
int dynrange_coef
dynamic range coefficient
int joint_huff[DCA_PRIM_CHANNELS_MAX]
joint subband scale factors codebook
static int get_bits_left(GetBitContext *gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint16_t core_downmix_codes[DCA_PRIM_CHANNELS_MAX+1][4]
embedded downmix coefficients (9-bit codes)
static void lfe_interpolation_fir(DCAContext *s, int decimation_select, int num_deci_sample, float *samples_in, float *samples_out)
float subband_samples[DCA_BLOCKS_MAX][DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][8]
static const uint16_t mask[17]
#define MIX_REAR1(samples, s1, rs, coef)
#define DCA_PRIM_CHANNELS_MAX
static const uint16_t bitalloc_12_codes[BITALLOC_12_COUNT][12]
int hdcd
source material is mastered in HDCD
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int mix_metadata
mixing metadata present
#define FF_PROFILE_DTS_ES
void av_log(void *avcl, int level, const char *fmt,...)
static const uint8_t bitalloc_12_bits[BITALLOC_12_COUNT][12]
const char * name
Name of the codec implementation.
int bitalloc[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]
bit allocation index
static int dca_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Main frame decoding function FIXME add arguments.
int debug_flag
used for suppressing repeated error messages output
uint64_t channel_layout
Audio channel layout.
static const int8_t dca_lfe_index[]
const int8_t * channel_order_tab
channel reordering table, lfe and non lfe
float lfe_data[2 *DCA_LFE_MAX *(DCA_BLOCKS_MAX+4)]
Low frequency effect data.
common internal API header
static const uint8_t tmode_bits[TMODE_COUNT][4]
static void qmf_32_subbands(DCAContext *s, int chans, float samples_in[32][8], float *samples_out, float scale)
int front_sum
front sum/difference flag
int xch_disable
whether the XCh extension should be decoded or not
int source_pcm_res
source pcm resolution
int bit_rate
the average bitrate
audio channel layout utility functions
static const int8_t dca_channel_reorder_lfe[][9]
static const int8_t dca_channel_reorder_nolfe[][9]
int surround_sum
surround sum/difference flag
#define FF_PROFILE_UNKNOWN
static av_cold void dca_init_vlcs(void)
av_cold void ff_synth_filter_init(SynthFilterContext *c)
uint8_t dca_buffer[DCA_MAX_FRAME_SIZE+DCA_MAX_EXSS_HEADER_SIZE+DCA_BUFFER_PADDING_SIZE]
static const uint8_t scales_bits[SCALES_COUNT][129]
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
int joint_intensity[DCA_PRIM_CHANNELS_MAX]
joint intensity coding index
static const int16_t adpcm_vb[4096][4]
static const uint16_t *const bitalloc_codes[10][8]
int multirate_inter
multirate interpolator switch
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
static const uint8_t dca_channels[16]
#define AV_CH_FRONT_LEFT_OF_CENTER
lossless extension in ExSS
#define AV_CH_FRONT_CENTER
uint8_t core_downmix_amode
audio channel arrangement of embedded downmix
const uint32_t avpriv_dca_sample_rates[16]
int bit_rate
transmission bit rate
static const uint8_t *const bitalloc_bits[10][8]
#define INIT_VLC_USE_NEW_STATIC
int offset
code values offset
static const uint8_t abits_levels[7]
#define AV_CH_FRONT_RIGHT_OF_CENTER
static const float lfe_fir_64[]
int xch_present
XCh extension present and valid.
int ff_side_data_update_matrix_encoding(AVFrame *frame, enum AVMatrixEncoding matrix_encoding)
Add or update AV_FRAME_DATA_MATRIXENCODING side data.
if(ac->has_optimized_func)
#define AVERROR_PATCHWELCOME
Not yet implemented in Libav, patches welcome.
int core_ext_mask
present extensions in the core substream
#define FF_PROFILE_DTS_96_24
#define DCA_MAX_FRAME_SIZE
Libavcodec external API header.
void(* qmf_32_subbands)(float samples_in[32][8], int sb_act, SynthFilterContext *synth, FFTContext *imdct, float synth_buf_ptr[512], int *synth_buf_offset, float synth_buf2[32], const float window[512], float *samples_out, float raXin[32], float scale)
int aux_data
auxiliary data flag
AVSampleFormat
Audio Sample Formats.
int sample_rate
samples per second
int ext_coding
extended coding flag
static float dca_dmix_code(unsigned code)
int32_t scale_factor[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][2]
scale factors (2 if transient)
int subband_activity[DCA_PRIM_CHANNELS_MAX]
subband activity count
main external API structure.
static void close(AVCodecParserContext *s)
float scalefactor_adj[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX]
scale factor adjustment
int copy_history
copy history
static void dca_exss_parse_header(DCAContext *s)
Parse extension substream header (HD)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define init_vlc(vlc, nb_bits, nb_codes,bits, bits_wrap, bits_size,codes, codes_wrap, codes_size,flags)
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits1(GetBitContext *s)
core in ExSS (extension substream)
Describe the class of an AVClass context structure.
static void skip_bits(GetBitContext *s, int n)
int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Get the required buffer size for the given audio parameters.
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
int32_t high_freq_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]
VQ encoded high frequency subbands.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static const uint64_t dca_core_channel_layout[]
static const float lossy_quant_d[32]
extended bitrate extension in ExSS
int sample_blocks
number of PCM sample blocks
static const uint8_t abits_sizes[7]
static const int8_t dca_channel_reorder_nolfe_xch[][9]
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static const AVOption options[]
static int decode_blockcode(int code, int levels, int32_t *values)
void(* decode_hf)(float dst[DCA_SUBBANDS][8], const int32_t vq_num[DCA_SUBBANDS], const int8_t hf_vq[1024][32], intptr_t vq_offset, int32_t scale[DCA_SUBBANDS][2], intptr_t start, intptr_t end)
#define AV_CH_BACK_CENTER
av_cold void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact)
Initialize a float DSP context.
int prediction_mode[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]
prediction mode (ADPCM used or not)
static av_cold int dca_decode_init(AVCodecContext *avctx)
DCA initialization.
static const float fir_32bands_perfect[]
int num_mix_configs
number of mix out configurations
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_dlog(ac->avr,"%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-> out
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
#define FF_DISABLE_DEPRECATION_WARNINGS
96/24 extension in core substream
common internal api header.
common internal and external API header
uint8_t * extra_channels_buffer
#define CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
int total_channels
number of channels including extensions
static const uint16_t scales_codes[SCALES_COUNT][129]
static int dca_filter_channels(DCAContext *s, int block_index)
int prediction_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]
prediction VQ coefs
int dialog_norm
dialog normalisation parameter
static av_cold int init(AVCodecParserContext *s)
int bit_rate_index
transmission bit rate index
int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, const uint8_t *buf, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Fill channel data pointers and linesize for samples with sample format sample_fmt.
static const uint8_t bitalloc_maxbits[10][7]
#define FF_ENABLE_DEPRECATION_WARNINGS
av_cold void ff_fmt_convert_init(FmtConvertContext *c, AVCodecContext *avctx)
int channels
number of audio channels
static const uint32_t dca_bit_rates[32]
VLC_TYPE(* table)[2]
code, bits
float * samples_chanptr[DCA_PRIM_CHANNELS_MAX+1]
static const int8_t high_freq_vq[1024][32]
int subsubframes[DCA_SUBFRAMES_MAX]
number of subsubframes
#define DCA_MAX_EXSS_HEADER_SIZE
static const float dca_default_coeffs[10][6][2]
static const float lfe_fir_128[]
static const int dca_ext_audio_descr_mask[]
static const uint8_t * align_get_bits(GetBitContext *s)
#define DOWNMIX_TO_STEREO(op1, op2)
int frame_size
primary frame byte size
#define DCA_SUBFRAMES_MAX
int aspf
audio sync word insertion flag
#define LOCAL_ALIGNED_16(t, v,...)
int prim_channels
number of primary audio channels
float downmix_coef[DCA_PRIM_CHANNELS_MAX+1][2]
stereo downmix coefficients
#define FF_PROFILE_DTS_HD_MA
static const uint8_t bitalloc_12_vlc_bits[BITALLOC_12_COUNT]
static int get_scale(GetBitContext *gb, int level, int value, int log2range)
uint8_t ** extended_data
pointers to the data planes/channels.
uint64_t request_channel_layout
Request decoder to use this channel layout if it can (0 for default)
int partial_samples[DCA_SUBFRAMES_MAX]
partial subsubframe samples count
static const AVClass dca_decoder_class
This structure stores compressed data.
int subframes
number of subframes
static int dca_parse_audio_coding_header(DCAContext *s, int base_channel)
int nb_samples
number of audio samples (per channel) described by this frame
static const uint16_t dca_dmixtable[242]
unsigned int extra_channels_buffer_size
static const uint8_t tmode_vlc_bits[TMODE_COUNT]
static av_always_inline int get_bitalloc(GetBitContext *gb, BitAlloc *ba, int idx)
int static_fields
static fields present
int frame_type
type of the current frame
static const uint8_t dca_bits_per_sample[7]