132 #define DCA_DOLBY 101 134 #define DCA_CHANNEL_BITS 6 135 #define DCA_CHANNEL_MASK 0x3F 139 #define HEADER_SIZE 14 141 #define DCA_NSYNCAUX 0x9A1105A0 165 static int vlcs_initialized = 0;
167 static VLC_TYPE dca_table[23622][2];
169 if (vlcs_initialized)
172 dca_bitalloc_index.
offset = 1;
173 dca_bitalloc_index.
wrap = 2;
174 for (i = 0; i < 5; i++) {
176 dca_bitalloc_index.
vlc[i].
table_allocated = ff_dca_vlc_offs[i + 1] - ff_dca_vlc_offs[i];
181 dca_scalefactor.
offset = -64;
182 dca_scalefactor.
wrap = 2;
183 for (i = 0; i < 5; i++) {
185 dca_scalefactor.
vlc[i].
table_allocated = ff_dca_vlc_offs[i + 6] - ff_dca_vlc_offs[i + 5];
192 for (i = 0; i < 4; i++) {
200 for (i = 0; i < 10; i++)
201 for (j = 0; j < 7; j++) {
205 dca_smpl_bitalloc[i + 1].
wrap = 1 + (j > 4);
207 dca_smpl_bitalloc[i + 1].
vlc[j].
table_allocated = ff_dca_vlc_offs[c + 1] - ff_dca_vlc_offs[c];
215 vlcs_initialized = 1;
227 static const uint8_t adj_table[4] = { 16, 18, 20, 23 };
228 static const int bitlen[11] = { 0, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 };
229 static const int thr[11] = { 0, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7 };
259 for (j = 1; j < 11; j++)
264 for (j = 0; j < 11; j++)
268 for (j = 1; j < 11; j++)
352 value = av_clip(value, 0, (1 << log2range) - 1);
353 }
else if (level < 8) {
354 if (level + 1 > log2range) {
401 "Invalid bit allocation index\n");
409 ff_dlog(s->
avctx,
"bitalloc index [%i][%i] too big (%i)\n",
421 k < s->audio_header.vq_start_subband[j] && s->
dca_chan[j].
bitalloc[k] > 0) {
432 const uint32_t *scale_table;
433 int scale_sum, log_size;
486 k < s->audio_header.subband_activity[source_channel]; k++) {
493 "Joint stereo coding not supported\n");
519 if (!base_channel && s->
lfe) {
521 int lfe_samples = 2 * s->
lfe * (4 + block_index);
525 for (j = lfe_samples; j < lfe_end_sample; j++) {
537 for (j = lfe_samples; j < lfe_end_sample; j++)
548 const float *prCoeff;
552 scale *= sqrt(1 / 8.0);
564 samples_out, s->
raXin, scale);
574 for (i = 0; i < 32; i++)
575 for (j = 0; j < 32; j++)
576 table->
dct4_coeff[i][j] = cos((2 * i + 1) * (2 * j + 1) * M_PI / 128);
577 for (i = 0; i < 32; i++)
578 for (j = 0; j < 32; j++)
579 table->
dct2_coeff[i][j] = cos((2 * i + 1) * j * M_PI / 64);
582 for (i = 0; i < 32; i++)
583 table->
rcos[i] = 0.125 / cos((2 * i + 1) * M_PI / 256);
584 for (i = 0; i < 32; i++)
585 table->
rsin[i] = -0.125 / sin((2 * i + 1) * M_PI / 256);
595 float *samples_out,
float scale)
601 unsigned i, j, k, subindex;
607 raXin[i] = samples_in[i][subindex];
609 for (k = 0; k < 32; k++) {
611 for (i = 0; i < 32; i++)
614 for (k = 0; k < 32; k++) {
616 for (i = 1; i < 32; i++)
619 for (k = 0; k < 32; k++) {
626 for (j = 0; j < 1024; j += 128)
628 *samples_out++ = out * scale;
633 for (j = 0; j < 1024; j += 128)
640 memmove(raX + 64, raX, (1024 - 64) *
sizeof(*raX));
656 const float *prCoeff;
671 for (deciindex = 0; deciindex < 2 * s->
lfe; deciindex++) {
674 samples_out += 2 * 32 * (1 + idx);
679 #define MIX_REAR1(samples, s1, rs, coef) \ 680 samples[0][i] += samples[s1][i] * coef[rs][0]; \ 681 samples[1][i] += samples[s1][i] * coef[rs][1]; 683 #define MIX_REAR2(samples, s1, s2, rs, coef) \ 684 samples[0][i] += samples[s1][i] * coef[rs][0] + samples[s2][i] * coef[rs + 1][0]; \ 685 samples[1][i] += samples[s1][i] * coef[rs][1] + samples[s2][i] * coef[rs + 1][1]; 687 #define MIX_FRONT3(samples, coef) \ 691 samples[0][i] = t * coef[0][0] + u * coef[1][0] + v * coef[2][0]; \ 692 samples[1][i] = t * coef[0][1] + u * coef[1][1] + v * coef[2][1]; 694 #define DOWNMIX_TO_STEREO(op1, op2) \ 695 for (i = 0; i < 256; i++) { \ 700 static void dca_downmix(
float **samples,
int srcfmt,
int lfe_present,
702 const int8_t *channel_mapping)
704 int c, l,
r, sl, sr, s;
719 c = channel_mapping[0];
720 l = channel_mapping[1];
721 r = channel_mapping[2];
725 s = channel_mapping[2];
729 c = channel_mapping[0];
730 l = channel_mapping[1];
731 r = channel_mapping[2];
732 s = channel_mapping[3];
737 sl = channel_mapping[2];
738 sr = channel_mapping[3];
742 c = channel_mapping[0];
743 l = channel_mapping[1];
744 r = channel_mapping[2];
745 sl = channel_mapping[3];
746 sr = channel_mapping[4];
754 for (i = 0; i < 256; i++) {
755 samples[0][i] += samples[lf_buf][i] * coef[lf_idx][0];
756 samples[1][i] += samples[lf_buf][i] * coef[lf_idx][1];
761 #ifndef decode_blockcodes 767 int offset = (levels - 1) >> 1;
769 for (i = 0; i < 4; i++) {
770 int div =
FASTDIV(code, levels);
771 values[i] = code - offset - div * levels;
792 const uint32_t *quant_step_table;
816 uint32_t quant_step_size = quant_step_table[abits];
823 sizeof(subband_samples[l][0]));
836 if (abits >= 11 || !dca_smpl_bitalloc[abits].
vlc[sel].table) {
839 int block_code1, block_code2,
size, levels, err;
847 levels, subband_samples[l]);
850 "ERROR: block code look-up failed\n");
856 subband_samples[l][m] =
get_sbits(&s->
gb, abits - 3);
862 &dca_smpl_bitalloc[abits], sel);
887 (int64_t)subband_samples[l][m - 1];
888 for (n = 2; n <= 4; n++)
891 (int64_t)subband_samples[l][m - n];
895 subband_samples[l][m] += (
int32_t)(sum + (1 << 12) >> 13);
911 "Stream with high frequencies VQ coding\n");
976 M_SQRT1_2 / 32768.0);
990 for (i = 511; i > 0; i--) {
992 samples[2 * i + 1] = samples[i];
994 samples[1] = samples[0];
1012 int in,
out, aux_data_count, aux_data_end, reserved;
1020 if (!base_channel) {
1040 "Auxiliary Decode Time Stamp Flag");
1073 "Invalid mode %d for embedded downmix coefficients\n",
1080 if ((tmp & 0xFF) > 241) {
1082 "Invalid downmix coefficient code %"PRIu16
"\n",
1101 "Core auxiliary data reserved content");
1157 int sign = (code >> 8) - 1;
1165 int core_ss_end, ret = 0;
1185 int ext_amode, xch_fsize;
1202 if ((ext_amode =
get_bits(&s->
gb, 4)) != 1) {
1204 "XCh extension amode %d not supported!\n",
1269 if (s->
amode < 16) {
1291 channels = num_core_channels + !!s->
lfe;
1303 if (channels > !!s->
lfe &&
1307 if (num_core_channels + !!s->
lfe > 2 &&
1320 for (i = 0; i < num_core_channels + !!s->
lfe; i++) {
1330 "Invalid channel mode %d\n", am);
1333 if (num_core_channels + !!s->
lfe >
1339 for (i = 0; i < num_core_channels + !!s->
lfe; i++) {
1345 for (i = 0; i < num_core_channels + !!s->
lfe; i++) {
1366 int *got_frame_ptr,
AVPacket *avpkt)
1370 int buf_size = avpkt->
size;
1373 int num_core_channels = 0;
1375 float **samples_flt;
1377 int channels, full_channels;
1433 "DCA: too many residual channels (%d, core channels %d). Disabling XLL\n",
1436 }
else if (xll_nb_samples != frame->
nb_samples &&
1439 "DCA: unsupported upsampling (%d XLL samples, %d core samples). Disabling XLL\n",
1443 if (2 * frame->
nb_samples == xll_nb_samples) {
1445 "XLL: upsampling core channels by a factor of 2\n");
1486 full_channels - channels,
1495 unsigned block = upsample ? 512 : 256;
1496 for (ch = 0; ch < channels; ch++)
1498 for (; ch < full_channels; ch++)
1516 for (i = 0; i < 2 * s->
lfe * 4; i++)
int wrap
wrap for get_vlc2()
const float ff_dca_lfe_xll_fir_64[256]
int ext_descr
extension audio descriptor flag
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static const int8_t bitalloc_offsets[10]
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
DCAChan dca_chan[DCA_PRIM_CHANNELS_MAX]
int crc_present
crc is present in the bitstream
static int set_channel_layout(AVCodecContext *avctx, int channels, int num_core_channels)
This structure describes decoded (raw) audio or video data.
const int8_t ff_dca_channel_reorder_lfe_xch[16][9]
int timestamp
embedded time stamp flag
int amode
audio channels arrangement
static int decode_blockcodes(int code1, int code2, int levels, int32_t *values)
lossless extension in ExSS
static const uint16_t tmode_codes[TMODE_COUNT][4]
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
const uint32_t ff_dca_lossy_quant[32]
static void skip_bits_long(GetBitContext *s, int n)
FmtConvertContext fmt_conv
static int dca_parse_frame_header(DCAContext *s)
void(* lfe_fir[2])(float *out, const float *in, const float *coefs)
int32_t subband_samples[DCA_BLOCKS_MAX][DCA_SUBBANDS][SAMPLES_PER_SUBBAND]
#define AV_OPT_FLAG_AUDIO_PARAM
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, 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)
int samples_deficit
deficit sample count
uint8_t core_downmix
embedded downmix coefficients available
#define DCA_MAX_FRAME_SIZE
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 version
encoder software revision
av_cold void ff_dcadsp_init(DCADSPContext *s)
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
#define FF_ARRAY_ELEMS(a)
#define AV_CH_LAYOUT_STEREO
static BitAlloc dca_scalefactor
scalefactor VLCs
#define init_vlc(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, flags)
static void lfe_interpolation_fir(DCAContext *s, const float *samples_in, float *samples_out)
static int get_sbits(GetBitContext *s, int n)
av_cold void ff_synth_filter_init(SynthFilterContext *c)
const float ff_dca_fir_32bands_nonperfect[512]
Macro definitions for various function/variable attributes.
int maxbits[8]
max bits in VLC
const int8_t ff_dca_high_freq_vq[1024][32]
int32_t scale_factor[DCA_SUBBANDS][2]
scale factors (2 if transient)
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]
const float ff_dca_fir_64bands[1024]
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...
int xll_channels
total number of channels (in all channel sets)
static BitAlloc dca_tmode
transition mode VLCs
#define DCA_MAX_EXSS_HEADER_SIZE
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)
int joint_scale_factor[DCA_SUBBANDS]
joint subband scale factors
static int dca_subframe_header(DCAContext *s, int base_channel, int block_index)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
static int dca_decode_block(DCAContext *s, int base_channel, int block_index)
Decode a dca frame block.
const uint32_t ff_dca_bit_rates[32]
static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
enum AVSampleFormat sample_fmt
audio sample format
int xch_base_channel
index of first (only) channel containing XCH data
void(* decode_hf)(int32_t dst[DCA_SUBBANDS][SAMPLES_PER_SUBBAND], 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)
int xll_residual_channels
number of residual channels
int dca_buffer_size
how much data is in the dca_buffer
#define MIX_REAR2(samples, s1, s2, rs, coef)
static void get_array(GetBitContext *gb, int *dst, int len, int bits)
96/24 extension in core substream
static av_cold int dca_decode_end(AVCodecContext *avctx)
const uint16_t ff_dca_vlc_offs[63]
#define AV_CH_LOW_FREQUENCY
int header_crc
header crc check bytes
XllChSetSubHeader xll_chsets[DCA_XLL_CHSETS_MAX]
static int get_bits_count(const GetBitContext *s)
int sample_rate
audio sampling rate
bitstream reader API header.
static BitAlloc dca_bitalloc_index
indexes for samples VLC select
const int8_t ff_dca_channel_reorder_nolfe[16][9]
int lfe
low frequency effects flag
static BitAlloc dca_smpl_bitalloc[11]
samples VLCs
int bitalloc[DCA_SUBBANDS]
bit allocation index
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)
int predictor_history
predictor history flag
int dynrange_coef
dynamic range coefficient
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)
int transition_mode[DCA_SUBBANDS]
transition mode (transients)
const float ff_dca_lfe_fir_128[256]
#define MIX_REAR1(samples, s1, rs, coef)
static const uint16_t bitalloc_12_codes[BITALLOC_12_COUNT][12]
const uint32_t ff_dca_lossless_quant[32]
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. ...
const uint16_t ff_dca_dmixtable[FF_DCA_DMIXTABLE_SIZE]
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
const float ff_dca_lfe_fir_64[256]
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
#define FF_PROFILE_DTS_ES
int flags
AV_CODEC_FLAG_*.
static const uint8_t bitalloc_12_bits[BITALLOC_12_COUNT][12]
const char * name
Name of the codec implementation.
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
static void qmf_32_subbands(DCAContext *s, int chans, float samples_in[DCA_SUBBANDS][SAMPLES_PER_SUBBAND], float *samples_out, float scale)
uint64_t channel_layout
Audio channel layout.
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]
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
float subband_fir_noidea[64]
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
int32_t subband_samples_hist[DCA_SUBBANDS][4]
static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
int surround_sum
surround sum/difference flag
static av_cold void dca_init_vlcs(void)
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 prediction_mode[DCA_SUBBANDS]
prediction mode (ADPCM used or not)
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.
#define AV_CH_FRONT_LEFT_OF_CENTER
void(* qmf_32_subbands)(float samples_in[DCA_SUBBANDS][SAMPLES_PER_SUBBAND], 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)
#define AV_CH_FRONT_CENTER
#define DCA_SUBBANDS_X96K
av_cold void ff_fmt_convert_init(FmtConvertContext *c, AVCodecContext *avctx)
uint8_t core_downmix_amode
audio channel arrangement of embedded downmix
const uint32_t avpriv_dca_sample_rates[16]
int joint_huff
joint subband scale factors codebook
int bit_rate
transmission bit rate
static const uint8_t *const bitalloc_bits[10][8]
int offset
code values offset
static const uint8_t abits_levels[7]
#define AV_CH_FRONT_RIGHT_OF_CENTER
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.
const int16_t ff_dca_adpcm_vb[4096][4]
const uint32_t ff_dca_scale_factor_quant7[128]
int core_ext_mask
present extensions in the core substream
int ff_dca_xll_decode_audio(DCAContext *s, AVFrame *frame)
#define FF_PROFILE_DTS_96_24
const uint8_t ff_dca_channels[16]
#define AV_LOG_INFO
Standard information.
static int dca_filter_channels(DCAContext *s, int block_index, int upsample)
Libavcodec external API header.
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)
main external API structure.
int copy_history
copy history
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
const float ff_dca_default_coeffs[10][6][2]
const int8_t ff_dca_channel_reorder_nolfe_xch[16][9]
static unsigned int get_bits1(GetBitContext *s)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;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);return NULL;} return ac;} 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;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->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);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
static void skip_bits1(GetBitContext *s)
Describe the class of an AVClass context structure.
int exss_ext_mask
Non-core extensions.
static void skip_bits(GetBitContext *s, int n)
const uint32_t ff_dca_scale_factor_quant6[64]
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
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static const uint64_t dca_core_channel_layout[]
int sample_blocks
number of PCM sample blocks
DCAAudioHeader audio_header
static const uint8_t abits_sizes[7]
const int8_t ff_dca_channel_reorder_lfe[16][9]
int xll_segments
number of segments per frame
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static const AVOption options[]
void(* dequantize)(int32_t *samples, uint32_t step_size, uint32_t scale)
static int decode_blockcode(int code, int levels, int32_t *values)
#define AV_CH_BACK_CENTER
av_cold void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact)
Initialize a float DSP context.
const AVProfile ff_dca_profiles[]
static av_cold int dca_decode_init(AVCodecContext *avctx)
DCA initialization.
static int scan_for_extensions(AVCodecContext *avctx)
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
common internal api header.
static void qmf_64_subbands(DCAContext *s, int chans, float samples_in[DCA_SUBBANDS_X96K][SAMPLES_PER_SUBBAND], float *samples_out, float scale)
common internal and external API header
#define LOCAL_ALIGNED(a, t, v,...)
uint8_t * extra_channels_buffer
#define INIT_VLC_USE_NEW_STATIC
static const uint16_t scales_codes[SCALES_COUNT][129]
int dialog_norm
dialog normalisation parameter
int prediction_vq[DCA_SUBBANDS]
prediction VQ coefs
int32_t high_freq_vq[DCA_SUBBANDS]
VQ encoded high frequency subbands.
int xll_smpl_in_seg
samples in segment per one frequency band for the first channel set
static av_cold int init(AVCodecParserContext *s)
int bit_rate_index
transmission bit rate index
void ff_dca_exss_parse_header(DCAContext *s)
Parse extension substream header (HD)
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]
int channels
number of audio channels
VLC_TYPE(* table)[2]
code, bits
float * samples_chanptr[DCA_PRIM_CHANNELS_MAX+1]
int subsubframes[DCA_SUBFRAMES_MAX]
number of subsubframes
QMF64_table * qmf64_table
static const int dca_ext_audio_descr_mask[]
XCh channel extension in core substream.
static const uint8_t * align_get_bits(GetBitContext *s)
#define DOWNMIX_TO_STEREO(op1, op2)
void(* int32_to_float)(float *dst, const int32_t *src, intptr_t len)
Convert an array of int32_t to float.
int frame_size
primary frame byte size
static QMF64_table * qmf64_precompute(void)
static enum AVSampleFormat sample_fmts[]
int aspf
audio sync word insertion flag
float downmix_coef[DCA_PRIM_CHANNELS_MAX+1][2]
stereo downmix coefficients
static const uint8_t bitalloc_12_vlc_bits[BITALLOC_12_COUNT]
static int get_scale(GetBitContext *gb, int level, int value, int log2range)
const float ff_dca_fir_32bands_perfect[512]
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)
const int8_t ff_dca_lfe_index[16]
int partial_samples[DCA_SUBFRAMES_MAX]
partial subsubframe samples count
static const AVClass dca_decoder_class
float subband_fir_hist[1024]
This structure stores compressed data.
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
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
#define SAMPLES_PER_SUBBAND
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)
#define DCA_PRIM_CHANNELS_MAX
int frame_type
type of the current frame
XXCh channels extension in core substream.