diff options
author | Daniil Cherednik <dan.cherednik@gmail.com> | 2017-02-20 23:22:51 +0000 |
---|---|---|
committer | Rostislav Pehlivanov <atomnuker@gmail.com> | 2017-05-08 05:56:14 +0100 |
commit | b8c2b9c39279171f647d9c81f34ffa3d3ae93c47 (patch) | |
tree | fc50e13f8009274c05ab06eeeb80757b6dc10a94 /libavcodec/dca_core.h | |
parent | 5f928c5201c077b9765610bc5304235c3f1d9bd6 (diff) | |
download | ffmpeg-b8c2b9c39279171f647d9c81f34ffa3d3ae93c47.tar.gz |
avcodec/dcaenc: Initial implementation of ADPCM encoding for DCA encoder
Diffstat (limited to 'libavcodec/dca_core.h')
-rw-r--r-- | libavcodec/dca_core.h | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/libavcodec/dca_core.h b/libavcodec/dca_core.h index e84bdab18e..7dcfb13bc7 100644 --- a/libavcodec/dca_core.h +++ b/libavcodec/dca_core.h @@ -33,6 +33,7 @@ #include "dca_exss.h" #include "dcadsp.h" #include "dcadct.h" +#include "dcamath.h" #include "dcahuff.h" #include "fft.h" #include "synth_filter.h" @@ -43,7 +44,6 @@ #define DCA_SUBFRAMES 16 #define DCA_SUBBAND_SAMPLES 8 #define DCA_PCMBLOCK_SAMPLES 32 -#define DCA_ADPCM_COEFFS 4 #define DCA_LFE_HISTORY 8 #define DCA_ABITS_MAX 26 @@ -195,6 +195,29 @@ static inline int ff_dca_core_map_spkr(DCACoreDecoder *core, int spkr) return -1; } +static inline void ff_dca_core_dequantize(int32_t *output, const int32_t *input, + int32_t step_size, int32_t scale, int residual, int len) +{ + // Account for quantizer step size + int64_t step_scale = (int64_t)step_size * scale; + int n, shift = 0; + + // Limit scale factor resolution to 22 bits + if (step_scale > (1 << 23)) { + shift = av_log2(step_scale >> 23) + 1; + step_scale >>= shift; + } + + // Scale the samples + if (residual) { + for (n = 0; n < len; n++) + output[n] += clip23(norm__(input[n] * step_scale, 22 - shift)); + } else { + for (n = 0; n < len; n++) + output[n] = clip23(norm__(input[n] * step_scale, 22 - shift)); + } +} + int ff_dca_core_parse(DCACoreDecoder *s, uint8_t *data, int size); int ff_dca_core_parse_exss(DCACoreDecoder *s, uint8_t *data, DCAExssAsset *asset); int ff_dca_core_filter_fixed(DCACoreDecoder *s, int x96_synth); |