annotate dca.c @ 4840:a743c46500d4 libavcodec

Per reference swf/flv adpcm encoder.
author banan
date Wed, 11 Apr 2007 13:10:13 +0000
parents 011fb289e3b0
children 384c95879d8b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4599
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1 /*
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
2 * DCA compatible decoder
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
3 * Copyright (C) 2004 Gildas Bazin
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
4 * Copyright (C) 2004 Benjamin Zores
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
5 * Copyright (C) 2006 Benjamin Larsson
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
6 * Copyright (C) 2007 Konstantin Shishkov
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
7 *
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
8 * This file is part of FFmpeg.
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
9 *
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
10 * FFmpeg is free software; you can redistribute it and/or
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
11 * modify it under the terms of the GNU Lesser General Public
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
12 * License as published by the Free Software Foundation; either
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
13 * version 2.1 of the License, or (at your option) any later version.
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
14 *
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
15 * FFmpeg is distributed in the hope that it will be useful,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
18 * Lesser General Public License for more details.
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
19 *
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
20 * You should have received a copy of the GNU Lesser General Public
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
21 * License along with FFmpeg; if not, write to the Free Software
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
23 */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
24
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
25 /**
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
26 * @file dca.c
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
27 */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
28
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
29 #include <math.h>
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
30 #include <stddef.h>
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
31 #include <stdio.h>
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
32
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
33 #include "avcodec.h"
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
34 #include "dsputil.h"
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
35 #include "bitstream.h"
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
36 #include "dcadata.h"
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
37 #include "dcahuff.h"
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
38 #include "parser.h"
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
39
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
40 /** DCA syncwords, also used for bitstream type detection */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
41 //@{
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
42 #define DCA_MARKER_RAW_BE 0x7FFE8001
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
43 #define DCA_MARKER_RAW_LE 0xFE7F0180
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
44 #define DCA_MARKER_14B_BE 0x1FFFE800
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
45 #define DCA_MARKER_14B_LE 0xFF1F00E8
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
46 //@}
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
47
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
48 //#define TRACE
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
49
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
50 #define DCA_PRIM_CHANNELS_MAX (5)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
51 #define DCA_SUBBANDS (32)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
52 #define DCA_ABITS_MAX (32) /* Should be 28 */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
53 #define DCA_SUBSUBFAMES_MAX (4)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
54 #define DCA_LFE_MAX (3)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
55
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
56 enum DCAMode {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
57 DCA_MONO = 0,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
58 DCA_CHANNEL,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
59 DCA_STEREO,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
60 DCA_STEREO_SUMDIFF,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
61 DCA_STEREO_TOTAL,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
62 DCA_3F,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
63 DCA_2F1R,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
64 DCA_3F1R,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
65 DCA_2F2R,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
66 DCA_3F2R,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
67 DCA_4F2R
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
68 };
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
69
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
70 #define DCA_DOLBY 101 /* FIXME */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
71
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
72 #define DCA_CHANNEL_BITS 6
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
73 #define DCA_CHANNEL_MASK 0x3F
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
74
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
75 #define DCA_LFE 0x80
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
76
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
77 #define HEADER_SIZE 14
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
78 #define CONVERT_BIAS 384
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
79
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
80 #define DCA_MAX_FRAME_SIZE 16383
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
81
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
82 /** Bit allocation */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
83 typedef struct {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
84 int offset; ///< code values offset
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
85 int maxbits[8]; ///< max bits in VLC
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
86 int wrap; ///< wrap for get_vlc2()
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
87 VLC vlc[8]; ///< actual codes
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
88 } BitAlloc;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
89
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
90 static BitAlloc dca_bitalloc_index; ///< indexes for samples VLC select
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
91 static BitAlloc dca_tmode; ///< transition mode VLCs
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
92 static BitAlloc dca_scalefactor; ///< scalefactor VLCs
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
93 static BitAlloc dca_smpl_bitalloc[11]; ///< samples VLCs
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
94
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
95 /** Pre-calculated cosine modulation coefs for the QMF */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
96 static float cos_mod[544];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
97
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
98 static int av_always_inline get_bitalloc(GetBitContext *gb, BitAlloc *ba, int idx)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
99 {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
100 return get_vlc2(gb, ba->vlc[idx].table, ba->vlc[idx].bits, ba->wrap) + ba->offset;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
101 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
102
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
103 typedef struct {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
104 AVCodecContext *avctx;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
105 /* Frame header */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
106 int frame_type; ///< type of the current frame
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
107 int samples_deficit; ///< deficit sample count
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
108 int crc_present; ///< crc is present in the bitstream
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
109 int sample_blocks; ///< number of PCM sample blocks
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
110 int frame_size; ///< primary frame byte size
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
111 int amode; ///< audio channels arrangement
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
112 int sample_rate; ///< audio sampling rate
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
113 int bit_rate; ///< transmission bit rate
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
114
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
115 int downmix; ///< embedded downmix enabled
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
116 int dynrange; ///< embedded dynamic range flag
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
117 int timestamp; ///< embedded time stamp flag
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
118 int aux_data; ///< auxiliary data flag
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
119 int hdcd; ///< source material is mastered in HDCD
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
120 int ext_descr; ///< extension audio descriptor flag
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
121 int ext_coding; ///< extended coding flag
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
122 int aspf; ///< audio sync word insertion flag
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
123 int lfe; ///< low frequency effects flag
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
124 int predictor_history; ///< predictor history flag
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
125 int header_crc; ///< header crc check bytes
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
126 int multirate_inter; ///< multirate interpolator switch
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
127 int version; ///< encoder software revision
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
128 int copy_history; ///< copy history
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
129 int source_pcm_res; ///< source pcm resolution
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
130 int front_sum; ///< front sum/difference flag
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
131 int surround_sum; ///< surround sum/difference flag
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
132 int dialog_norm; ///< dialog normalisation parameter
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
133
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
134 /* Primary audio coding header */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
135 int subframes; ///< number of subframes
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
136 int prim_channels; ///< number of primary audio channels
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
137 int subband_activity[DCA_PRIM_CHANNELS_MAX]; ///< subband activity count
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
138 int vq_start_subband[DCA_PRIM_CHANNELS_MAX]; ///< high frequency vq start subband
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
139 int joint_intensity[DCA_PRIM_CHANNELS_MAX]; ///< joint intensity coding index
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
140 int transient_huffman[DCA_PRIM_CHANNELS_MAX]; ///< transient mode code book
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
141 int scalefactor_huffman[DCA_PRIM_CHANNELS_MAX]; ///< scale factor code book
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
142 int bitalloc_huffman[DCA_PRIM_CHANNELS_MAX]; ///< bit allocation quantizer select
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
143 int quant_index_huffman[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX]; ///< quantization index codebook select
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
144 float scalefactor_adj[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX]; ///< scale factor adjustment
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
145
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
146 /* Primary audio coding side information */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
147 int subsubframes; ///< number of subsubframes
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
148 int partial_samples; ///< partial subsubframe samples count
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
149 int prediction_mode[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< prediction mode (ADPCM used or not)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
150 int prediction_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< prediction VQ coefs
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
151 int bitalloc[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< bit allocation index
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
152 int transition_mode[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< transition mode (transients)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
153 int scale_factor[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][2]; ///< scale factors (2 if transient)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
154 int joint_huff[DCA_PRIM_CHANNELS_MAX]; ///< joint subband scale factors codebook
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
155 int joint_scale_factor[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< joint subband scale factors
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
156 int downmix_coef[DCA_PRIM_CHANNELS_MAX][2]; ///< stereo downmix coefficients
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
157 int dynrange_coef; ///< dynamic range coefficient
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
158
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
159 int high_freq_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< VQ encoded high frequency subbands
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
160
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
161 float lfe_data[2 * DCA_SUBSUBFAMES_MAX * DCA_LFE_MAX *
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
162 2 /*history */ ]; ///< Low frequency effect data
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
163 int lfe_scale_factor;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
164
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
165 /* Subband samples history (for ADPCM) */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
166 float subband_samples_hist[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][4];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
167 float subband_fir_hist[DCA_PRIM_CHANNELS_MAX][512];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
168 float subband_fir_noidea[DCA_PRIM_CHANNELS_MAX][64];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
169
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
170 int output; ///< type of output
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
171 int bias; ///< output bias
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
172
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
173 DECLARE_ALIGNED_16(float, samples[1536]); /* 6 * 256 = 1536, might only need 5 */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
174 DECLARE_ALIGNED_16(int16_t, tsamples[1536]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
175
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
176 uint8_t dca_buffer[DCA_MAX_FRAME_SIZE];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
177 int dca_buffer_size; ///< how much data is in the dca_buffer
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
178
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
179 GetBitContext gb;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
180 /* Current position in DCA frame */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
181 int current_subframe;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
182 int current_subsubframe;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
183
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
184 int debug_flag; ///< used for suppressing repeated error messages output
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
185 DSPContext dsp;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
186 } DCAContext;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
187
4783
011fb289e3b0 changes some function declarations from () to (void) as per ansi c.
gpoirier
parents: 4599
diff changeset
188 static void dca_init_vlcs(void)
4599
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
189 {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
190 static int vlcs_inited = 0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
191 int i, j;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
192
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
193 if (vlcs_inited)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
194 return;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
195
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
196 dca_bitalloc_index.offset = 1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
197 dca_bitalloc_index.wrap = 1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
198 for (i = 0; i < 5; i++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
199 init_vlc(&dca_bitalloc_index.vlc[i], bitalloc_12_vlc_bits[i], 12,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
200 bitalloc_12_bits[i], 1, 1,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
201 bitalloc_12_codes[i], 2, 2, 1);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
202 dca_scalefactor.offset = -64;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
203 dca_scalefactor.wrap = 2;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
204 for (i = 0; i < 5; i++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
205 init_vlc(&dca_scalefactor.vlc[i], SCALES_VLC_BITS, 129,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
206 scales_bits[i], 1, 1,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
207 scales_codes[i], 2, 2, 1);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
208 dca_tmode.offset = 0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
209 dca_tmode.wrap = 1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
210 for (i = 0; i < 4; i++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
211 init_vlc(&dca_tmode.vlc[i], tmode_vlc_bits[i], 4,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
212 tmode_bits[i], 1, 1,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
213 tmode_codes[i], 2, 2, 1);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
214
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
215 for(i = 0; i < 10; i++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
216 for(j = 0; j < 7; j++){
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
217 if(!bitalloc_codes[i][j]) break;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
218 dca_smpl_bitalloc[i+1].offset = bitalloc_offsets[i];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
219 dca_smpl_bitalloc[i+1].wrap = 1 + (j > 4);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
220 init_vlc(&dca_smpl_bitalloc[i+1].vlc[j], bitalloc_maxbits[i][j],
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
221 bitalloc_sizes[i],
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
222 bitalloc_bits[i][j], 1, 1,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
223 bitalloc_codes[i][j], 2, 2, 1);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
224 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
225 vlcs_inited = 1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
226 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
227
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
228 static inline void get_array(GetBitContext *gb, int *dst, int len, int bits)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
229 {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
230 while(len--)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
231 *dst++ = get_bits(gb, bits);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
232 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
233
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
234 static int dca_parse_frame_header(DCAContext * s)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
235 {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
236 int i, j;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
237 static const float adj_table[4] = { 1.0, 1.1250, 1.2500, 1.4375 };
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
238 static const int bitlen[11] = { 0, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 };
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
239 static const int thr[11] = { 0, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7 };
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
240
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
241 s->bias = CONVERT_BIAS;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
242
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
243 init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
244
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
245 /* Sync code */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
246 get_bits(&s->gb, 32);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
247
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
248 /* Frame header */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
249 s->frame_type = get_bits(&s->gb, 1);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
250 s->samples_deficit = get_bits(&s->gb, 5) + 1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
251 s->crc_present = get_bits(&s->gb, 1);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
252 s->sample_blocks = get_bits(&s->gb, 7) + 1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
253 s->frame_size = get_bits(&s->gb, 14) + 1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
254 if (s->frame_size < 95)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
255 return -1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
256 s->amode = get_bits(&s->gb, 6);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
257 s->sample_rate = dca_sample_rates[get_bits(&s->gb, 4)];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
258 if (!s->sample_rate)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
259 return -1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
260 s->bit_rate = dca_bit_rates[get_bits(&s->gb, 5)];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
261 if (!s->bit_rate)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
262 return -1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
263
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
264 s->downmix = get_bits(&s->gb, 1);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
265 s->dynrange = get_bits(&s->gb, 1);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
266 s->timestamp = get_bits(&s->gb, 1);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
267 s->aux_data = get_bits(&s->gb, 1);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
268 s->hdcd = get_bits(&s->gb, 1);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
269 s->ext_descr = get_bits(&s->gb, 3);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
270 s->ext_coding = get_bits(&s->gb, 1);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
271 s->aspf = get_bits(&s->gb, 1);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
272 s->lfe = get_bits(&s->gb, 2);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
273 s->predictor_history = get_bits(&s->gb, 1);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
274
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
275 /* TODO: check CRC */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
276 if (s->crc_present)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
277 s->header_crc = get_bits(&s->gb, 16);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
278
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
279 s->multirate_inter = get_bits(&s->gb, 1);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
280 s->version = get_bits(&s->gb, 4);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
281 s->copy_history = get_bits(&s->gb, 2);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
282 s->source_pcm_res = get_bits(&s->gb, 3);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
283 s->front_sum = get_bits(&s->gb, 1);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
284 s->surround_sum = get_bits(&s->gb, 1);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
285 s->dialog_norm = get_bits(&s->gb, 4);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
286
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
287 /* FIXME: channels mixing levels */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
288 s->output = DCA_STEREO;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
289
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
290 #ifdef TRACE
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
291 av_log(s->avctx, AV_LOG_DEBUG, "frame type: %i\n", s->frame_type);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
292 av_log(s->avctx, AV_LOG_DEBUG, "samples deficit: %i\n", s->samples_deficit);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
293 av_log(s->avctx, AV_LOG_DEBUG, "crc present: %i\n", s->crc_present);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
294 av_log(s->avctx, AV_LOG_DEBUG, "sample blocks: %i (%i samples)\n",
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
295 s->sample_blocks, s->sample_blocks * 32);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
296 av_log(s->avctx, AV_LOG_DEBUG, "frame size: %i bytes\n", s->frame_size);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
297 av_log(s->avctx, AV_LOG_DEBUG, "amode: %i (%i channels)\n",
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
298 s->amode, dca_channels[s->amode]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
299 av_log(s->avctx, AV_LOG_DEBUG, "sample rate: %i (%i Hz)\n",
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
300 s->sample_rate, dca_sample_rates[s->sample_rate]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
301 av_log(s->avctx, AV_LOG_DEBUG, "bit rate: %i (%i bits/s)\n",
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
302 s->bit_rate, dca_bit_rates[s->bit_rate]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
303 av_log(s->avctx, AV_LOG_DEBUG, "downmix: %i\n", s->downmix);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
304 av_log(s->avctx, AV_LOG_DEBUG, "dynrange: %i\n", s->dynrange);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
305 av_log(s->avctx, AV_LOG_DEBUG, "timestamp: %i\n", s->timestamp);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
306 av_log(s->avctx, AV_LOG_DEBUG, "aux_data: %i\n", s->aux_data);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
307 av_log(s->avctx, AV_LOG_DEBUG, "hdcd: %i\n", s->hdcd);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
308 av_log(s->avctx, AV_LOG_DEBUG, "ext descr: %i\n", s->ext_descr);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
309 av_log(s->avctx, AV_LOG_DEBUG, "ext coding: %i\n", s->ext_coding);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
310 av_log(s->avctx, AV_LOG_DEBUG, "aspf: %i\n", s->aspf);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
311 av_log(s->avctx, AV_LOG_DEBUG, "lfe: %i\n", s->lfe);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
312 av_log(s->avctx, AV_LOG_DEBUG, "predictor history: %i\n",
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
313 s->predictor_history);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
314 av_log(s->avctx, AV_LOG_DEBUG, "header crc: %i\n", s->header_crc);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
315 av_log(s->avctx, AV_LOG_DEBUG, "multirate inter: %i\n",
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
316 s->multirate_inter);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
317 av_log(s->avctx, AV_LOG_DEBUG, "version number: %i\n", s->version);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
318 av_log(s->avctx, AV_LOG_DEBUG, "copy history: %i\n", s->copy_history);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
319 av_log(s->avctx, AV_LOG_DEBUG,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
320 "source pcm resolution: %i (%i bits/sample)\n",
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
321 s->source_pcm_res, dca_bits_per_sample[s->source_pcm_res]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
322 av_log(s->avctx, AV_LOG_DEBUG, "front sum: %i\n", s->front_sum);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
323 av_log(s->avctx, AV_LOG_DEBUG, "surround sum: %i\n", s->surround_sum);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
324 av_log(s->avctx, AV_LOG_DEBUG, "dialog norm: %i\n", s->dialog_norm);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
325 av_log(s->avctx, AV_LOG_DEBUG, "\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
326 #endif
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
327
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
328 /* Primary audio coding header */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
329 s->subframes = get_bits(&s->gb, 4) + 1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
330 s->prim_channels = get_bits(&s->gb, 3) + 1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
331
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
332
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
333 for (i = 0; i < s->prim_channels; i++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
334 s->subband_activity[i] = get_bits(&s->gb, 5) + 2;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
335 if (s->subband_activity[i] > DCA_SUBBANDS)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
336 s->subband_activity[i] = DCA_SUBBANDS;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
337 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
338 for (i = 0; i < s->prim_channels; i++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
339 s->vq_start_subband[i] = get_bits(&s->gb, 5) + 1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
340 if (s->vq_start_subband[i] > DCA_SUBBANDS)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
341 s->vq_start_subband[i] = DCA_SUBBANDS;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
342 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
343 get_array(&s->gb, s->joint_intensity, s->prim_channels, 3);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
344 get_array(&s->gb, s->transient_huffman, s->prim_channels, 2);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
345 get_array(&s->gb, s->scalefactor_huffman, s->prim_channels, 3);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
346 get_array(&s->gb, s->bitalloc_huffman, s->prim_channels, 3);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
347
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
348 /* Get codebooks quantization indexes */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
349 memset(s->quant_index_huffman, 0, sizeof(s->quant_index_huffman));
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
350 for (j = 1; j < 11; j++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
351 for (i = 0; i < s->prim_channels; i++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
352 s->quant_index_huffman[i][j] = get_bits(&s->gb, bitlen[j]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
353
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
354 /* Get scale factor adjustment */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
355 for (j = 0; j < 11; j++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
356 for (i = 0; i < s->prim_channels; i++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
357 s->scalefactor_adj[i][j] = 1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
358
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
359 for (j = 1; j < 11; j++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
360 for (i = 0; i < s->prim_channels; i++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
361 if (s->quant_index_huffman[i][j] < thr[j])
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
362 s->scalefactor_adj[i][j] = adj_table[get_bits(&s->gb, 2)];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
363
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
364 if (s->crc_present) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
365 /* Audio header CRC check */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
366 get_bits(&s->gb, 16);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
367 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
368
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
369 s->current_subframe = 0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
370 s->current_subsubframe = 0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
371
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
372 #ifdef TRACE
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
373 av_log(s->avctx, AV_LOG_DEBUG, "subframes: %i\n", s->subframes);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
374 av_log(s->avctx, AV_LOG_DEBUG, "prim channels: %i\n", s->prim_channels);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
375 for(i = 0; i < s->prim_channels; i++){
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
376 av_log(s->avctx, AV_LOG_DEBUG, "subband activity: %i\n", s->subband_activity[i]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
377 av_log(s->avctx, AV_LOG_DEBUG, "vq start subband: %i\n", s->vq_start_subband[i]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
378 av_log(s->avctx, AV_LOG_DEBUG, "joint intensity: %i\n", s->joint_intensity[i]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
379 av_log(s->avctx, AV_LOG_DEBUG, "transient mode codebook: %i\n", s->transient_huffman[i]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
380 av_log(s->avctx, AV_LOG_DEBUG, "scale factor codebook: %i\n", s->scalefactor_huffman[i]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
381 av_log(s->avctx, AV_LOG_DEBUG, "bit allocation quantizer: %i\n", s->bitalloc_huffman[i]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
382 av_log(s->avctx, AV_LOG_DEBUG, "quant index huff:");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
383 for (j = 0; j < 11; j++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
384 av_log(s->avctx, AV_LOG_DEBUG, " %i",
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
385 s->quant_index_huffman[i][j]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
386 av_log(s->avctx, AV_LOG_DEBUG, "\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
387 av_log(s->avctx, AV_LOG_DEBUG, "scalefac adj:");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
388 for (j = 0; j < 11; j++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
389 av_log(s->avctx, AV_LOG_DEBUG, " %1.3f", s->scalefactor_adj[i][j]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
390 av_log(s->avctx, AV_LOG_DEBUG, "\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
391 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
392 #endif
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
393
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
394 return 0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
395 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
396
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
397
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
398 static inline int get_scale(GetBitContext *gb, int level, int index, int value)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
399 {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
400 if (level < 5) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
401 /* huffman encoded */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
402 value += get_bitalloc(gb, &dca_scalefactor, index);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
403 } else if(level < 8)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
404 value = get_bits(gb, level + 1);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
405 return value;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
406 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
407
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
408 static int dca_subframe_header(DCAContext * s)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
409 {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
410 /* Primary audio coding side information */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
411 int j, k;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
412
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
413 s->subsubframes = get_bits(&s->gb, 2) + 1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
414 s->partial_samples = get_bits(&s->gb, 3);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
415 for (j = 0; j < s->prim_channels; j++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
416 for (k = 0; k < s->subband_activity[j]; k++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
417 s->prediction_mode[j][k] = get_bits(&s->gb, 1);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
418 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
419
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
420 /* Get prediction codebook */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
421 for (j = 0; j < s->prim_channels; j++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
422 for (k = 0; k < s->subband_activity[j]; k++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
423 if (s->prediction_mode[j][k] > 0) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
424 /* (Prediction coefficient VQ address) */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
425 s->prediction_vq[j][k] = get_bits(&s->gb, 12);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
426 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
427 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
428 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
429
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
430 /* Bit allocation index */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
431 for (j = 0; j < s->prim_channels; j++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
432 for (k = 0; k < s->vq_start_subband[j]; k++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
433 if (s->bitalloc_huffman[j] == 6)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
434 s->bitalloc[j][k] = get_bits(&s->gb, 5);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
435 else if (s->bitalloc_huffman[j] == 5)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
436 s->bitalloc[j][k] = get_bits(&s->gb, 4);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
437 else {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
438 s->bitalloc[j][k] =
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
439 get_bitalloc(&s->gb, &dca_bitalloc_index, j);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
440 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
441
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
442 if (s->bitalloc[j][k] > 26) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
443 // av_log(s->avctx,AV_LOG_DEBUG,"bitalloc index [%i][%i] too big (%i)\n",
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
444 // j, k, s->bitalloc[j][k]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
445 return -1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
446 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
447 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
448 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
449
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
450 /* Transition mode */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
451 for (j = 0; j < s->prim_channels; j++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
452 for (k = 0; k < s->subband_activity[j]; k++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
453 s->transition_mode[j][k] = 0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
454 if (s->subsubframes > 1 &&
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
455 k < s->vq_start_subband[j] && s->bitalloc[j][k] > 0) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
456 s->transition_mode[j][k] =
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
457 get_bitalloc(&s->gb, &dca_tmode, s->transient_huffman[j]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
458 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
459 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
460 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
461
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
462 for (j = 0; j < s->prim_channels; j++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
463 uint32_t *scale_table;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
464 int scale_sum;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
465
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
466 memset(s->scale_factor[j], 0, s->subband_activity[j] * sizeof(s->scale_factor[0][0][0]) * 2);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
467
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
468 if (s->scalefactor_huffman[j] == 6)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
469 scale_table = (uint32_t *) scale_factor_quant7;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
470 else
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
471 scale_table = (uint32_t *) scale_factor_quant6;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
472
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
473 /* When huffman coded, only the difference is encoded */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
474 scale_sum = 0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
475
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
476 for (k = 0; k < s->subband_activity[j]; k++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
477 if (k >= s->vq_start_subband[j] || s->bitalloc[j][k] > 0) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
478 scale_sum = get_scale(&s->gb, s->scalefactor_huffman[j], j, scale_sum);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
479 s->scale_factor[j][k][0] = scale_table[scale_sum];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
480 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
481
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
482 if (k < s->vq_start_subband[j] && s->transition_mode[j][k]) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
483 /* Get second scale factor */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
484 scale_sum = get_scale(&s->gb, s->scalefactor_huffman[j], j, scale_sum);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
485 s->scale_factor[j][k][1] = scale_table[scale_sum];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
486 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
487 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
488 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
489
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
490 /* Joint subband scale factor codebook select */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
491 for (j = 0; j < s->prim_channels; j++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
492 /* Transmitted only if joint subband coding enabled */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
493 if (s->joint_intensity[j] > 0)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
494 s->joint_huff[j] = get_bits(&s->gb, 3);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
495 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
496
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
497 /* Scale factors for joint subband coding */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
498 for (j = 0; j < s->prim_channels; j++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
499 int source_channel;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
500
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
501 /* Transmitted only if joint subband coding enabled */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
502 if (s->joint_intensity[j] > 0) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
503 int scale = 0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
504 source_channel = s->joint_intensity[j] - 1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
505
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
506 /* When huffman coded, only the difference is encoded
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
507 * (is this valid as well for joint scales ???) */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
508
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
509 for (k = s->subband_activity[j]; k < s->subband_activity[source_channel]; k++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
510 scale = get_scale(&s->gb, s->joint_huff[j], j, 0);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
511 scale += 64; /* bias */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
512 s->joint_scale_factor[j][k] = scale; /*joint_scale_table[scale]; */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
513 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
514
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
515 if (!s->debug_flag & 0x02) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
516 av_log(s->avctx, AV_LOG_DEBUG,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
517 "Joint stereo coding not supported\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
518 s->debug_flag |= 0x02;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
519 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
520 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
521 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
522
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
523 /* Stereo downmix coefficients */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
524 if (s->prim_channels > 2 && s->downmix) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
525 for (j = 0; j < s->prim_channels; j++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
526 s->downmix_coef[j][0] = get_bits(&s->gb, 7);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
527 s->downmix_coef[j][1] = get_bits(&s->gb, 7);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
528 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
529 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
530
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
531 /* Dynamic range coefficient */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
532 if (s->dynrange)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
533 s->dynrange_coef = get_bits(&s->gb, 8);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
534
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
535 /* Side information CRC check word */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
536 if (s->crc_present) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
537 get_bits(&s->gb, 16);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
538 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
539
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
540 /*
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
541 * Primary audio data arrays
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
542 */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
543
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
544 /* VQ encoded high frequency subbands */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
545 for (j = 0; j < s->prim_channels; j++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
546 for (k = s->vq_start_subband[j]; k < s->subband_activity[j]; k++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
547 /* 1 vector -> 32 samples */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
548 s->high_freq_vq[j][k] = get_bits(&s->gb, 10);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
549
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
550 /* Low frequency effect data */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
551 if (s->lfe) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
552 /* LFE samples */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
553 int lfe_samples = 2 * s->lfe * s->subsubframes;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
554 float lfe_scale;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
555
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
556 for (j = lfe_samples; j < lfe_samples * 2; j++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
557 /* Signed 8 bits int */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
558 s->lfe_data[j] = get_sbits(&s->gb, 8);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
559 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
560
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
561 /* Scale factor index */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
562 s->lfe_scale_factor = scale_factor_quant7[get_bits(&s->gb, 8)];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
563
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
564 /* Quantization step size * scale factor */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
565 lfe_scale = 0.035 * s->lfe_scale_factor;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
566
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
567 for (j = lfe_samples; j < lfe_samples * 2; j++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
568 s->lfe_data[j] *= lfe_scale;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
569 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
570
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
571 #ifdef TRACE
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
572 av_log(s->avctx, AV_LOG_DEBUG, "subsubframes: %i\n", s->subsubframes);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
573 av_log(s->avctx, AV_LOG_DEBUG, "partial samples: %i\n",
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
574 s->partial_samples);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
575 for (j = 0; j < s->prim_channels; j++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
576 av_log(s->avctx, AV_LOG_DEBUG, "prediction mode:");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
577 for (k = 0; k < s->subband_activity[j]; k++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
578 av_log(s->avctx, AV_LOG_DEBUG, " %i", s->prediction_mode[j][k]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
579 av_log(s->avctx, AV_LOG_DEBUG, "\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
580 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
581 for (j = 0; j < s->prim_channels; j++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
582 for (k = 0; k < s->subband_activity[j]; k++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
583 av_log(s->avctx, AV_LOG_DEBUG,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
584 "prediction coefs: %f, %f, %f, %f\n",
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
585 (float) adpcm_vb[s->prediction_vq[j][k]][0] / 8192,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
586 (float) adpcm_vb[s->prediction_vq[j][k]][1] / 8192,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
587 (float) adpcm_vb[s->prediction_vq[j][k]][2] / 8192,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
588 (float) adpcm_vb[s->prediction_vq[j][k]][3] / 8192);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
589 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
590 for (j = 0; j < s->prim_channels; j++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
591 av_log(s->avctx, AV_LOG_DEBUG, "bitalloc index: ");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
592 for (k = 0; k < s->vq_start_subband[j]; k++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
593 av_log(s->avctx, AV_LOG_DEBUG, "%2.2i ", s->bitalloc[j][k]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
594 av_log(s->avctx, AV_LOG_DEBUG, "\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
595 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
596 for (j = 0; j < s->prim_channels; j++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
597 av_log(s->avctx, AV_LOG_DEBUG, "Transition mode:");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
598 for (k = 0; k < s->subband_activity[j]; k++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
599 av_log(s->avctx, AV_LOG_DEBUG, " %i", s->transition_mode[j][k]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
600 av_log(s->avctx, AV_LOG_DEBUG, "\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
601 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
602 for (j = 0; j < s->prim_channels; j++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
603 av_log(s->avctx, AV_LOG_DEBUG, "Scale factor:");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
604 for (k = 0; k < s->subband_activity[j]; k++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
605 if (k >= s->vq_start_subband[j] || s->bitalloc[j][k] > 0)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
606 av_log(s->avctx, AV_LOG_DEBUG, " %i", s->scale_factor[j][k][0]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
607 if (k < s->vq_start_subband[j] && s->transition_mode[j][k])
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
608 av_log(s->avctx, AV_LOG_DEBUG, " %i(t)", s->scale_factor[j][k][1]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
609 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
610 av_log(s->avctx, AV_LOG_DEBUG, "\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
611 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
612 for (j = 0; j < s->prim_channels; j++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
613 if (s->joint_intensity[j] > 0) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
614 av_log(s->avctx, AV_LOG_DEBUG, "Joint scale factor index:\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
615 for (k = s->subband_activity[j]; k < s->subband_activity[source_channel]; k++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
616 av_log(s->avctx, AV_LOG_DEBUG, " %i", s->joint_scale_factor[j][k]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
617 av_log(s->avctx, AV_LOG_DEBUG, "\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
618 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
619 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
620 if (s->prim_channels > 2 && s->downmix) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
621 av_log(s->avctx, AV_LOG_DEBUG, "Downmix coeffs:\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
622 for (j = 0; j < s->prim_channels; j++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
623 av_log(s->avctx, AV_LOG_DEBUG, "Channel 0,%d = %f\n", j, dca_downmix_coeffs[s->downmix_coef[j][0]]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
624 av_log(s->avctx, AV_LOG_DEBUG, "Channel 1,%d = %f\n", j, dca_downmix_coeffs[s->downmix_coef[j][1]]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
625 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
626 av_log(s->avctx, AV_LOG_DEBUG, "\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
627 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
628 for (j = 0; j < s->prim_channels; j++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
629 for (k = s->vq_start_subband[j]; k < s->subband_activity[j]; k++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
630 av_log(s->avctx, AV_LOG_DEBUG, "VQ index: %i\n", s->high_freq_vq[j][k]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
631 if(s->lfe){
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
632 av_log(s->avctx, AV_LOG_DEBUG, "LFE samples:\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
633 for (j = lfe_samples; j < lfe_samples * 2; j++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
634 av_log(s->avctx, AV_LOG_DEBUG, " %f", s->lfe_data[j]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
635 av_log(s->avctx, AV_LOG_DEBUG, "\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
636 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
637 #endif
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
638
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
639 return 0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
640 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
641
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
642 static void qmf_32_subbands(DCAContext * s, int chans,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
643 float samples_in[32][8], float *samples_out,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
644 float scale, float bias)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
645 {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
646 float *prCoeff;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
647 int i, j, k;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
648 float praXin[33], *raXin = &praXin[1];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
649
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
650 float *subband_fir_hist = s->subband_fir_hist[chans];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
651 float *subband_fir_hist2 = s->subband_fir_noidea[chans];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
652
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
653 int chindex = 0, subindex;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
654
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
655 praXin[0] = 0.0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
656
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
657 /* Select filter */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
658 if (!s->multirate_inter) /* Non-perfect reconstruction */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
659 prCoeff = (float *) fir_32bands_nonperfect;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
660 else /* Perfect reconstruction */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
661 prCoeff = (float *) fir_32bands_perfect;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
662
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
663 /* Reconstructed channel sample index */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
664 for (subindex = 0; subindex < 8; subindex++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
665 float t1, t2, sum[16], diff[16];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
666
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
667 /* Load in one sample from each subband and clear inactive subbands */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
668 for (i = 0; i < s->subband_activity[chans]; i++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
669 raXin[i] = samples_in[i][subindex];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
670 for (; i < 32; i++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
671 raXin[i] = 0.0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
672
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
673 /* Multiply by cosine modulation coefficients and
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
674 * create temporary arrays SUM and DIFF */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
675 for (j = 0, k = 0; k < 16; k++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
676 t1 = 0.0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
677 t2 = 0.0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
678 for (i = 0; i < 16; i++, j++){
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
679 t1 += (raXin[2 * i] + raXin[2 * i + 1]) * cos_mod[j];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
680 t2 += (raXin[2 * i] + raXin[2 * i - 1]) * cos_mod[j + 256];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
681 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
682 sum[k] = t1 + t2;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
683 diff[k] = t1 - t2;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
684 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
685
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
686 j = 512;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
687 /* Store history */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
688 for (k = 0; k < 16; k++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
689 subband_fir_hist[k] = cos_mod[j++] * sum[k];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
690 for (k = 0; k < 16; k++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
691 subband_fir_hist[32-k-1] = cos_mod[j++] * diff[k];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
692
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
693 /* Multiply by filter coefficients */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
694 for (k = 31, i = 0; i < 32; i++, k--)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
695 for (j = 0; j < 512; j += 64){
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
696 subband_fir_hist2[i] += prCoeff[i+j] * ( subband_fir_hist[i+j] - subband_fir_hist[j+k]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
697 subband_fir_hist2[i+32] += prCoeff[i+j+32]*(-subband_fir_hist[i+j] - subband_fir_hist[j+k]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
698 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
699
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
700 /* Create 32 PCM output samples */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
701 for (i = 0; i < 32; i++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
702 samples_out[chindex++] = subband_fir_hist2[i] * scale + bias;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
703
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
704 /* Update working arrays */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
705 memmove(&subband_fir_hist[32], &subband_fir_hist[0], (512 - 32) * sizeof(float));
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
706 memmove(&subband_fir_hist2[0], &subband_fir_hist2[32], 32 * sizeof(float));
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
707 memset(&subband_fir_hist2[32], 0, 32 * sizeof(float));
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
708 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
709 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
710
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
711 static void lfe_interpolation_fir(int decimation_select,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
712 int num_deci_sample, float *samples_in,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
713 float *samples_out, float scale,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
714 float bias)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
715 {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
716 /* samples_in: An array holding decimated samples.
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
717 * Samples in current subframe starts from samples_in[0],
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
718 * while samples_in[-1], samples_in[-2], ..., stores samples
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
719 * from last subframe as history.
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
720 *
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
721 * samples_out: An array holding interpolated samples
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
722 */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
723
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
724 int decifactor, k, j;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
725 const float *prCoeff;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
726
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
727 int interp_index = 0; /* Index to the interpolated samples */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
728 int deciindex;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
729
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
730 /* Select decimation filter */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
731 if (decimation_select == 1) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
732 decifactor = 128;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
733 prCoeff = lfe_fir_128;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
734 } else {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
735 decifactor = 64;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
736 prCoeff = lfe_fir_64;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
737 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
738 /* Interpolation */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
739 for (deciindex = 0; deciindex < num_deci_sample; deciindex++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
740 /* One decimated sample generates decifactor interpolated ones */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
741 for (k = 0; k < decifactor; k++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
742 float rTmp = 0.0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
743 //FIXME the coeffs are symetric, fix that
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
744 for (j = 0; j < 512 / decifactor; j++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
745 rTmp += samples_in[deciindex - j] * prCoeff[k + j * decifactor];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
746 samples_out[interp_index++] = rTmp / scale + bias;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
747 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
748 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
749 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
750
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
751 /* downmixing routines */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
752 #define MIX_REAR1(samples, si1) \
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
753 samples[i] += samples[si1]; \
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
754 samples[i+256] += samples[si1];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
755
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
756 #define MIX_REAR2(samples, si1, si2) \
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
757 samples[i] += samples[si1]; \
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
758 samples[i+256] += samples[si2];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
759
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
760 #define MIX_FRONT3(samples) \
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
761 t = samples[i]; \
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
762 samples[i] += samples[i+256]; \
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
763 samples[i+256] = samples[i+512] + t;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
764
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
765 #define DOWNMIX_TO_STEREO(op1, op2) \
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
766 for(i = 0; i < 256; i++){ \
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
767 op1 \
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
768 op2 \
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
769 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
770
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
771 static void dca_downmix(float *samples, int srcfmt)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
772 {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
773 int i;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
774 float t;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
775
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
776 switch (srcfmt) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
777 case DCA_MONO:
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
778 case DCA_CHANNEL:
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
779 case DCA_STEREO_TOTAL:
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
780 case DCA_STEREO_SUMDIFF:
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
781 case DCA_4F2R:
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
782 av_log(NULL, 0, "Not implemented!\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
783 break;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
784 case DCA_STEREO:
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
785 break;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
786 case DCA_3F:
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
787 DOWNMIX_TO_STEREO(MIX_FRONT3(samples),);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
788 break;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
789 case DCA_2F1R:
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
790 DOWNMIX_TO_STEREO(MIX_REAR1(samples, i + 512),);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
791 break;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
792 case DCA_3F1R:
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
793 DOWNMIX_TO_STEREO(MIX_FRONT3(samples),
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
794 MIX_REAR1(samples, i + 768));
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
795 break;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
796 case DCA_2F2R:
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
797 DOWNMIX_TO_STEREO(MIX_REAR2(samples, i + 512, i + 768),);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
798 break;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
799 case DCA_3F2R:
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
800 DOWNMIX_TO_STEREO(MIX_FRONT3(samples),
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
801 MIX_REAR2(samples, i + 768, i + 1024));
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
802 break;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
803 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
804 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
805
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
806
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
807 /* Very compact version of the block code decoder that does not use table
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
808 * look-up but is slightly slower */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
809 static int decode_blockcode(int code, int levels, int *values)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
810 {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
811 int i;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
812 int offset = (levels - 1) >> 1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
813
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
814 for (i = 0; i < 4; i++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
815 values[i] = (code % levels) - offset;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
816 code /= levels;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
817 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
818
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
819 if (code == 0)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
820 return 0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
821 else {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
822 av_log(NULL, AV_LOG_ERROR, "ERROR: block code look-up failed\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
823 return -1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
824 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
825 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
826
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
827 static const uint8_t abits_sizes[7] = { 7, 10, 12, 13, 15, 17, 19 };
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
828 static const uint8_t abits_levels[7] = { 3, 5, 7, 9, 13, 17, 25 };
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
829
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
830 static int dca_subsubframe(DCAContext * s)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
831 {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
832 int k, l;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
833 int subsubframe = s->current_subsubframe;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
834
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
835 float *quant_step_table;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
836
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
837 /* FIXME */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
838 float subband_samples[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][8];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
839
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
840 /*
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
841 * Audio data
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
842 */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
843
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
844 /* Select quantization step size table */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
845 if (s->bit_rate == 0x1f)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
846 quant_step_table = (float *) lossless_quant_d;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
847 else
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
848 quant_step_table = (float *) lossy_quant_d;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
849
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
850 for (k = 0; k < s->prim_channels; k++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
851 for (l = 0; l < s->vq_start_subband[k]; l++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
852 int m;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
853
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
854 /* Select the mid-tread linear quantizer */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
855 int abits = s->bitalloc[k][l];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
856
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
857 float quant_step_size = quant_step_table[abits];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
858 float rscale;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
859
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
860 /*
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
861 * Determine quantization index code book and its type
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
862 */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
863
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
864 /* Select quantization index code book */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
865 int sel = s->quant_index_huffman[k][abits];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
866
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
867 /*
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
868 * Extract bits from the bit stream
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
869 */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
870 if(!abits){
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
871 memset(subband_samples[k][l], 0, 8 * sizeof(subband_samples[0][0][0]));
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
872 }else if(abits >= 11 || !dca_smpl_bitalloc[abits].vlc[sel].table){
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
873 if(abits <= 7){
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
874 /* Block code */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
875 int block_code1, block_code2, size, levels;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
876 int block[8];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
877
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
878 size = abits_sizes[abits-1];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
879 levels = abits_levels[abits-1];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
880
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
881 block_code1 = get_bits(&s->gb, size);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
882 /* FIXME Should test return value */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
883 decode_blockcode(block_code1, levels, block);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
884 block_code2 = get_bits(&s->gb, size);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
885 decode_blockcode(block_code2, levels, &block[4]);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
886 for (m = 0; m < 8; m++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
887 subband_samples[k][l][m] = block[m];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
888 }else{
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
889 /* no coding */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
890 for (m = 0; m < 8; m++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
891 subband_samples[k][l][m] = get_sbits(&s->gb, abits - 3);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
892 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
893 }else{
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
894 /* Huffman coded */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
895 for (m = 0; m < 8; m++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
896 subband_samples[k][l][m] = get_bitalloc(&s->gb, &dca_smpl_bitalloc[abits], sel);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
897 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
898
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
899 /* Deal with transients */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
900 if (s->transition_mode[k][l] &&
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
901 subsubframe >= s->transition_mode[k][l])
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
902 rscale = quant_step_size * s->scale_factor[k][l][1];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
903 else
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
904 rscale = quant_step_size * s->scale_factor[k][l][0];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
905
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
906 rscale *= s->scalefactor_adj[k][sel];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
907
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
908 for (m = 0; m < 8; m++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
909 subband_samples[k][l][m] *= rscale;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
910
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
911 /*
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
912 * Inverse ADPCM if in prediction mode
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
913 */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
914 if (s->prediction_mode[k][l]) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
915 int n;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
916 for (m = 0; m < 8; m++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
917 for (n = 1; n <= 4; n++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
918 if (m >= n)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
919 subband_samples[k][l][m] +=
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
920 (adpcm_vb[s->prediction_vq[k][l]][n - 1] *
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
921 subband_samples[k][l][m - n] / 8192);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
922 else if (s->predictor_history)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
923 subband_samples[k][l][m] +=
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
924 (adpcm_vb[s->prediction_vq[k][l]][n - 1] *
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
925 s->subband_samples_hist[k][l][m - n +
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
926 4] / 8192);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
927 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
928 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
929 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
930
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
931 /*
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
932 * Decode VQ encoded high frequencies
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
933 */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
934 for (l = s->vq_start_subband[k]; l < s->subband_activity[k]; l++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
935 /* 1 vector -> 32 samples but we only need the 8 samples
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
936 * for this subsubframe. */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
937 int m;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
938
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
939 if (!s->debug_flag & 0x01) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
940 av_log(s->avctx, AV_LOG_DEBUG, "Stream with high frequencies VQ coding\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
941 s->debug_flag |= 0x01;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
942 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
943
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
944 for (m = 0; m < 8; m++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
945 subband_samples[k][l][m] =
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
946 high_freq_vq[s->high_freq_vq[k][l]][subsubframe * 8 +
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
947 m]
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
948 * (float) s->scale_factor[k][l][0] / 16.0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
949 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
950 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
951 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
952
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
953 /* Check for DSYNC after subsubframe */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
954 if (s->aspf || subsubframe == s->subsubframes - 1) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
955 if (0xFFFF == get_bits(&s->gb, 16)) { /* 0xFFFF */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
956 #ifdef TRACE
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
957 av_log(s->avctx, AV_LOG_DEBUG, "Got subframe DSYNC\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
958 #endif
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
959 } else {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
960 av_log(s->avctx, AV_LOG_ERROR, "Didn't get subframe DSYNC\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
961 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
962 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
963
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
964 /* Backup predictor history for adpcm */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
965 for (k = 0; k < s->prim_channels; k++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
966 for (l = 0; l < s->vq_start_subband[k]; l++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
967 memcpy(s->subband_samples_hist[k][l], &subband_samples[k][l][4],
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
968 4 * sizeof(subband_samples[0][0][0]));
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
969
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
970 /* 32 subbands QMF */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
971 for (k = 0; k < s->prim_channels; k++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
972 /* static float pcm_to_double[8] =
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
973 {32768.0, 32768.0, 524288.0, 524288.0, 0, 8388608.0, 8388608.0};*/
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
974 qmf_32_subbands(s, k, subband_samples[k], &s->samples[256 * k],
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
975 2.0 / 3 /*pcm_to_double[s->source_pcm_res] */ ,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
976 0 /*s->bias */ );
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
977 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
978
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
979 /* Down mixing */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
980
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
981 if (s->prim_channels > dca_channels[s->output & DCA_CHANNEL_MASK]) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
982 dca_downmix(s->samples, s->amode);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
983 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
984
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
985 /* Generate LFE samples for this subsubframe FIXME!!! */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
986 if (s->output & DCA_LFE) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
987 int lfe_samples = 2 * s->lfe * s->subsubframes;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
988 int i_channels = dca_channels[s->output & DCA_CHANNEL_MASK];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
989
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
990 lfe_interpolation_fir(s->lfe, 2 * s->lfe,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
991 s->lfe_data + lfe_samples +
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
992 2 * s->lfe * subsubframe,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
993 &s->samples[256 * i_channels],
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
994 8388608.0, s->bias);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
995 /* Outputs 20bits pcm samples */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
996 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
997
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
998 return 0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
999 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1000
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1001
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1002 static int dca_subframe_footer(DCAContext * s)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1003 {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1004 int aux_data_count = 0, i;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1005 int lfe_samples;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1006
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1007 /*
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1008 * Unpack optional information
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1009 */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1010
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1011 if (s->timestamp)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1012 get_bits(&s->gb, 32);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1013
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1014 if (s->aux_data)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1015 aux_data_count = get_bits(&s->gb, 6);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1016
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1017 for (i = 0; i < aux_data_count; i++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1018 get_bits(&s->gb, 8);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1019
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1020 if (s->crc_present && (s->downmix || s->dynrange))
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1021 get_bits(&s->gb, 16);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1022
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1023 lfe_samples = 2 * s->lfe * s->subsubframes;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1024 for (i = 0; i < lfe_samples; i++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1025 s->lfe_data[i] = s->lfe_data[i + lfe_samples];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1026 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1027
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1028 return 0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1029 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1030
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1031 /**
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1032 * Decode a dca frame block
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1033 *
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1034 * @param s pointer to the DCAContext
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1035 */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1036
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1037 static int dca_decode_block(DCAContext * s)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1038 {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1039
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1040 /* Sanity check */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1041 if (s->current_subframe >= s->subframes) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1042 av_log(s->avctx, AV_LOG_DEBUG, "check failed: %i>%i",
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1043 s->current_subframe, s->subframes);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1044 return -1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1045 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1046
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1047 if (!s->current_subsubframe) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1048 #ifdef TRACE
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1049 av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subframe_header\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1050 #endif
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1051 /* Read subframe header */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1052 if (dca_subframe_header(s))
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1053 return -1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1054 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1055
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1056 /* Read subsubframe */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1057 #ifdef TRACE
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1058 av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subsubframe\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1059 #endif
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1060 if (dca_subsubframe(s))
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1061 return -1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1062
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1063 /* Update state */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1064 s->current_subsubframe++;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1065 if (s->current_subsubframe >= s->subsubframes) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1066 s->current_subsubframe = 0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1067 s->current_subframe++;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1068 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1069 if (s->current_subframe >= s->subframes) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1070 #ifdef TRACE
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1071 av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subframe_footer\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1072 #endif
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1073 /* Read subframe footer */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1074 if (dca_subframe_footer(s))
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1075 return -1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1076 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1077
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1078 return 0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1079 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1080
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1081 /**
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1082 * Convert bitstream to one representation based on sync marker
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1083 */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1084 static int dca_convert_bitstream(uint8_t * src, int src_size, uint8_t * dst,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1085 int max_size)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1086 {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1087 uint32_t mrk;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1088 int i, tmp;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1089 uint16_t *ssrc = (uint16_t *) src, *sdst = (uint16_t *) dst;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1090 PutBitContext pb;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1091
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1092 mrk = AV_RB32(src);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1093 switch (mrk) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1094 case DCA_MARKER_RAW_BE:
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1095 memcpy(dst, src, FFMIN(src_size, max_size));
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1096 return FFMIN(src_size, max_size);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1097 case DCA_MARKER_RAW_LE:
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1098 for (i = 0; i < (FFMIN(src_size, max_size) + 1) >> 1; i++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1099 *sdst++ = bswap_16(*ssrc++);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1100 return FFMIN(src_size, max_size);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1101 case DCA_MARKER_14B_BE:
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1102 case DCA_MARKER_14B_LE:
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1103 init_put_bits(&pb, dst, max_size);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1104 for (i = 0; i < (src_size + 1) >> 1; i++, src += 2) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1105 tmp = ((mrk == DCA_MARKER_14B_BE) ? AV_RB16(src) : AV_RL16(src)) & 0x3FFF;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1106 put_bits(&pb, 14, tmp);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1107 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1108 flush_put_bits(&pb);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1109 return (put_bits_count(&pb) + 7) >> 3;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1110 default:
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1111 return -1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1112 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1113 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1114
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1115 /**
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1116 * Main frame decoding function
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1117 * FIXME add arguments
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1118 */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1119 static int dca_decode_frame(AVCodecContext * avctx,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1120 void *data, int *data_size,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1121 uint8_t * buf, int buf_size)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1122 {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1123
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1124 int i, j, k;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1125 int16_t *samples = data;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1126 DCAContext *s = avctx->priv_data;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1127 int channels;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1128
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1129
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1130 s->dca_buffer_size = dca_convert_bitstream(buf, buf_size, s->dca_buffer, DCA_MAX_FRAME_SIZE);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1131 if (s->dca_buffer_size == -1) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1132 av_log(avctx, AV_LOG_ERROR, "Not a DCA frame\n");
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1133 return -1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1134 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1135
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1136 init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1137 if (dca_parse_frame_header(s) < 0) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1138 //seems like the frame is corrupt, try with the next one
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1139 return buf_size;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1140 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1141 //set AVCodec values with parsed data
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1142 avctx->sample_rate = s->sample_rate;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1143 avctx->channels = 2; //FIXME
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1144 avctx->bit_rate = s->bit_rate;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1145
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1146 channels = dca_channels[s->output];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1147 if(*data_size < (s->sample_blocks / 8) * 256 * sizeof(int16_t) * channels)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1148 return -1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1149 *data_size = 0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1150 for (i = 0; i < (s->sample_blocks / 8); i++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1151 dca_decode_block(s);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1152 s->dsp.float_to_int16(s->tsamples, s->samples, 256 * channels);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1153 /* interleave samples */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1154 for (j = 0; j < 256; j++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1155 for (k = 0; k < channels; k++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1156 samples[k] = s->tsamples[j + k * 256];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1157 samples += channels;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1158 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1159 *data_size += 256 * sizeof(int16_t) * channels;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1160 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1161
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1162 return buf_size;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1163 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1164
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1165
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1166
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1167 /**
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1168 * Build the cosine modulation tables for the QMF
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1169 *
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1170 * @param s pointer to the DCAContext
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1171 */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1172
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1173 static void pre_calc_cosmod(DCAContext * s)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1174 {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1175 int i, j, k;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1176 static int cosmod_inited = 0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1177
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1178 if(cosmod_inited) return;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1179 for (j = 0, k = 0; k < 16; k++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1180 for (i = 0; i < 16; i++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1181 cos_mod[j++] = cos((2 * i + 1) * (2 * k + 1) * M_PI / 64);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1182
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1183 for (k = 0; k < 16; k++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1184 for (i = 0; i < 16; i++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1185 cos_mod[j++] = cos((i) * (2 * k + 1) * M_PI / 32);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1186
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1187 for (k = 0; k < 16; k++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1188 cos_mod[j++] = 0.25 / (2 * cos((2 * k + 1) * M_PI / 128));
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1189
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1190 for (k = 0; k < 16; k++)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1191 cos_mod[j++] = -0.25 / (2.0 * sin((2 * k + 1) * M_PI / 128));
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1192
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1193 cosmod_inited = 1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1194 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1195
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1196
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1197 /**
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1198 * DCA initialization
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1199 *
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1200 * @param avctx pointer to the AVCodecContext
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1201 */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1202
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1203 static int dca_decode_init(AVCodecContext * avctx)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1204 {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1205 DCAContext *s = avctx->priv_data;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1206
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1207 s->avctx = avctx;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1208 dca_init_vlcs();
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1209 pre_calc_cosmod(s);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1210
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1211 dsputil_init(&s->dsp, avctx);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1212 return 0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1213 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1214
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1215
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1216 AVCodec dca_decoder = {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1217 .name = "dca",
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1218 .type = CODEC_TYPE_AUDIO,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1219 .id = CODEC_ID_DTS,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1220 .priv_data_size = sizeof(DCAContext),
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1221 .init = dca_decode_init,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1222 .decode = dca_decode_frame,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1223 };
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1224
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1225 #ifdef CONFIG_DCA_PARSER
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1226
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1227 typedef struct DCAParseContext {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1228 ParseContext pc;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1229 uint32_t lastmarker;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1230 } DCAParseContext;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1231
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1232 #define IS_MARKER(state, i, buf, buf_size) \
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1233 ((state == DCA_MARKER_14B_LE && (i < buf_size-2) && (buf[i+1] & 0xF0) == 0xF0 && buf[i+2] == 0x07) \
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1234 || (state == DCA_MARKER_14B_BE && (i < buf_size-2) && buf[i+1] == 0x07 && (buf[i+2] & 0xF0) == 0xF0) \
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1235 || state == DCA_MARKER_RAW_LE || state == DCA_MARKER_RAW_BE)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1236
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1237 /**
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1238 * finds the end of the current frame in the bitstream.
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1239 * @return the position of the first byte of the next frame, or -1
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1240 */
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1241 static int dca_find_frame_end(DCAParseContext * pc1, const uint8_t * buf,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1242 int buf_size)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1243 {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1244 int start_found, i;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1245 uint32_t state;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1246 ParseContext *pc = &pc1->pc;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1247
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1248 start_found = pc->frame_start_found;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1249 state = pc->state;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1250
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1251 i = 0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1252 if (!start_found) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1253 for (i = 0; i < buf_size; i++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1254 state = (state << 8) | buf[i];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1255 if (IS_MARKER(state, i, buf, buf_size)) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1256 if (pc1->lastmarker && state == pc1->lastmarker) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1257 start_found = 1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1258 break;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1259 } else if (!pc1->lastmarker) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1260 start_found = 1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1261 pc1->lastmarker = state;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1262 break;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1263 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1264 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1265 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1266 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1267 if (start_found) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1268 for (; i < buf_size; i++) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1269 state = (state << 8) | buf[i];
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1270 if (state == pc1->lastmarker && IS_MARKER(state, i, buf, buf_size)) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1271 pc->frame_start_found = 0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1272 pc->state = -1;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1273 return i - 3;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1274 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1275 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1276 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1277 pc->frame_start_found = start_found;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1278 pc->state = state;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1279 return END_NOT_FOUND;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1280 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1281
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1282 static int dca_parse_init(AVCodecParserContext * s)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1283 {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1284 DCAParseContext *pc1 = s->priv_data;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1285
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1286 pc1->lastmarker = 0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1287 return 0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1288 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1289
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1290 static int dca_parse(AVCodecParserContext * s,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1291 AVCodecContext * avctx,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1292 uint8_t ** poutbuf, int *poutbuf_size,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1293 const uint8_t * buf, int buf_size)
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1294 {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1295 DCAParseContext *pc1 = s->priv_data;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1296 ParseContext *pc = &pc1->pc;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1297 int next;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1298
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1299 if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1300 next = buf_size;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1301 } else {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1302 next = dca_find_frame_end(pc1, buf, buf_size);
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1303
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1304 if (ff_combine_frame(pc, next, (uint8_t **) & buf, &buf_size) < 0) {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1305 *poutbuf = NULL;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1306 *poutbuf_size = 0;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1307 return buf_size;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1308 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1309 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1310 *poutbuf = (uint8_t *) buf;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1311 *poutbuf_size = buf_size;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1312 return next;
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1313 }
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1314
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1315 AVCodecParser dca_parser = {
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1316 {CODEC_ID_DTS},
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1317 sizeof(DCAParseContext),
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1318 dca_parse_init,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1319 dca_parse,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1320 ff_parse_close,
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1321 };
2cd245d65761 DCA decoder
kostya
parents:
diff changeset
1322 #endif /* CONFIG_DCA_PARSER */