Go to the documentation of this file.
46 #define MAX_CHANNELS 6
47 #define DCA_MAX_FRAME_SIZE 16384
48 #define DCA_HEADER_SIZE 13
49 #define DCA_LFE_SAMPLES 8
51 #define DCAENC_SUBBANDS 32
53 #define SUBSUBFRAMES 2
54 #define SUBBAND_SAMPLES (SUBFRAMES * SUBSUBFRAMES * 8)
57 #define COS_T(x) (c->cos_table[(x) & 2047])
117 double f1 =
f / 1000;
119 return -3.64 * pow(f1, -0.8)
120 + 6.8 *
exp(-0.6 * (f1 - 3.4) * (f1 - 3.4))
121 - 6.0 *
exp(-0.15 * (f1 - 8.7) * (f1 - 8.7))
122 - 0.0006 * (f1 * f1) * (f1 * f1);
131 return 20 * log10(
h);
147 c->subband[ch][band] = bufer +
157 if (
c->subband[0][0]) {
160 c->subband[0][0] =
NULL;
168 int i, j, k, min_frame_bits;
174 c->fullband_channels =
c->channels =
layout.nb_channels;
175 c->lfe_channel = (
c->channels == 3 ||
c->channels == 6);
176 c->band_interpolation =
c->band_interpolation_tab[1];
177 c->band_spectrum =
c->band_spectrum_tab[1];
178 c->worst_quantization_noise = -2047;
179 c->worst_noise_ever = -2047;
180 c->consumed_adpcm_bits = 0;
187 "encoder will guess the layout, but it "
188 "might be incorrect.\n");
193 c->channel_config = 0;
195 c->channel_config = 2;
197 c->channel_config = 8;
199 c->channel_config = 9;
201 c->channel_config = 9;
207 if (
c->lfe_channel) {
208 c->fullband_channels--;
219 c->bit_allocation_sel[
i] = 6;
223 c->prediction_mode[
i][j] = -1;
228 for (
i = 0;
i < 9;
i++) {
234 c->samplerate_index =
i;
242 c->bitrate_index =
i;
244 min_frame_bits = 132 + (493 + 28 * 32) *
c->fullband_channels +
c->lfe_channel * 72;
248 c->frame_size = (
c->frame_bits + 7) / 8;
256 c->cos_table[0] = 0x7fffffff;
257 c->cos_table[512] = 0;
258 c->cos_table[1024] = -
c->cos_table[0];
259 for (
i = 1;
i < 512;
i++) {
261 c->cos_table[1024-
i] = -
c->cos_table[
i];
262 c->cos_table[1024+
i] = -
c->cos_table[
i];
263 c->cos_table[2048-
i] = +
c->cos_table[
i];
266 for (
i = 0;
i < 2048;
i++)
269 for (k = 0; k < 32; k++) {
270 for (j = 0; j < 8; j++) {
276 for (
i = 0;
i < 512;
i++) {
281 for (
i = 0;
i < 9;
i++) {
282 for (j = 0; j <
AUBANDS; j++) {
283 for (k = 0; k < 256; k++) {
291 for (
i = 0;
i < 256;
i++) {
295 for (j = 0; j < 8; j++) {
297 for (
i = 0;
i < 512;
i++) {
299 accum += reconst * cos(2 *
M_PI * (
i + 0.5 - 256) * (j + 0.5) / 512);
301 c->band_spectrum_tab[0][j] = (
int32_t)(200 * log10(accum));
303 for (j = 0; j < 8; j++) {
305 for (
i = 0;
i < 512;
i++) {
307 accum += reconst * cos(2 *
M_PI * (
i + 0.5 - 256) * (j + 0.5) / 512);
309 c->band_spectrum_tab[1][j] = (
int32_t)(200 * log10(accum));
327 int ch, subs,
i, k, j;
329 for (ch = 0; ch <
c->fullband_channels; ch++) {
333 const int chi =
c->channel_order_tab[ch];
335 memcpy(hist, &
c->history[ch][0], 512 *
sizeof(
int32_t));
343 memset(accum, 0, 64 *
sizeof(
int32_t));
345 for (k = 0,
i = hist_start, j = 0;
346 i < 512; k = (k + 1) & 63,
i++, j++)
347 accum[k] +=
mul32(hist[
i],
c->band_interpolation[j]);
348 for (
i = 0;
i < hist_start; k = (k + 1) & 63,
i++, j++)
349 accum[k] +=
mul32(hist[
i],
c->band_interpolation[j]);
351 for (k = 16; k < 32; k++)
352 accum[k] = accum[k] - accum[31 - k];
353 for (k = 32; k < 48; k++)
354 accum[k] = accum[k] + accum[95 - k];
356 for (band = 0; band < 32; band++) {
358 for (
i = 16;
i < 48;
i++) {
359 int s = (2 * band + 1) * (2 * (
i + 16) + 1);
363 c->subband[ch][band][subs] = ((band + 1) & 2) ? -resp : resp;
367 for (
i = 0;
i < 32;
i++)
368 hist[
i + hist_start] =
input[(subs * 32 +
i) *
c->channels + chi];
370 hist_start = (hist_start + 32) & 511;
378 const int lfech =
lfe_index[
c->channel_config];
384 memcpy(hist, &
c->history[
c->channels - 1][0], 512 *
sizeof(
int32_t));
390 for (
i = hist_start, j = 0;
i < 512;
i++, j++)
391 accum +=
mul32(hist[
i],
c->lfe_fir_64i[j]);
392 for (
i = 0;
i < hist_start;
i++, j++)
393 accum +=
mul32(hist[
i],
c->lfe_fir_64i[j]);
395 c->downsampled_lfe[lfes] = accum;
398 for (
i = 0;
i < 64;
i++)
399 hist[
i + hist_start] =
input[(lfes * 64 +
i) *
c->channels + lfech];
401 hist_start = (hist_start + 64) & 511;
410 for (
i = 1024;
i > 0;
i >>= 1) {
411 if (
c->cb_to_level[
i + res] >= in)
424 return a +
c->cb_to_add[
a -
b];
434 for (
i = 0;
i < 512;
i++)
438 for (
i = 0;
i < 256;
i++) {
452 const int samplerate_index =
c->samplerate_index;
457 for (j = 0; j < 256; j++)
458 out_cb_unnorm[j] = -2047;
462 for (j = 0; j < 256; j++)
463 denom =
add_cb(
c, denom,
power[j] +
c->auf[samplerate_index][
i][j]);
464 for (j = 0; j < 256; j++)
465 out_cb_unnorm[j] =
add_cb(
c, out_cb_unnorm[j],
466 -denom +
c->auf[samplerate_index][
i][j]);
469 for (j = 0; j < 256; j++)
470 out_cb[j] =
add_cb(
c, out_cb[j], -out_cb_unnorm[j] - ca_cb - cs_cb);
483 for (
f = 0;
f < 4;
f++)
486 for (
f = 0;
f < 8;
f++)
487 walk(
c, band, band - 1, 8 * band - 4 +
f,
498 for (
f = 0;
f < 4;
f++)
501 for (
f = 0;
f < 8;
f++)
502 walk(
c, band, band + 1, 8 * band + 4 +
f,
513 if (value < c->band_masking_cb[band1])
514 c->band_masking_cb[band1] =
value;
519 int i, k, band, ch, ssf;
522 for (
i = 0;
i < 256;
i++)
524 c->masking_curve_cb[ssf][
i] = -2047;
527 for (ch = 0; ch <
c->fullband_channels; ch++) {
528 const int chi =
c->channel_order_tab[ch];
530 for (
i = 0, k = 128 + 256 * ssf; k < 512;
i++, k++)
531 data[
i] =
c->history[ch][k];
532 for (k -= 512;
i < 512;
i++, k++)
536 for (
i = 0;
i < 256;
i++) {
540 if (
c->masking_curve_cb[ssf][
i] < m)
541 m =
c->masking_curve_cb[ssf][
i];
542 c->eff_masking_curve_cb[
i] = m;
545 for (band = 0; band < 32; band++) {
546 c->band_masking_cb[band] = 2048;
568 for (ch = 0; ch <
c->fullband_channels; ch++) {
569 for (band = 0; band < 32; band++)
570 c->peak_cb[ch][band] =
find_peak(
c,
c->subband[ch][band],
585 c->consumed_adpcm_bits = 0;
586 for (ch = 0; ch <
c->fullband_channels; ch++) {
587 for (band = 0; band < 32; band++) {
591 if (pred_vq_id >= 0) {
592 c->prediction_mode[ch][band] = pred_vq_id;
593 c->consumed_adpcm_bits += 12;
594 c->diff_peak_cb[ch][band] =
find_peak(
c, estimated_diff, 16);
596 c->prediction_mode[ch][band] = -1;
603 #define USED_1ABITS 1
604 #define USED_26ABITS 4
610 if (
c->bitrate_index == 3)
622 int our_nscale, try_remove;
629 peak =
c->cb_to_level[-peak_cb];
631 for (try_remove = 64; try_remove > 0; try_remove >>= 1) {
638 our_nscale -= try_remove;
641 if (our_nscale >= 125)
654 int32_t diff_peak_cb =
c->diff_peak_cb[ch][band];
657 &
c->quant[ch][band]);
663 step_size,
c->adpcm_history[ch][band],
c->subband[ch][band],
664 c->adpcm_history[ch][band] + 4,
c->quantized[ch][band],
672 for (ch = 0; ch <
c->fullband_channels; ch++)
673 for (band = 0; band < 32; band++)
674 if (
c->prediction_mode[ch][band] >= 0)
682 for (ch = 0; ch <
c->fullband_channels; ch++) {
683 for (band = 0; band < 32; band++) {
684 if (
c->prediction_mode[ch][band] == -1) {
698 uint8_t sel,
id = abits - 1;
711 uint32_t t,
bits = 0;
716 if (vlc_bits[
i][0] == 0) {
723 best_sel_bits[
i] = vlc_bits[
i][0];
726 if (best_sel_bits[
i] > vlc_bits[
i][sel] && vlc_bits[
i][sel]) {
727 best_sel_bits[
i] = vlc_bits[
i][sel];
728 best_sel_id[
i] = sel;
733 t = best_sel_bits[
i] + 2;
734 if (t < clc_bits[
i]) {
735 res[
i] = best_sel_id[
i];
755 if (abits[
i] > 12 || abits[
i] == 0) {
778 uint32_t bits_counter = 0;
780 c->consumed_bits = 132 + 333 *
c->fullband_channels;
781 c->consumed_bits +=
c->consumed_adpcm_bits;
783 c->consumed_bits += 72;
786 for (ch = 0; ch <
c->fullband_channels; ch++) {
787 for (band = 0; band < 32; band++) {
788 int snr_cb =
c->peak_cb[ch][band] -
c->band_masking_cb[band] -
noise;
790 if (snr_cb >= 1312) {
791 c->abits[ch][band] = 26;
793 }
else if (snr_cb >= 222) {
794 c->abits[ch][band] = 8 +
mul32(snr_cb - 222, 69000000);
796 }
else if (snr_cb >= 0) {
797 c->abits[ch][band] = 2 +
mul32(snr_cb, 106000000);
799 }
else if (forbid_zero || snr_cb >= -140) {
800 c->abits[ch][band] = 1;
803 c->abits[ch][band] = 0;
808 &
c->bit_allocation_sel[ch]);
814 for (ch = 0; ch <
c->fullband_channels; ch++) {
815 for (band = 0; band < 32; band++) {
816 if (
c->prediction_mode[ch][band] == -1) {
819 &
c->quant[ch][band]);
828 for (ch = 0; ch <
c->fullband_channels; ch++) {
829 for (band = 0; band < 32; band++) {
832 c->quantized[ch][band],
833 huff_bit_count_accum[ch][
c->abits[ch][band] - 1]);
834 clc_bit_count_accum[ch][
c->abits[ch][band] - 1] +=
bit_consumption[
c->abits[ch][band]];
841 for (ch = 0; ch <
c->fullband_channels; ch++) {
843 clc_bit_count_accum[ch],
844 c->quant_index_sel[ch]);
847 c->consumed_bits += bits_counter;
860 low = high =
c->worst_quantization_noise;
861 if (
c->consumed_bits >
c->frame_bits) {
862 while (
c->consumed_bits >
c->frame_bits) {
872 while (
c->consumed_bits <=
c->frame_bits) {
882 for (down =
snr_fudge >> 1; down; down >>= 1) {
884 if (
c->consumed_bits <=
c->frame_bits)
889 c->worst_quantization_noise = high;
890 if (high >
c->worst_noise_ever)
891 c->worst_noise_ever = high;
898 for (k = 0; k < 512; k++)
899 for (ch = 0; ch <
c->channels; ch++) {
900 const int chi =
c->channel_order_tab[ch];
902 c->history[ch][k] =
input[k *
c->channels + chi];
914 for (ch = 0; ch <
c->channels; ch++) {
915 for (band = 0; band < 32; band++) {
917 if (
c->prediction_mode[ch][band] == -1) {
921 c->quantized[ch][band]+12, step_size,
924 AV_COPY128U(
c->adpcm_history[ch][band],
c->adpcm_history[ch][band]+4);
934 samples[0] =
c->adpcm_history[ch][band][0] * (1 << 7);
935 samples[1] =
c->adpcm_history[ch][band][1] * (1 << 7);
936 samples[2] =
c->adpcm_history[ch][band][2] * (1 << 7);
937 samples[3] =
c->adpcm_history[ch][band][3] * (1 << 7);
1038 put_bits(&
c->pb, 3,
c->fullband_channels - 1);
1041 for (ch = 0; ch <
c->fullband_channels; ch++)
1045 for (ch = 0; ch <
c->fullband_channels; ch++)
1049 for (ch = 0; ch <
c->fullband_channels; ch++)
1053 for (ch = 0; ch <
c->fullband_channels; ch++)
1057 for (ch = 0; ch <
c->fullband_channels; ch++)
1061 for (ch = 0; ch <
c->fullband_channels; ch++)
1062 put_bits(&
c->pb, 3,
c->bit_allocation_sel[ch]);
1066 for (ch = 0; ch <
c->fullband_channels; ch++)
1071 for (ch = 0; ch <
c->fullband_channels; ch++)
1080 int i, j, sum,
bits, sel;
1083 sel =
c->quant_index_sel[ch][
c->abits[ch][band] - 1];
1087 sel,
c->abits[ch][band] - 1);
1092 if (
c->abits[ch][band] <= 7) {
1093 for (
i = 0;
i < 8;
i += 4) {
1095 for (j = 3; j >= 0; j--) {
1097 sum +=
c->quantized[ch][band][
ss * 8 +
i + j];
1106 for (
i = 0;
i < 8;
i++) {
1114 int i, band,
ss, ch;
1123 for (ch = 0; ch <
c->fullband_channels; ch++)
1125 put_bits(&
c->pb, 1, !(
c->prediction_mode[ch][band] == -1));
1128 for (ch = 0; ch <
c->fullband_channels; ch++)
1130 if (
c->prediction_mode[ch][band] >= 0)
1131 put_bits(&
c->pb, 12,
c->prediction_mode[ch][band]);
1134 for (ch = 0; ch <
c->fullband_channels; ch++) {
1135 if (
c->bit_allocation_sel[ch] == 6) {
1141 c->bit_allocation_sel[ch]);
1147 for (ch = 0; ch <
c->fullband_channels; ch++)
1149 if (
c->abits[ch][band])
1154 for (ch = 0; ch <
c->fullband_channels; ch++)
1156 if (
c->abits[ch][band])
1157 put_bits(&
c->pb, 7,
c->scale_factor[ch][band]);
1167 if (
c->lfe_channel) {
1175 for (ch = 0; ch <
c->fullband_channels; ch++)
1177 if (
c->abits[ch][band])
1201 if (
c->options.adpcm_mode)
1220 *got_packet_ptr = 1;
1224 #define DCAENC_FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
1232 .
class_name =
"DCA (DTS Coherent Acoustics)",
1257 #if FF_API_OLD_CHANNEL_LAYOUT
static void lfe_downsample(DCAEncContext *c, const int32_t *input)
int frame_size
Number of samples per channel in an audio frame.
#define AV_LOG_WARNING
Something somehow does not look correct.
static av_always_inline double ff_exp10(double x)
Compute 10^x for floating point values.
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int ff_dcaadpcm_do_real(int pred_vq_index, softfloat quant, int32_t scale_factor, int32_t step_size, const int32_t *prev_hist, const int32_t *in, int32_t *next_hist, int32_t *out, int len, int32_t peak)
int32_t * subband[MAX_CHANNELS][DCAENC_SUBBANDS]
int sample_rate
samples per second
static double cb(void *priv, double x, double y)
static const AVOption options[]
#define AV_CHANNEL_LAYOUT_5POINT1
static void walk_band_low(DCAEncContext *c, int band, int channel, walk_band_t walk, int32_t *arg)
const uint32_t ff_dca_bit_rates[32]
#define AV_CH_LAYOUT_MONO
av_cold void ff_dcaadpcm_free(DCAADPCMEncContext *s)
static const softfloat scalefactor_inv[128]
static void put_sbits(PutBitContext *pb, int n, int32_t value)
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static const uint16_t erb[]
static const uint8_t lfe_index[7]
static void put_subframe(DCAEncContext *c, int subframe)
This structure describes decoded (raw) audio or video data.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
CompressionOptions options
static int32_t get_step_size(DCAEncContext *c, int ch, int band)
const uint32_t ff_dca_lossy_quant[32]
#define AV_CHANNEL_LAYOUT_MONO
static void calc_lfe_scales(DCAEncContext *c)
int32_t adpcm_history[MAX_CHANNELS][DCAENC_SUBBANDS][DCA_ADPCM_COEFFS *2]
#define fc(width, name, range_min, range_max)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
#define AV_CHANNEL_LAYOUT_STEREO
static void update_band_masking(DCAEncContext *c, int band1, int band2, int f, int32_t spectrum1, int32_t spectrum2, int channel, int32_t *arg)
static int calc_one_scale(DCAEncContext *c, int32_t peak_cb, int abits, softfloat *quant)
static int32_t quantize_value(int32_t value, softfloat quant)
const int32_t * band_interpolation
static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
static void put_frame_header(DCAEncContext *c)
DCAADPCMEncContext adpcm_ctx
uint32_t ff_dca_vlc_calc_alloc_bits(int *values, uint8_t n, uint8_t sel)
int32_t history[MAX_CHANNELS][512]
static void calc_masking(DCAEncContext *c, const int32_t *input)
#define AV_CHANNEL_LAYOUT_5POINT0
AVCodec p
The public AVCodec.
static void adpcm_analysis(DCAEncContext *c)
const float ff_dca_fir_32bands_nonperfect[512]
AVChannelLayout ch_layout
Audio channel layout.
const uint8_t ff_dca_quant_index_group_size[DCA_CODE_BOOKS]
static void accumulate_huff_bit_consumption(int abits, int32_t *quantized, uint32_t *result)
static int init_quantization_noise(DCAEncContext *c, int noise, int forbid_zero)
static double val(void *priv, double ch)
const uint32_t ff_dca_quant_levels[32]
#define ss(width, name, subs,...)
#define FF_CODEC_ENCODE_CB(func)
int32_t auf[9][AUBANDS][256]
#define AV_CH_LAYOUT_STEREO
static int quant(float coef, const float Q, const float rounding)
Quantize one coefficient.
static int put_bytes_left(const PutBitContext *s, int round_up)
static const int bit_consumption[27]
static void walk_band_high(DCAEncContext *c, int band, int channel, walk_band_t walk, int32_t *arg)
static void quantize_adpcm_subband(DCAEncContext *c, int ch, int band)
int32_t quantized[MAX_CHANNELS][DCAENC_SUBBANDS][SUBBAND_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 AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
#define AV_CHANNEL_LAYOUT_2_2
const FFCodec ff_dca_encoder
static void quantize_adpcm(DCAEncContext *c)
int abits[MAX_CHANNELS][DCAENC_SUBBANDS]
int32_t peak_cb[MAX_CHANNELS][DCAENC_SUBBANDS]
const int32_t * band_spectrum
static double hom(double f)
int32_t eff_masking_curve_cb[256]
int32_t downsampled_lfe[DCA_LFE_SAMPLES]
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
static uint32_t set_best_abits_code(int abits[DCAENC_SUBBANDS], int bands, int32_t *res)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static const float bands[]
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
and forward the result(frame or status change) to the corresponding input. If nothing is possible
static void adjust_jnd(DCAEncContext *c, const int32_t in[512], int32_t out_cb[256])
#define LOCAL_ALIGNED_32(t, v,...)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
const uint32_t ff_dca_lossless_quant[32]
static int32_t mul32(int32_t a, int32_t b)
const float ff_dca_lfe_fir_64[256]
#define AV_COPY128U(d, s)
int64_t bit_rate
the average bitrate
const char * av_default_item_name(void *ptr)
Return the context name.
uint32_t ff_dca_vlc_calc_quant_bits(int *values, uint8_t n, uint8_t sel, uint8_t table)
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
static const softfloat stepsize_inv[27]
#define AV_CH_LAYOUT_5POINT1
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
int32_t band_masking_cb[32]
static const FFCodecDefault defaults[]
int ff_dcaadpcm_subband_analysis(const DCAADPCMEncContext *s, const int32_t *in, int len, int *diff)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static av_cold int encode_close(AVCodecContext *avctx)
int32_t worst_quantization_noise
int32_t band_interpolation_tab[2][512]
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
const uint32_t ff_dca_scale_factor_quant7[128]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static void subband_bufer_free(DCAEncContext *c)
softfloat quant[MAX_CHANNELS][DCAENC_SUBBANDS]
An AVChannelLayout holds information about the channel layout of audio data.
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 add_cb(DCAEncContext *c, int32_t a, int32_t b)
#define DCA_BITALLOC_12_COUNT
static int encode_init(AVCodecContext *avctx)
static void fill_in_adpcm_bufer(DCAEncContext *c)
#define DCA_MAX_FRAME_SIZE
static void quantize_pcm(DCAEncContext *c)
int32_t masking_curve_cb[SUBSUBFRAMES][256]
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
static void put_primary_audio_header(DCAEncContext *c)
int32_t quant_index_sel[MAX_CHANNELS][DCA_CODE_BOOKS]
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel layout
#define AV_CH_LAYOUT_5POINT0
static void find_peaks(DCAEncContext *c)
const uint8_t ff_dca_quant_index_sel_nbits[DCA_CODE_BOOKS]
void ff_dca_vlc_enc_quant(PutBitContext *pb, int *values, uint8_t n, uint8_t sel, uint8_t table)
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
AVSampleFormat
Audio sample formats.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
const char * name
Name of the codec implementation.
static int32_t norm__(int64_t a, int bits)
void * av_calloc(size_t nmemb, size_t size)
static const int8_t channel_reorder_nolfe[7][5]
static const int snr_fudge
#define FFSWAP(type, a, b)
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 void subband_transform(DCAEncContext *c, const int32_t *input)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
int consumed_adpcm_bits
Number of bits to transmit ADPCM related info.
static const int8_t channel_reorder_lfe[7][5]
static void ff_dca_core_dequantize(int32_t *output, const int32_t *input, int32_t step_size, int32_t scale, int residual, int len)
av_cold int ff_dcaadpcm_init(DCAADPCMEncContext *s)
main external API structure.
static float power(float r, float g, float b, float max)
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
static int noise(AVBSFContext *ctx, AVPacket *pkt)
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
Filter the word “frame” indicates either a video frame or a group of audio samples
static int subband_bufer_alloc(DCAEncContext *c)
static void assign_bits(DCAEncContext *c)
static int32_t get_cb(DCAEncContext *c, int32_t in)
static const uint8_t bitstream_sfreq[]
static float add(float src0, float src1)
static int32_t find_peak(DCAEncContext *c, const int32_t *in, int len)
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
This structure stores compressed data.
const float ff_dca_fir_32bands_perfect[512]
static void shift_history(DCAEncContext *c, const int32_t *input)
static uint32_t set_best_code(uint32_t vlc_bits[DCA_CODE_BOOKS][7], uint32_t clc_bits[DCA_CODE_BOOKS], int32_t res[DCA_CODE_BOOKS])
int32_t prediction_mode[MAX_CHANNELS][DCAENC_SUBBANDS]
void ff_dca_vlc_enc_alloc(PutBitContext *pb, int *values, uint8_t n, uint8_t sel)
static const double coeff[2][5]
int32_t cb_to_level[2048]
static void put_subframe_samples(DCAEncContext *c, int ss, int band, int ch)
int32_t bit_allocation_sel[MAX_CHANNELS]
int32_t band_spectrum_tab[2][8]
static void calc_power(DCAEncContext *c, const int32_t in[2 *256], int32_t power[256])
@ AV_SAMPLE_FMT_S32
signed 32 bits
int32_t diff_peak_cb[MAX_CHANNELS][DCAENC_SUBBANDS]
expected peak of residual signal
static const AVClass dcaenc_class
int scale_factor[MAX_CHANNELS][DCAENC_SUBBANDS]
static double gammafilter(int i, double f)
const int8_t * channel_order_tab
channel reordering table, lfe and non lfe