1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec/dca: move huffman data into separate object file

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
foo86 2016-05-01 08:41:43 -07:00 committed by James Almer
parent bc2fe36228
commit 2df7d4fa45
8 changed files with 1124 additions and 1087 deletions

View File

@ -230,7 +230,7 @@ OBJS-$(CONFIG_COMFORTNOISE_ENCODER) += cngenc.o
OBJS-$(CONFIG_CPIA_DECODER) += cpia.o OBJS-$(CONFIG_CPIA_DECODER) += cpia.o
OBJS-$(CONFIG_CSCD_DECODER) += cscd.o OBJS-$(CONFIG_CSCD_DECODER) += cscd.o
OBJS-$(CONFIG_CYUV_DECODER) += cyuv.o OBJS-$(CONFIG_CYUV_DECODER) += cyuv.o
OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadata.o \ OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadata.o dcahuff.o \
dca_core.o dca_exss.o dca_xll.o \ dca_core.o dca_exss.o dca_xll.o \
dcadsp.o dcadct.o synth_filter.o dcadsp.o dcadct.o synth_filter.o
OBJS-$(CONFIG_DCA_ENCODER) += dcaenc.o dca.o dcadata.o OBJS-$(CONFIG_DCA_ENCODER) += dcaenc.o dca.o dcadata.o

View File

@ -100,62 +100,6 @@ static const uint8_t quant_index_group_size[DCA_CODE_BOOKS] = {
1, 3, 3, 3, 3, 7, 7, 7, 7, 7 1, 3, 3, 3, 3, 7, 7, 7, 7, 7
}; };
typedef struct DCAVLC {
int offset; ///< Code values offset
int max_depth; ///< Parameter for get_vlc2()
VLC vlc[7]; ///< Actual codes
} DCAVLC;
static DCAVLC vlc_bit_allocation;
static DCAVLC vlc_transition_mode;
static DCAVLC vlc_scale_factor;
static DCAVLC vlc_quant_index[DCA_CODE_BOOKS];
static av_cold void dca_init_vlcs(void)
{
static VLC_TYPE dca_table[23622][2];
static int vlcs_initialized = 0;
int i, j, k;
if (vlcs_initialized)
return;
#define DCA_INIT_VLC(vlc, a, b, c, d) \
do { \
vlc.table = &dca_table[ff_dca_vlc_offs[k]]; \
vlc.table_allocated = ff_dca_vlc_offs[k + 1] - ff_dca_vlc_offs[k]; \
init_vlc(&vlc, a, b, c, 1, 1, d, 2, 2, INIT_VLC_USE_NEW_STATIC); \
} while (0)
vlc_bit_allocation.offset = 1;
vlc_bit_allocation.max_depth = 2;
for (i = 0, k = 0; i < 5; i++, k++)
DCA_INIT_VLC(vlc_bit_allocation.vlc[i], bitalloc_12_vlc_bits[i], 12,
bitalloc_12_bits[i], bitalloc_12_codes[i]);
vlc_scale_factor.offset = -64;
vlc_scale_factor.max_depth = 2;
for (i = 0; i < 5; i++, k++)
DCA_INIT_VLC(vlc_scale_factor.vlc[i], SCALES_VLC_BITS, 129,
scales_bits[i], scales_codes[i]);
vlc_transition_mode.offset = 0;
vlc_transition_mode.max_depth = 1;
for (i = 0; i < 4; i++, k++)
DCA_INIT_VLC(vlc_transition_mode.vlc[i], tmode_vlc_bits[i], 4,
tmode_bits[i], tmode_codes[i]);
for (i = 0; i < DCA_CODE_BOOKS; i++) {
vlc_quant_index[i].offset = bitalloc_offsets[i];
vlc_quant_index[i].max_depth = 1 + (i > 4);
for (j = 0; j < quant_index_group_size[i]; j++, k++)
DCA_INIT_VLC(vlc_quant_index[i].vlc[j], bitalloc_maxbits[i][j],
bitalloc_sizes[i], bitalloc_bits[i][j], bitalloc_codes[i][j]);
}
vlcs_initialized = 1;
}
static int dca_get_vlc(GetBitContext *s, DCAVLC *v, int i) static int dca_get_vlc(GetBitContext *s, DCAVLC *v, int i)
{ {
return get_vlc2(s, v->vlc[i].table, v->vlc[i].bits, v->max_depth) + v->offset; return get_vlc2(s, v->vlc[i].table, v->vlc[i].bits, v->max_depth) + v->offset;
@ -498,7 +442,7 @@ static inline int parse_scale(DCACoreDecoder *s, int *scale_index, int sel)
// If Huffman code was used, the difference of scales was encoded // If Huffman code was used, the difference of scales was encoded
if (sel < 5) if (sel < 5)
*scale_index += dca_get_vlc(&s->gb, &vlc_scale_factor, sel); *scale_index += dca_get_vlc(&s->gb, &ff_dca_vlc_scale_factor, sel);
else else
*scale_index = get_bits(&s->gb, sel + 1); *scale_index = get_bits(&s->gb, sel + 1);
@ -517,7 +461,7 @@ static inline int parse_joint_scale(DCACoreDecoder *s, int sel)
// Absolute value was encoded even when Huffman code was used // Absolute value was encoded even when Huffman code was used
if (sel < 5) if (sel < 5)
scale_index = dca_get_vlc(&s->gb, &vlc_scale_factor, sel); scale_index = dca_get_vlc(&s->gb, &ff_dca_vlc_scale_factor, sel);
else else
scale_index = get_bits(&s->gb, sel + 1); scale_index = get_bits(&s->gb, sel + 1);
@ -569,7 +513,7 @@ static int parse_subframe_header(DCACoreDecoder *s, int sf,
int abits; int abits;
if (sel < 5) if (sel < 5)
abits = dca_get_vlc(&s->gb, &vlc_bit_allocation, sel); abits = dca_get_vlc(&s->gb, &ff_dca_vlc_bit_allocation, sel);
else else
abits = get_bits(&s->gb, sel - 1); abits = get_bits(&s->gb, sel - 1);
@ -592,7 +536,7 @@ static int parse_subframe_header(DCACoreDecoder *s, int sf,
int sel = s->transition_mode_sel[ch]; int sel = s->transition_mode_sel[ch];
for (band = 0; band < s->subband_vq_start[ch]; band++) for (band = 0; band < s->subband_vq_start[ch]; band++)
if (s->bit_allocation[ch][band]) if (s->bit_allocation[ch][band])
s->transition_mode[sf][ch][band] = dca_get_vlc(&s->gb, &vlc_transition_mode, sel); s->transition_mode[sf][ch][band] = dca_get_vlc(&s->gb, &ff_dca_vlc_transition_mode, sel);
} }
} }
@ -703,7 +647,7 @@ static inline int parse_huffman_codes(DCACoreDecoder *s, int32_t *audio, int abi
// Extract Huffman codes from the bit stream // Extract Huffman codes from the bit stream
for (i = 0; i < DCA_SUBBAND_SAMPLES; i++) for (i = 0; i < DCA_SUBBAND_SAMPLES; i++)
audio[i] = dca_get_vlc(&s->gb, &vlc_quant_index[abits - 1], sel); audio[i] = dca_get_vlc(&s->gb, &ff_dca_vlc_quant_index[abits - 1], sel);
return 1; return 1;
} }
@ -1494,7 +1438,7 @@ static int parse_x96_subframe_header(DCACoreDecoder *s, int xch_base)
for (band = s->x96_subband_start; band < s->nsubbands[ch]; band++) { for (band = s->x96_subband_start; band < s->nsubbands[ch]; band++) {
// If Huffman code was used, the difference of abits was encoded // If Huffman code was used, the difference of abits was encoded
if (sel < 7) if (sel < 7)
abits += dca_get_vlc(&s->gb, &vlc_quant_index[5 + 2 * s->x96_high_res], sel); abits += dca_get_vlc(&s->gb, &ff_dca_vlc_quant_index[5 + 2 * s->x96_high_res], sel);
else else
abits = get_bits(&s->gb, 3 + s->x96_high_res); abits = get_bits(&s->gb, 3 + s->x96_high_res);
@ -2575,8 +2519,6 @@ av_cold void ff_dca_core_flush(DCACoreDecoder *s)
av_cold int ff_dca_core_init(DCACoreDecoder *s) av_cold int ff_dca_core_init(DCACoreDecoder *s)
{ {
dca_init_vlcs();
if (!(s->float_dsp = avpriv_float_dsp_alloc(0))) if (!(s->float_dsp = avpriv_float_dsp_alloc(0)))
return -1; return -1;
if (!(s->fixed_dsp = avpriv_alloc_fixed_dsp(0))) if (!(s->fixed_dsp = avpriv_alloc_fixed_dsp(0)))

View File

@ -33,6 +33,7 @@
#include "dca_exss.h" #include "dca_exss.h"
#include "dcadsp.h" #include "dcadsp.h"
#include "dcadct.h" #include "dcadct.h"
#include "dcahuff.h"
#include "fft.h" #include "fft.h"
#include "synth_filter.h" #include "synth_filter.h"
@ -44,7 +45,6 @@
#define DCA_PCMBLOCK_SAMPLES 32 #define DCA_PCMBLOCK_SAMPLES 32
#define DCA_ADPCM_COEFFS 4 #define DCA_ADPCM_COEFFS 4
#define DCA_LFE_HISTORY 8 #define DCA_LFE_HISTORY 8
#define DCA_CODE_BOOKS 10
#define DCA_ABITS_MAX 26 #define DCA_ABITS_MAX 26
#define DCA_CORE_CHANNELS_MAX 6 #define DCA_CORE_CHANNELS_MAX 6

View File

@ -8729,12 +8729,3 @@ const int32_t ff_dca_sampling_freqs[16] = {
8000, 16000, 32000, 64000, 128000, 22050, 44100, 88200, 8000, 16000, 32000, 64000, 128000, 22050, 44100, 88200,
176400, 352800, 12000, 24000, 48000, 96000, 192000, 384000, 176400, 352800, 12000, 24000, 48000, 96000, 192000, 384000,
}; };
const uint16_t ff_dca_vlc_offs[63] = {
0, 512, 640, 768, 1282, 1794, 2436, 3080, 3770, 4454, 5364,
5372, 5380, 5388, 5392, 5396, 5412, 5420, 5428, 5460, 5492, 5508,
5572, 5604, 5668, 5796, 5860, 5892, 6412, 6668, 6796, 7308, 7564,
7820, 8076, 8620, 9132, 9388, 9910, 10166, 10680, 11196, 11726, 12240,
12752, 13298, 13810, 14326, 14840, 15500, 16022, 16540, 17158, 17678, 18264,
18796, 19352, 19926, 20468, 21472, 22398, 23014, 23622,
};

View File

@ -73,6 +73,4 @@ extern const int32_t ff_dca_xll_band_coeff[20];
extern const int32_t ff_dca_sampling_freqs[16]; extern const int32_t ff_dca_sampling_freqs[16];
extern const uint16_t ff_dca_vlc_offs[63];
#endif /* AVCODEC_DCADATA_H */ #endif /* AVCODEC_DCADATA_H */

View File

@ -22,7 +22,7 @@
#include "libavutil/channel_layout.h" #include "libavutil/channel_layout.h"
#include "dcadec.h" #include "dcadec.h"
#include "dcamath.h" #include "dcahuff.h"
#include "dca_syncwords.h" #include "dca_syncwords.h"
#include "profiles.h" #include "profiles.h"
@ -350,6 +350,8 @@ static av_cold int dcadec_init(AVCodecContext *avctx)
s->exss.avctx = avctx; s->exss.avctx = avctx;
s->xll.avctx = avctx; s->xll.avctx = avctx;
ff_dca_init_vlcs();
if (ff_dca_core_init(&s->core) < 0) if (ff_dca_core_init(&s->core) < 0)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);

1099
libavcodec/dcahuff.c Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff