Mercurial > libavcodec.hg
annotate dca.c @ 11606:93db59ec6eb7 libavcodec
DCA: use some type-punning in qmf_32_subbands()
| author | mru |
|---|---|
| date | Mon, 12 Apr 2010 11:14:48 +0000 |
| parents | 18f17f44de37 |
| children | 554450259db8 |
| rev | line source |
|---|---|
| 4599 | 1 /* |
| 2 * DCA compatible decoder | |
| 3 * Copyright (C) 2004 Gildas Bazin | |
| 4 * Copyright (C) 2004 Benjamin Zores | |
| 5 * Copyright (C) 2006 Benjamin Larsson | |
| 6 * Copyright (C) 2007 Konstantin Shishkov | |
| 7 * | |
| 8 * This file is part of FFmpeg. | |
| 9 * | |
| 10 * FFmpeg is free software; you can redistribute it and/or | |
| 11 * modify it under the terms of the GNU Lesser General Public | |
| 12 * License as published by the Free Software Foundation; either | |
| 13 * version 2.1 of the License, or (at your option) any later version. | |
| 14 * | |
| 15 * FFmpeg is distributed in the hope that it will be useful, | |
| 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 18 * Lesser General Public License for more details. | |
| 19 * | |
| 20 * You should have received a copy of the GNU Lesser General Public | |
| 21 * License along with FFmpeg; if not, write to the Free Software | |
| 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 23 */ | |
| 24 | |
| 25 /** | |
|
8718
e9d9d946f213
Use full internal pathname in doxygen @file directives.
diego
parents:
8226
diff
changeset
|
26 * @file libavcodec/dca.c |
| 4599 | 27 */ |
| 28 | |
| 29 #include <math.h> | |
| 30 #include <stddef.h> | |
| 31 #include <stdio.h> | |
| 32 | |
| 11606 | 33 #include "libavutil/intreadwrite.h" |
| 4599 | 34 #include "avcodec.h" |
| 35 #include "dsputil.h" | |
| 11370 | 36 #include "fft.h" |
| 9428 | 37 #include "get_bits.h" |
|
9411
4cb7c65fc775
Split bitstream.h, put the bitstream writer stuff in the new file
stefano
parents:
9393
diff
changeset
|
38 #include "put_bits.h" |
| 4599 | 39 #include "dcadata.h" |
| 40 #include "dcahuff.h" | |
| 4899 | 41 #include "dca.h" |
| 10467 | 42 #include "synth_filter.h" |
| 4599 | 43 |
| 44 //#define TRACE | |
| 45 | |
| 46 #define DCA_PRIM_CHANNELS_MAX (5) | |
| 47 #define DCA_SUBBANDS (32) | |
| 48 #define DCA_ABITS_MAX (32) /* Should be 28 */ | |
| 49 #define DCA_SUBSUBFAMES_MAX (4) | |
| 50 #define DCA_LFE_MAX (3) | |
| 51 | |
| 52 enum DCAMode { | |
| 53 DCA_MONO = 0, | |
| 54 DCA_CHANNEL, | |
| 55 DCA_STEREO, | |
| 56 DCA_STEREO_SUMDIFF, | |
| 57 DCA_STEREO_TOTAL, | |
| 58 DCA_3F, | |
| 59 DCA_2F1R, | |
| 60 DCA_3F1R, | |
| 61 DCA_2F2R, | |
| 62 DCA_3F2R, | |
| 63 DCA_4F2R | |
| 64 }; | |
| 65 | |
| 8100 | 66 /* Tables for mapping dts channel configurations to libavcodec multichannel api. |
| 67 * Some compromises have been made for special configurations. Most configurations | |
| 68 * are never used so complete accuracy is not needed. | |
| 69 * | |
| 70 * L = left, R = right, C = center, S = surround, F = front, R = rear, T = total, OV = overhead. | |
| 8126 | 71 * S -> side, when both rear and back are configured move one of them to the side channel |
| 8100 | 72 * OV -> center back |
|
8102
04295cbc0e9b
Change multichannel API define prefix from "CHANNEL_" to "CH_".
andoma
parents:
8101
diff
changeset
|
73 * All 2 channel configurations -> CH_LAYOUT_STEREO |
| 8100 | 74 */ |
| 75 | |
| 76 static const int64_t dca_core_channel_layout[] = { | |
|
8102
04295cbc0e9b
Change multichannel API define prefix from "CHANNEL_" to "CH_".
andoma
parents:
8101
diff
changeset
|
77 CH_FRONT_CENTER, ///< 1, A |
|
04295cbc0e9b
Change multichannel API define prefix from "CHANNEL_" to "CH_".
andoma
parents:
8101
diff
changeset
|
78 CH_LAYOUT_STEREO, ///< 2, A + B (dual mono) |
|
04295cbc0e9b
Change multichannel API define prefix from "CHANNEL_" to "CH_".
andoma
parents:
8101
diff
changeset
|
79 CH_LAYOUT_STEREO, ///< 2, L + R (stereo) |
|
04295cbc0e9b
Change multichannel API define prefix from "CHANNEL_" to "CH_".
andoma
parents:
8101
diff
changeset
|
80 CH_LAYOUT_STEREO, ///< 2, (L+R) + (L-R) (sum-difference) |
|
04295cbc0e9b
Change multichannel API define prefix from "CHANNEL_" to "CH_".
andoma
parents:
8101
diff
changeset
|
81 CH_LAYOUT_STEREO, ///< 2, LT +RT (left and right total) |
| 8103 | 82 CH_LAYOUT_STEREO|CH_FRONT_CENTER, ///< 3, C+L+R |
| 83 CH_LAYOUT_STEREO|CH_BACK_CENTER, ///< 3, L+R+S | |
| 84 CH_LAYOUT_STEREO|CH_FRONT_CENTER|CH_BACK_CENTER, ///< 4, C + L + R+ S | |
| 85 CH_LAYOUT_STEREO|CH_SIDE_LEFT|CH_SIDE_RIGHT, ///< 4, L + R +SL+ SR | |
| 86 CH_LAYOUT_STEREO|CH_FRONT_CENTER|CH_SIDE_LEFT|CH_SIDE_RIGHT, ///< 5, C + L + R+ SL+SR | |
| 87 CH_LAYOUT_STEREO|CH_SIDE_LEFT|CH_SIDE_RIGHT|CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER, ///< 6, CL + CR + L + R + SL + SR | |
| 88 CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_RIGHT|CH_FRONT_CENTER|CH_BACK_CENTER, ///< 6, C + L + R+ LR + RR + OV | |
| 89 CH_FRONT_CENTER|CH_FRONT_RIGHT_OF_CENTER|CH_FRONT_LEFT_OF_CENTER|CH_BACK_CENTER|CH_BACK_LEFT|CH_BACK_RIGHT, ///< 6, CF+ CR+LF+ RF+LR + RR | |
| 90 CH_FRONT_LEFT_OF_CENTER|CH_FRONT_CENTER|CH_FRONT_RIGHT_OF_CENTER|CH_LAYOUT_STEREO|CH_SIDE_LEFT|CH_SIDE_RIGHT, ///< 7, CL + C + CR + L + R + SL + SR | |
|
8102
04295cbc0e9b
Change multichannel API define prefix from "CHANNEL_" to "CH_".
andoma
parents:
8101
diff
changeset
|
91 CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER|CH_LAYOUT_STEREO|CH_SIDE_LEFT|CH_SIDE_RIGHT|CH_BACK_LEFT|CH_BACK_RIGHT, ///< 8, CL + CR + L + R + SL1 + SL2+ SR1 + SR2 |
| 8103 | 92 CH_FRONT_LEFT_OF_CENTER|CH_FRONT_CENTER|CH_FRONT_RIGHT_OF_CENTER|CH_LAYOUT_STEREO|CH_SIDE_LEFT|CH_BACK_CENTER|CH_SIDE_RIGHT, ///< 8, CL + C+ CR + L + R + SL + S+ SR |
| 8100 | 93 }; |
| 94 | |
|
8148
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
95 static const int8_t dca_lfe_index[] = { |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
96 1,2,2,2,2,3,2,3,2,3,2,3,1,3,2,3 |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
97 }; |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
98 |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
99 static const int8_t dca_channel_reorder_lfe[][8] = { |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
100 { 0, -1, -1, -1, -1, -1, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
101 { 0, 1, -1, -1, -1, -1, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
102 { 0, 1, -1, -1, -1, -1, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
103 { 0, 1, -1, -1, -1, -1, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
104 { 0, 1, -1, -1, -1, -1, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
105 { 2, 0, 1, -1, -1, -1, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
106 { 0, 1, 3, -1, -1, -1, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
107 { 2, 0, 1, 4, -1, -1, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
108 { 0, 1, 3, 4, -1, -1, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
109 { 2, 0, 1, 4, 5, -1, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
110 { 3, 4, 0, 1, 5, 6, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
111 { 2, 0, 1, 4, 5, 6, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
112 { 0, 6, 4, 5, 2, 3, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
113 { 4, 2, 5, 0, 1, 6, 7, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
114 { 5, 6, 0, 1, 7, 3, 8, 4}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
115 { 4, 2, 5, 0, 1, 6, 8, 7}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
116 }; |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
117 |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
118 static const int8_t dca_channel_reorder_nolfe[][8] = { |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
119 { 0, -1, -1, -1, -1, -1, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
120 { 0, 1, -1, -1, -1, -1, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
121 { 0, 1, -1, -1, -1, -1, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
122 { 0, 1, -1, -1, -1, -1, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
123 { 0, 1, -1, -1, -1, -1, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
124 { 2, 0, 1, -1, -1, -1, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
125 { 0, 1, 2, -1, -1, -1, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
126 { 2, 0, 1, 3, -1, -1, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
127 { 0, 1, 2, 3, -1, -1, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
128 { 2, 0, 1, 3, 4, -1, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
129 { 2, 3, 0, 1, 4, 5, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
130 { 2, 0, 1, 3, 4, 5, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
131 { 0, 5, 3, 4, 1, 2, -1, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
132 { 3, 2, 4, 0, 1, 5, 6, -1}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
133 { 4, 5, 0, 1, 6, 2, 7, 3}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
134 { 3, 2, 4, 0, 1, 5, 7, 6}, |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
135 }; |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
136 |
| 8100 | 137 |
| 4599 | 138 #define DCA_DOLBY 101 /* FIXME */ |
| 139 | |
| 140 #define DCA_CHANNEL_BITS 6 | |
| 141 #define DCA_CHANNEL_MASK 0x3F | |
| 142 | |
| 143 #define DCA_LFE 0x80 | |
| 144 | |
| 145 #define HEADER_SIZE 14 | |
| 146 | |
|
7670
dabe2516abe2
Increase buffer size to 16384 patch by Alexander E. Patrakov" patrakov gmail
michael
parents:
7451
diff
changeset
|
147 #define DCA_MAX_FRAME_SIZE 16384 |
| 4599 | 148 |
| 149 /** Bit allocation */ | |
| 150 typedef struct { | |
| 151 int offset; ///< code values offset | |
| 152 int maxbits[8]; ///< max bits in VLC | |
| 153 int wrap; ///< wrap for get_vlc2() | |
| 154 VLC vlc[8]; ///< actual codes | |
| 155 } BitAlloc; | |
| 156 | |
| 157 static BitAlloc dca_bitalloc_index; ///< indexes for samples VLC select | |
| 158 static BitAlloc dca_tmode; ///< transition mode VLCs | |
| 159 static BitAlloc dca_scalefactor; ///< scalefactor VLCs | |
| 160 static BitAlloc dca_smpl_bitalloc[11]; ///< samples VLCs | |
| 161 | |
|
4908
777f250df232
Fix multiple "?inline/static? is not at beginning of declaration" warnings.
diego
parents:
4899
diff
changeset
|
162 static av_always_inline int get_bitalloc(GetBitContext *gb, BitAlloc *ba, int idx) |
| 4599 | 163 { |
| 164 return get_vlc2(gb, ba->vlc[idx].table, ba->vlc[idx].bits, ba->wrap) + ba->offset; | |
| 165 } | |
| 166 | |
| 167 typedef struct { | |
| 168 AVCodecContext *avctx; | |
| 169 /* Frame header */ | |
| 170 int frame_type; ///< type of the current frame | |
| 171 int samples_deficit; ///< deficit sample count | |
| 172 int crc_present; ///< crc is present in the bitstream | |
| 173 int sample_blocks; ///< number of PCM sample blocks | |
| 174 int frame_size; ///< primary frame byte size | |
| 175 int amode; ///< audio channels arrangement | |
| 176 int sample_rate; ///< audio sampling rate | |
| 177 int bit_rate; ///< transmission bit rate | |
| 8077 | 178 int bit_rate_index; ///< transmission bit rate index |
| 4599 | 179 |
| 180 int downmix; ///< embedded downmix enabled | |
| 181 int dynrange; ///< embedded dynamic range flag | |
| 182 int timestamp; ///< embedded time stamp flag | |
| 183 int aux_data; ///< auxiliary data flag | |
| 184 int hdcd; ///< source material is mastered in HDCD | |
| 185 int ext_descr; ///< extension audio descriptor flag | |
| 186 int ext_coding; ///< extended coding flag | |
| 187 int aspf; ///< audio sync word insertion flag | |
| 188 int lfe; ///< low frequency effects flag | |
| 189 int predictor_history; ///< predictor history flag | |
| 190 int header_crc; ///< header crc check bytes | |
| 191 int multirate_inter; ///< multirate interpolator switch | |
| 192 int version; ///< encoder software revision | |
| 193 int copy_history; ///< copy history | |
| 194 int source_pcm_res; ///< source pcm resolution | |
| 195 int front_sum; ///< front sum/difference flag | |
| 196 int surround_sum; ///< surround sum/difference flag | |
| 197 int dialog_norm; ///< dialog normalisation parameter | |
| 198 | |
| 199 /* Primary audio coding header */ | |
| 200 int subframes; ///< number of subframes | |
| 6463 | 201 int total_channels; ///< number of channels including extensions |
| 4599 | 202 int prim_channels; ///< number of primary audio channels |
| 203 int subband_activity[DCA_PRIM_CHANNELS_MAX]; ///< subband activity count | |
| 204 int vq_start_subband[DCA_PRIM_CHANNELS_MAX]; ///< high frequency vq start subband | |
| 205 int joint_intensity[DCA_PRIM_CHANNELS_MAX]; ///< joint intensity coding index | |
| 206 int transient_huffman[DCA_PRIM_CHANNELS_MAX]; ///< transient mode code book | |
| 207 int scalefactor_huffman[DCA_PRIM_CHANNELS_MAX]; ///< scale factor code book | |
| 208 int bitalloc_huffman[DCA_PRIM_CHANNELS_MAX]; ///< bit allocation quantizer select | |
| 209 int quant_index_huffman[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX]; ///< quantization index codebook select | |
| 210 float scalefactor_adj[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX]; ///< scale factor adjustment | |
| 211 | |
| 212 /* Primary audio coding side information */ | |
| 213 int subsubframes; ///< number of subsubframes | |
| 214 int partial_samples; ///< partial subsubframe samples count | |
| 215 int prediction_mode[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< prediction mode (ADPCM used or not) | |
| 216 int prediction_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< prediction VQ coefs | |
| 217 int bitalloc[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< bit allocation index | |
| 218 int transition_mode[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< transition mode (transients) | |
| 219 int scale_factor[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][2]; ///< scale factors (2 if transient) | |
| 220 int joint_huff[DCA_PRIM_CHANNELS_MAX]; ///< joint subband scale factors codebook | |
| 221 int joint_scale_factor[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< joint subband scale factors | |
| 222 int downmix_coef[DCA_PRIM_CHANNELS_MAX][2]; ///< stereo downmix coefficients | |
| 223 int dynrange_coef; ///< dynamic range coefficient | |
| 224 | |
| 225 int high_freq_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< VQ encoded high frequency subbands | |
| 226 | |
| 227 float lfe_data[2 * DCA_SUBSUBFAMES_MAX * DCA_LFE_MAX * | |
| 228 2 /*history */ ]; ///< Low frequency effect data | |
| 229 int lfe_scale_factor; | |
| 230 | |
| 231 /* Subband samples history (for ADPCM) */ | |
| 232 float subband_samples_hist[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][4]; | |
| 11369 | 233 DECLARE_ALIGNED(16, float, subband_fir_hist)[DCA_PRIM_CHANNELS_MAX][512]; |
| 11591 | 234 DECLARE_ALIGNED(16, float, subband_fir_noidea)[DCA_PRIM_CHANNELS_MAX][32]; |
| 7737 | 235 int hist_index[DCA_PRIM_CHANNELS_MAX]; |
| 11369 | 236 DECLARE_ALIGNED(16, float, raXin)[32]; |
| 4599 | 237 |
| 238 int output; ///< type of output | |
|
8062
17aeecee2a97
Fix dca decoder with non simd float2int16 conversion
banan
parents:
8061
diff
changeset
|
239 float add_bias; ///< output bias |
|
17aeecee2a97
Fix dca decoder with non simd float2int16 conversion
banan
parents:
8061
diff
changeset
|
240 float scale_bias; ///< output scale |
| 4599 | 241 |
| 11369 | 242 DECLARE_ALIGNED(16, float, samples)[1536]; /* 6 * 256 = 1536, might only need 5 */ |
| 7726 | 243 const float *samples_chanptr[6]; |
| 4599 | 244 |
| 245 uint8_t dca_buffer[DCA_MAX_FRAME_SIZE]; | |
| 246 int dca_buffer_size; ///< how much data is in the dca_buffer | |
| 247 | |
|
8148
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
248 const int8_t* channel_order_tab; ///< channel reordering table, lfe and non lfe |
| 4599 | 249 GetBitContext gb; |
| 250 /* Current position in DCA frame */ | |
| 251 int current_subframe; | |
| 252 int current_subsubframe; | |
| 253 | |
| 254 int debug_flag; ///< used for suppressing repeated error messages output | |
| 255 DSPContext dsp; | |
| 10199 | 256 FFTContext imdct; |
| 11592 | 257 SynthFilterContext synth; |
| 4599 | 258 } DCAContext; |
| 259 | |
|
9526
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
260 static const uint16_t dca_vlc_offs[] = { |
|
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
261 0, 512, 640, 768, 1282, 1794, 2436, 3080, 3770, 4454, 5364, |
|
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
262 5372, 5380, 5388, 5392, 5396, 5412, 5420, 5428, 5460, 5492, 5508, |
|
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
263 5572, 5604, 5668, 5796, 5860, 5892, 6412, 6668, 6796, 7308, 7564, |
|
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
264 7820, 8076, 8620, 9132, 9388, 9910, 10166, 10680, 11196, 11726, 12240, |
|
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
265 12752, 13298, 13810, 14326, 14840, 15500, 16022, 16540, 17158, 17678, 18264, |
|
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
266 18796, 19352, 19926, 20468, 21472, 22398, 23014, 23622, |
|
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
267 }; |
|
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
268 |
|
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
6463
diff
changeset
|
269 static av_cold void dca_init_vlcs(void) |
| 4599 | 270 { |
| 6350 | 271 static int vlcs_initialized = 0; |
|
9526
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
272 int i, j, c = 14; |
|
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
273 static VLC_TYPE dca_table[23622][2]; |
| 4599 | 274 |
| 6350 | 275 if (vlcs_initialized) |
| 4599 | 276 return; |
| 277 | |
| 278 dca_bitalloc_index.offset = 1; | |
| 5070 | 279 dca_bitalloc_index.wrap = 2; |
|
9526
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
280 for (i = 0; i < 5; i++) { |
|
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
281 dca_bitalloc_index.vlc[i].table = &dca_table[dca_vlc_offs[i]]; |
|
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
282 dca_bitalloc_index.vlc[i].table_allocated = dca_vlc_offs[i + 1] - dca_vlc_offs[i]; |
| 4599 | 283 init_vlc(&dca_bitalloc_index.vlc[i], bitalloc_12_vlc_bits[i], 12, |
| 284 bitalloc_12_bits[i], 1, 1, | |
|
9526
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
285 bitalloc_12_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); |
|
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
286 } |
| 4599 | 287 dca_scalefactor.offset = -64; |
| 288 dca_scalefactor.wrap = 2; | |
|
9526
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
289 for (i = 0; i < 5; i++) { |
|
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
290 dca_scalefactor.vlc[i].table = &dca_table[dca_vlc_offs[i + 5]]; |
|
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
291 dca_scalefactor.vlc[i].table_allocated = dca_vlc_offs[i + 6] - dca_vlc_offs[i + 5]; |
| 4599 | 292 init_vlc(&dca_scalefactor.vlc[i], SCALES_VLC_BITS, 129, |
| 293 scales_bits[i], 1, 1, | |
|
9526
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
294 scales_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); |
|
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
295 } |
| 4599 | 296 dca_tmode.offset = 0; |
| 297 dca_tmode.wrap = 1; | |
|
9526
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
298 for (i = 0; i < 4; i++) { |
|
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
299 dca_tmode.vlc[i].table = &dca_table[dca_vlc_offs[i + 10]]; |
|
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
300 dca_tmode.vlc[i].table_allocated = dca_vlc_offs[i + 11] - dca_vlc_offs[i + 10]; |
| 4599 | 301 init_vlc(&dca_tmode.vlc[i], tmode_vlc_bits[i], 4, |
| 302 tmode_bits[i], 1, 1, | |
|
9526
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
303 tmode_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); |
|
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
304 } |
| 4599 | 305 |
| 306 for(i = 0; i < 10; i++) | |
| 307 for(j = 0; j < 7; j++){ | |
| 308 if(!bitalloc_codes[i][j]) break; | |
| 309 dca_smpl_bitalloc[i+1].offset = bitalloc_offsets[i]; | |
| 310 dca_smpl_bitalloc[i+1].wrap = 1 + (j > 4); | |
|
9526
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
311 dca_smpl_bitalloc[i+1].vlc[j].table = &dca_table[dca_vlc_offs[c]]; |
|
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
312 dca_smpl_bitalloc[i+1].vlc[j].table_allocated = dca_vlc_offs[c + 1] - dca_vlc_offs[c]; |
| 4599 | 313 init_vlc(&dca_smpl_bitalloc[i+1].vlc[j], bitalloc_maxbits[i][j], |
| 314 bitalloc_sizes[i], | |
| 315 bitalloc_bits[i][j], 1, 1, | |
|
9526
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
316 bitalloc_codes[i][j], 2, 2, INIT_VLC_USE_NEW_STATIC); |
|
b9216a975c7f
Make VLC tables in DCA decoder use INIT_VLC_USE_NEW_STATIC
kostya
parents:
9428
diff
changeset
|
317 c++; |
| 4599 | 318 } |
| 6350 | 319 vlcs_initialized = 1; |
| 4599 | 320 } |
| 321 | |
| 322 static inline void get_array(GetBitContext *gb, int *dst, int len, int bits) | |
| 323 { | |
| 324 while(len--) | |
| 325 *dst++ = get_bits(gb, bits); | |
| 326 } | |
| 327 | |
| 328 static int dca_parse_frame_header(DCAContext * s) | |
| 329 { | |
| 330 int i, j; | |
| 331 static const float adj_table[4] = { 1.0, 1.1250, 1.2500, 1.4375 }; | |
| 332 static const int bitlen[11] = { 0, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 }; | |
| 333 static const int thr[11] = { 0, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7 }; | |
| 334 | |
| 335 init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8); | |
| 336 | |
| 337 /* Sync code */ | |
| 338 get_bits(&s->gb, 32); | |
| 339 | |
| 340 /* Frame header */ | |
| 341 s->frame_type = get_bits(&s->gb, 1); | |
| 342 s->samples_deficit = get_bits(&s->gb, 5) + 1; | |
| 343 s->crc_present = get_bits(&s->gb, 1); | |
| 344 s->sample_blocks = get_bits(&s->gb, 7) + 1; | |
| 345 s->frame_size = get_bits(&s->gb, 14) + 1; | |
| 346 if (s->frame_size < 95) | |
| 347 return -1; | |
| 348 s->amode = get_bits(&s->gb, 6); | |
| 349 s->sample_rate = dca_sample_rates[get_bits(&s->gb, 4)]; | |
| 350 if (!s->sample_rate) | |
| 351 return -1; | |
| 8078 | 352 s->bit_rate_index = get_bits(&s->gb, 5); |
| 8077 | 353 s->bit_rate = dca_bit_rates[s->bit_rate_index]; |
| 4599 | 354 if (!s->bit_rate) |
| 355 return -1; | |
| 356 | |
| 357 s->downmix = get_bits(&s->gb, 1); | |
| 358 s->dynrange = get_bits(&s->gb, 1); | |
| 359 s->timestamp = get_bits(&s->gb, 1); | |
| 360 s->aux_data = get_bits(&s->gb, 1); | |
| 361 s->hdcd = get_bits(&s->gb, 1); | |
| 362 s->ext_descr = get_bits(&s->gb, 3); | |
| 363 s->ext_coding = get_bits(&s->gb, 1); | |
| 364 s->aspf = get_bits(&s->gb, 1); | |
| 365 s->lfe = get_bits(&s->gb, 2); | |
| 366 s->predictor_history = get_bits(&s->gb, 1); | |
| 367 | |
| 368 /* TODO: check CRC */ | |
| 369 if (s->crc_present) | |
| 370 s->header_crc = get_bits(&s->gb, 16); | |
| 371 | |
| 372 s->multirate_inter = get_bits(&s->gb, 1); | |
| 373 s->version = get_bits(&s->gb, 4); | |
| 374 s->copy_history = get_bits(&s->gb, 2); | |
| 375 s->source_pcm_res = get_bits(&s->gb, 3); | |
| 376 s->front_sum = get_bits(&s->gb, 1); | |
| 377 s->surround_sum = get_bits(&s->gb, 1); | |
| 378 s->dialog_norm = get_bits(&s->gb, 4); | |
| 379 | |
| 380 /* FIXME: channels mixing levels */ | |
| 4893 | 381 s->output = s->amode; |
| 382 if(s->lfe) s->output |= DCA_LFE; | |
| 4599 | 383 |
| 384 #ifdef TRACE | |
| 385 av_log(s->avctx, AV_LOG_DEBUG, "frame type: %i\n", s->frame_type); | |
| 386 av_log(s->avctx, AV_LOG_DEBUG, "samples deficit: %i\n", s->samples_deficit); | |
| 387 av_log(s->avctx, AV_LOG_DEBUG, "crc present: %i\n", s->crc_present); | |
| 388 av_log(s->avctx, AV_LOG_DEBUG, "sample blocks: %i (%i samples)\n", | |
| 389 s->sample_blocks, s->sample_blocks * 32); | |
| 390 av_log(s->avctx, AV_LOG_DEBUG, "frame size: %i bytes\n", s->frame_size); | |
| 391 av_log(s->avctx, AV_LOG_DEBUG, "amode: %i (%i channels)\n", | |
| 392 s->amode, dca_channels[s->amode]); | |
| 8061 | 393 av_log(s->avctx, AV_LOG_DEBUG, "sample rate: %i Hz\n", |
| 394 s->sample_rate); | |
| 395 av_log(s->avctx, AV_LOG_DEBUG, "bit rate: %i bits/s\n", | |
| 396 s->bit_rate); | |
| 4599 | 397 av_log(s->avctx, AV_LOG_DEBUG, "downmix: %i\n", s->downmix); |
| 398 av_log(s->avctx, AV_LOG_DEBUG, "dynrange: %i\n", s->dynrange); | |
| 399 av_log(s->avctx, AV_LOG_DEBUG, "timestamp: %i\n", s->timestamp); | |
| 400 av_log(s->avctx, AV_LOG_DEBUG, "aux_data: %i\n", s->aux_data); | |
| 401 av_log(s->avctx, AV_LOG_DEBUG, "hdcd: %i\n", s->hdcd); | |
| 402 av_log(s->avctx, AV_LOG_DEBUG, "ext descr: %i\n", s->ext_descr); | |
| 403 av_log(s->avctx, AV_LOG_DEBUG, "ext coding: %i\n", s->ext_coding); | |
| 404 av_log(s->avctx, AV_LOG_DEBUG, "aspf: %i\n", s->aspf); | |
| 405 av_log(s->avctx, AV_LOG_DEBUG, "lfe: %i\n", s->lfe); | |
| 406 av_log(s->avctx, AV_LOG_DEBUG, "predictor history: %i\n", | |
| 407 s->predictor_history); | |
| 408 av_log(s->avctx, AV_LOG_DEBUG, "header crc: %i\n", s->header_crc); | |
| 409 av_log(s->avctx, AV_LOG_DEBUG, "multirate inter: %i\n", | |
| 410 s->multirate_inter); | |
| 411 av_log(s->avctx, AV_LOG_DEBUG, "version number: %i\n", s->version); | |
| 412 av_log(s->avctx, AV_LOG_DEBUG, "copy history: %i\n", s->copy_history); | |
| 413 av_log(s->avctx, AV_LOG_DEBUG, | |
| 414 "source pcm resolution: %i (%i bits/sample)\n", | |
| 415 s->source_pcm_res, dca_bits_per_sample[s->source_pcm_res]); | |
| 416 av_log(s->avctx, AV_LOG_DEBUG, "front sum: %i\n", s->front_sum); | |
| 417 av_log(s->avctx, AV_LOG_DEBUG, "surround sum: %i\n", s->surround_sum); | |
| 418 av_log(s->avctx, AV_LOG_DEBUG, "dialog norm: %i\n", s->dialog_norm); | |
| 419 av_log(s->avctx, AV_LOG_DEBUG, "\n"); | |
| 420 #endif | |
| 421 | |
| 422 /* Primary audio coding header */ | |
| 423 s->subframes = get_bits(&s->gb, 4) + 1; | |
| 6463 | 424 s->total_channels = get_bits(&s->gb, 3) + 1; |
| 425 s->prim_channels = s->total_channels; | |
| 426 if (s->prim_channels > DCA_PRIM_CHANNELS_MAX) | |
| 427 s->prim_channels = DCA_PRIM_CHANNELS_MAX; /* We only support DTS core */ | |
| 4599 | 428 |
| 429 | |
| 430 for (i = 0; i < s->prim_channels; i++) { | |
| 431 s->subband_activity[i] = get_bits(&s->gb, 5) + 2; | |
| 432 if (s->subband_activity[i] > DCA_SUBBANDS) | |
| 433 s->subband_activity[i] = DCA_SUBBANDS; | |
| 434 } | |
| 435 for (i = 0; i < s->prim_channels; i++) { | |
| 436 s->vq_start_subband[i] = get_bits(&s->gb, 5) + 1; | |
| 437 if (s->vq_start_subband[i] > DCA_SUBBANDS) | |
| 438 s->vq_start_subband[i] = DCA_SUBBANDS; | |
| 439 } | |
| 440 get_array(&s->gb, s->joint_intensity, s->prim_channels, 3); | |
| 441 get_array(&s->gb, s->transient_huffman, s->prim_channels, 2); | |
| 442 get_array(&s->gb, s->scalefactor_huffman, s->prim_channels, 3); | |
| 443 get_array(&s->gb, s->bitalloc_huffman, s->prim_channels, 3); | |
| 444 | |
| 445 /* Get codebooks quantization indexes */ | |
| 446 memset(s->quant_index_huffman, 0, sizeof(s->quant_index_huffman)); | |
| 447 for (j = 1; j < 11; j++) | |
| 448 for (i = 0; i < s->prim_channels; i++) | |
| 449 s->quant_index_huffman[i][j] = get_bits(&s->gb, bitlen[j]); | |
| 450 | |
| 451 /* Get scale factor adjustment */ | |
| 452 for (j = 0; j < 11; j++) | |
| 453 for (i = 0; i < s->prim_channels; i++) | |
| 454 s->scalefactor_adj[i][j] = 1; | |
| 455 | |
| 456 for (j = 1; j < 11; j++) | |
| 457 for (i = 0; i < s->prim_channels; i++) | |
| 458 if (s->quant_index_huffman[i][j] < thr[j]) | |
| 459 s->scalefactor_adj[i][j] = adj_table[get_bits(&s->gb, 2)]; | |
| 460 | |
| 461 if (s->crc_present) { | |
| 462 /* Audio header CRC check */ | |
| 463 get_bits(&s->gb, 16); | |
| 464 } | |
| 465 | |
| 466 s->current_subframe = 0; | |
| 467 s->current_subsubframe = 0; | |
| 468 | |
| 469 #ifdef TRACE | |
| 470 av_log(s->avctx, AV_LOG_DEBUG, "subframes: %i\n", s->subframes); | |
| 471 av_log(s->avctx, AV_LOG_DEBUG, "prim channels: %i\n", s->prim_channels); | |
| 472 for(i = 0; i < s->prim_channels; i++){ | |
| 473 av_log(s->avctx, AV_LOG_DEBUG, "subband activity: %i\n", s->subband_activity[i]); | |
| 474 av_log(s->avctx, AV_LOG_DEBUG, "vq start subband: %i\n", s->vq_start_subband[i]); | |
| 475 av_log(s->avctx, AV_LOG_DEBUG, "joint intensity: %i\n", s->joint_intensity[i]); | |
| 476 av_log(s->avctx, AV_LOG_DEBUG, "transient mode codebook: %i\n", s->transient_huffman[i]); | |
| 477 av_log(s->avctx, AV_LOG_DEBUG, "scale factor codebook: %i\n", s->scalefactor_huffman[i]); | |
| 478 av_log(s->avctx, AV_LOG_DEBUG, "bit allocation quantizer: %i\n", s->bitalloc_huffman[i]); | |
| 479 av_log(s->avctx, AV_LOG_DEBUG, "quant index huff:"); | |
| 480 for (j = 0; j < 11; j++) | |
| 481 av_log(s->avctx, AV_LOG_DEBUG, " %i", | |
| 482 s->quant_index_huffman[i][j]); | |
| 483 av_log(s->avctx, AV_LOG_DEBUG, "\n"); | |
| 484 av_log(s->avctx, AV_LOG_DEBUG, "scalefac adj:"); | |
| 485 for (j = 0; j < 11; j++) | |
| 486 av_log(s->avctx, AV_LOG_DEBUG, " %1.3f", s->scalefactor_adj[i][j]); | |
| 487 av_log(s->avctx, AV_LOG_DEBUG, "\n"); | |
| 488 } | |
| 489 #endif | |
| 490 | |
| 491 return 0; | |
| 492 } | |
| 493 | |
| 494 | |
|
4876
384c95879d8b
1000l to myself as used VLC indexes were totally wrong
kostya
parents:
4783
diff
changeset
|
495 static inline int get_scale(GetBitContext *gb, int level, int value) |
| 4599 | 496 { |
| 497 if (level < 5) { | |
| 498 /* huffman encoded */ | |
|
4876
384c95879d8b
1000l to myself as used VLC indexes were totally wrong
kostya
parents:
4783
diff
changeset
|
499 value += get_bitalloc(gb, &dca_scalefactor, level); |
| 4599 | 500 } else if(level < 8) |
| 501 value = get_bits(gb, level + 1); | |
| 502 return value; | |
| 503 } | |
| 504 | |
| 505 static int dca_subframe_header(DCAContext * s) | |
| 506 { | |
| 507 /* Primary audio coding side information */ | |
| 508 int j, k; | |
| 509 | |
| 510 s->subsubframes = get_bits(&s->gb, 2) + 1; | |
| 511 s->partial_samples = get_bits(&s->gb, 3); | |
| 512 for (j = 0; j < s->prim_channels; j++) { | |
| 513 for (k = 0; k < s->subband_activity[j]; k++) | |
| 514 s->prediction_mode[j][k] = get_bits(&s->gb, 1); | |
| 515 } | |
| 516 | |
| 517 /* Get prediction codebook */ | |
| 518 for (j = 0; j < s->prim_channels; j++) { | |
| 519 for (k = 0; k < s->subband_activity[j]; k++) { | |
| 520 if (s->prediction_mode[j][k] > 0) { | |
| 521 /* (Prediction coefficient VQ address) */ | |
| 522 s->prediction_vq[j][k] = get_bits(&s->gb, 12); | |
| 523 } | |
| 524 } | |
| 525 } | |
| 526 | |
| 527 /* Bit allocation index */ | |
| 528 for (j = 0; j < s->prim_channels; j++) { | |
| 529 for (k = 0; k < s->vq_start_subband[j]; k++) { | |
| 530 if (s->bitalloc_huffman[j] == 6) | |
| 531 s->bitalloc[j][k] = get_bits(&s->gb, 5); | |
| 532 else if (s->bitalloc_huffman[j] == 5) | |
| 533 s->bitalloc[j][k] = get_bits(&s->gb, 4); | |
| 6463 | 534 else if (s->bitalloc_huffman[j] == 7) { |
| 535 av_log(s->avctx, AV_LOG_ERROR, | |
| 536 "Invalid bit allocation index\n"); | |
| 537 return -1; | |
| 538 } else { | |
| 4599 | 539 s->bitalloc[j][k] = |
|
4876
384c95879d8b
1000l to myself as used VLC indexes were totally wrong
kostya
parents:
4783
diff
changeset
|
540 get_bitalloc(&s->gb, &dca_bitalloc_index, s->bitalloc_huffman[j]); |
| 4599 | 541 } |
| 542 | |
| 543 if (s->bitalloc[j][k] > 26) { | |
| 544 // av_log(s->avctx,AV_LOG_DEBUG,"bitalloc index [%i][%i] too big (%i)\n", | |
| 545 // j, k, s->bitalloc[j][k]); | |
| 546 return -1; | |
| 547 } | |
| 548 } | |
| 549 } | |
| 550 | |
| 551 /* Transition mode */ | |
| 552 for (j = 0; j < s->prim_channels; j++) { | |
| 553 for (k = 0; k < s->subband_activity[j]; k++) { | |
| 554 s->transition_mode[j][k] = 0; | |
| 555 if (s->subsubframes > 1 && | |
| 556 k < s->vq_start_subband[j] && s->bitalloc[j][k] > 0) { | |
| 557 s->transition_mode[j][k] = | |
| 558 get_bitalloc(&s->gb, &dca_tmode, s->transient_huffman[j]); | |
| 559 } | |
| 560 } | |
| 561 } | |
| 562 | |
| 563 for (j = 0; j < s->prim_channels; j++) { | |
| 6214 | 564 const uint32_t *scale_table; |
| 4599 | 565 int scale_sum; |
| 566 | |
| 567 memset(s->scale_factor[j], 0, s->subband_activity[j] * sizeof(s->scale_factor[0][0][0]) * 2); | |
| 568 | |
| 569 if (s->scalefactor_huffman[j] == 6) | |
| 6214 | 570 scale_table = scale_factor_quant7; |
| 4599 | 571 else |
| 6214 | 572 scale_table = scale_factor_quant6; |
| 4599 | 573 |
| 574 /* When huffman coded, only the difference is encoded */ | |
| 575 scale_sum = 0; | |
| 576 | |
| 577 for (k = 0; k < s->subband_activity[j]; k++) { | |
| 578 if (k >= s->vq_start_subband[j] || s->bitalloc[j][k] > 0) { | |
|
4876
384c95879d8b
1000l to myself as used VLC indexes were totally wrong
kostya
parents:
4783
diff
changeset
|
579 scale_sum = get_scale(&s->gb, s->scalefactor_huffman[j], scale_sum); |
| 4599 | 580 s->scale_factor[j][k][0] = scale_table[scale_sum]; |
| 581 } | |
| 582 | |
| 583 if (k < s->vq_start_subband[j] && s->transition_mode[j][k]) { | |
| 584 /* Get second scale factor */ | |
|
4876
384c95879d8b
1000l to myself as used VLC indexes were totally wrong
kostya
parents:
4783
diff
changeset
|
585 scale_sum = get_scale(&s->gb, s->scalefactor_huffman[j], scale_sum); |
| 4599 | 586 s->scale_factor[j][k][1] = scale_table[scale_sum]; |
| 587 } | |
| 588 } | |
| 589 } | |
| 590 | |
| 591 /* Joint subband scale factor codebook select */ | |
| 592 for (j = 0; j < s->prim_channels; j++) { | |
| 593 /* Transmitted only if joint subband coding enabled */ | |
| 594 if (s->joint_intensity[j] > 0) | |
| 595 s->joint_huff[j] = get_bits(&s->gb, 3); | |
| 596 } | |
| 597 | |
| 598 /* Scale factors for joint subband coding */ | |
| 599 for (j = 0; j < s->prim_channels; j++) { | |
| 600 int source_channel; | |
| 601 | |
| 602 /* Transmitted only if joint subband coding enabled */ | |
| 603 if (s->joint_intensity[j] > 0) { | |
| 604 int scale = 0; | |
| 605 source_channel = s->joint_intensity[j] - 1; | |
| 606 | |
| 607 /* When huffman coded, only the difference is encoded | |
| 608 * (is this valid as well for joint scales ???) */ | |
| 609 | |
| 610 for (k = s->subband_activity[j]; k < s->subband_activity[source_channel]; k++) { | |
|
4876
384c95879d8b
1000l to myself as used VLC indexes were totally wrong
kostya
parents:
4783
diff
changeset
|
611 scale = get_scale(&s->gb, s->joint_huff[j], 0); |
| 4599 | 612 scale += 64; /* bias */ |
| 613 s->joint_scale_factor[j][k] = scale; /*joint_scale_table[scale]; */ | |
| 614 } | |
| 615 | |
| 10380 | 616 if (!(s->debug_flag & 0x02)) { |
| 4599 | 617 av_log(s->avctx, AV_LOG_DEBUG, |
| 618 "Joint stereo coding not supported\n"); | |
| 619 s->debug_flag |= 0x02; | |
| 620 } | |
| 621 } | |
| 622 } | |
| 623 | |
| 624 /* Stereo downmix coefficients */ | |
| 4894 | 625 if (s->prim_channels > 2) { |
| 626 if(s->downmix) { | |
| 4895 | 627 for (j = 0; j < s->prim_channels; j++) { |
| 628 s->downmix_coef[j][0] = get_bits(&s->gb, 7); | |
| 629 s->downmix_coef[j][1] = get_bits(&s->gb, 7); | |
| 630 } | |
| 4894 | 631 } else { |
| 632 int am = s->amode & DCA_CHANNEL_MASK; | |
| 633 for (j = 0; j < s->prim_channels; j++) { | |
| 634 s->downmix_coef[j][0] = dca_default_coeffs[am][j][0]; | |
| 635 s->downmix_coef[j][1] = dca_default_coeffs[am][j][1]; | |
| 636 } | |
| 637 } | |
| 4599 | 638 } |
| 639 | |
| 640 /* Dynamic range coefficient */ | |
| 641 if (s->dynrange) | |
| 642 s->dynrange_coef = get_bits(&s->gb, 8); | |
| 643 | |
| 644 /* Side information CRC check word */ | |
| 645 if (s->crc_present) { | |
| 646 get_bits(&s->gb, 16); | |
| 647 } | |
| 648 | |
| 649 /* | |
| 650 * Primary audio data arrays | |
| 651 */ | |
| 652 | |
| 653 /* VQ encoded high frequency subbands */ | |
| 654 for (j = 0; j < s->prim_channels; j++) | |
| 655 for (k = s->vq_start_subband[j]; k < s->subband_activity[j]; k++) | |
| 656 /* 1 vector -> 32 samples */ | |
| 657 s->high_freq_vq[j][k] = get_bits(&s->gb, 10); | |
| 658 | |
| 659 /* Low frequency effect data */ | |
| 660 if (s->lfe) { | |
| 661 /* LFE samples */ | |
| 662 int lfe_samples = 2 * s->lfe * s->subsubframes; | |
| 663 float lfe_scale; | |
| 664 | |
| 665 for (j = lfe_samples; j < lfe_samples * 2; j++) { | |
| 666 /* Signed 8 bits int */ | |
| 667 s->lfe_data[j] = get_sbits(&s->gb, 8); | |
| 668 } | |
| 669 | |
| 670 /* Scale factor index */ | |
| 671 s->lfe_scale_factor = scale_factor_quant7[get_bits(&s->gb, 8)]; | |
| 672 | |
| 673 /* Quantization step size * scale factor */ | |
| 674 lfe_scale = 0.035 * s->lfe_scale_factor; | |
| 675 | |
| 676 for (j = lfe_samples; j < lfe_samples * 2; j++) | |
| 677 s->lfe_data[j] *= lfe_scale; | |
| 678 } | |
| 679 | |
| 680 #ifdef TRACE | |
| 681 av_log(s->avctx, AV_LOG_DEBUG, "subsubframes: %i\n", s->subsubframes); | |
| 682 av_log(s->avctx, AV_LOG_DEBUG, "partial samples: %i\n", | |
| 683 s->partial_samples); | |
| 684 for (j = 0; j < s->prim_channels; j++) { | |
| 685 av_log(s->avctx, AV_LOG_DEBUG, "prediction mode:"); | |
| 686 for (k = 0; k < s->subband_activity[j]; k++) | |
| 687 av_log(s->avctx, AV_LOG_DEBUG, " %i", s->prediction_mode[j][k]); | |
| 688 av_log(s->avctx, AV_LOG_DEBUG, "\n"); | |
| 689 } | |
| 690 for (j = 0; j < s->prim_channels; j++) { | |
| 691 for (k = 0; k < s->subband_activity[j]; k++) | |
| 692 av_log(s->avctx, AV_LOG_DEBUG, | |
| 693 "prediction coefs: %f, %f, %f, %f\n", | |
| 694 (float) adpcm_vb[s->prediction_vq[j][k]][0] / 8192, | |
| 695 (float) adpcm_vb[s->prediction_vq[j][k]][1] / 8192, | |
| 696 (float) adpcm_vb[s->prediction_vq[j][k]][2] / 8192, | |
| 697 (float) adpcm_vb[s->prediction_vq[j][k]][3] / 8192); | |
| 698 } | |
| 699 for (j = 0; j < s->prim_channels; j++) { | |
| 700 av_log(s->avctx, AV_LOG_DEBUG, "bitalloc index: "); | |
| 701 for (k = 0; k < s->vq_start_subband[j]; k++) | |
| 702 av_log(s->avctx, AV_LOG_DEBUG, "%2.2i ", s->bitalloc[j][k]); | |
| 703 av_log(s->avctx, AV_LOG_DEBUG, "\n"); | |
| 704 } | |
| 705 for (j = 0; j < s->prim_channels; j++) { | |
| 706 av_log(s->avctx, AV_LOG_DEBUG, "Transition mode:"); | |
| 707 for (k = 0; k < s->subband_activity[j]; k++) | |
| 708 av_log(s->avctx, AV_LOG_DEBUG, " %i", s->transition_mode[j][k]); | |
| 709 av_log(s->avctx, AV_LOG_DEBUG, "\n"); | |
| 710 } | |
| 711 for (j = 0; j < s->prim_channels; j++) { | |
| 712 av_log(s->avctx, AV_LOG_DEBUG, "Scale factor:"); | |
| 713 for (k = 0; k < s->subband_activity[j]; k++) { | |
| 714 if (k >= s->vq_start_subband[j] || s->bitalloc[j][k] > 0) | |
| 715 av_log(s->avctx, AV_LOG_DEBUG, " %i", s->scale_factor[j][k][0]); | |
| 716 if (k < s->vq_start_subband[j] && s->transition_mode[j][k]) | |
| 717 av_log(s->avctx, AV_LOG_DEBUG, " %i(t)", s->scale_factor[j][k][1]); | |
| 718 } | |
| 719 av_log(s->avctx, AV_LOG_DEBUG, "\n"); | |
| 720 } | |
| 721 for (j = 0; j < s->prim_channels; j++) { | |
| 722 if (s->joint_intensity[j] > 0) { | |
| 5069 | 723 int source_channel = s->joint_intensity[j] - 1; |
| 4599 | 724 av_log(s->avctx, AV_LOG_DEBUG, "Joint scale factor index:\n"); |
| 725 for (k = s->subband_activity[j]; k < s->subband_activity[source_channel]; k++) | |
| 726 av_log(s->avctx, AV_LOG_DEBUG, " %i", s->joint_scale_factor[j][k]); | |
| 727 av_log(s->avctx, AV_LOG_DEBUG, "\n"); | |
| 728 } | |
| 729 } | |
| 730 if (s->prim_channels > 2 && s->downmix) { | |
| 731 av_log(s->avctx, AV_LOG_DEBUG, "Downmix coeffs:\n"); | |
| 732 for (j = 0; j < s->prim_channels; j++) { | |
| 733 av_log(s->avctx, AV_LOG_DEBUG, "Channel 0,%d = %f\n", j, dca_downmix_coeffs[s->downmix_coef[j][0]]); | |
| 734 av_log(s->avctx, AV_LOG_DEBUG, "Channel 1,%d = %f\n", j, dca_downmix_coeffs[s->downmix_coef[j][1]]); | |
| 735 } | |
| 736 av_log(s->avctx, AV_LOG_DEBUG, "\n"); | |
| 737 } | |
| 738 for (j = 0; j < s->prim_channels; j++) | |
| 739 for (k = s->vq_start_subband[j]; k < s->subband_activity[j]; k++) | |
| 740 av_log(s->avctx, AV_LOG_DEBUG, "VQ index: %i\n", s->high_freq_vq[j][k]); | |
| 741 if(s->lfe){ | |
| 5069 | 742 int lfe_samples = 2 * s->lfe * s->subsubframes; |
| 4599 | 743 av_log(s->avctx, AV_LOG_DEBUG, "LFE samples:\n"); |
| 744 for (j = lfe_samples; j < lfe_samples * 2; j++) | |
| 745 av_log(s->avctx, AV_LOG_DEBUG, " %f", s->lfe_data[j]); | |
| 746 av_log(s->avctx, AV_LOG_DEBUG, "\n"); | |
| 747 } | |
| 748 #endif | |
| 749 | |
| 750 return 0; | |
| 751 } | |
| 752 | |
| 753 static void qmf_32_subbands(DCAContext * s, int chans, | |
| 754 float samples_in[32][8], float *samples_out, | |
| 755 float scale, float bias) | |
| 756 { | |
|
5974
ae05d6d12f12
Use the correct "const float *" type for variable instead of casting const away.
reimar
parents:
5645
diff
changeset
|
757 const float *prCoeff; |
| 10468 | 758 int i; |
| 4599 | 759 |
|
7738
93ba37a9098c
Replace obfuscated mdct in qmf_32_subbands() by ff_imdct_half().
michael
parents:
7737
diff
changeset
|
760 int subindex; |
| 4599 | 761 |
|
7738
93ba37a9098c
Replace obfuscated mdct in qmf_32_subbands() by ff_imdct_half().
michael
parents:
7737
diff
changeset
|
762 scale *= sqrt(1/8.0); |
| 4599 | 763 |
| 764 /* Select filter */ | |
| 765 if (!s->multirate_inter) /* Non-perfect reconstruction */ | |
|
5974
ae05d6d12f12
Use the correct "const float *" type for variable instead of casting const away.
reimar
parents:
5645
diff
changeset
|
766 prCoeff = fir_32bands_nonperfect; |
| 4599 | 767 else /* Perfect reconstruction */ |
|
5974
ae05d6d12f12
Use the correct "const float *" type for variable instead of casting const away.
reimar
parents:
5645
diff
changeset
|
768 prCoeff = fir_32bands_perfect; |
| 4599 | 769 |
| 770 /* Reconstructed channel sample index */ | |
| 771 for (subindex = 0; subindex < 8; subindex++) { | |
| 772 /* Load in one sample from each subband and clear inactive subbands */ | |
|
7738
93ba37a9098c
Replace obfuscated mdct in qmf_32_subbands() by ff_imdct_half().
michael
parents:
7737
diff
changeset
|
773 for (i = 0; i < s->subband_activity[chans]; i++){ |
| 11606 | 774 uint32_t v = AV_RN32A(&samples_in[i][subindex]) ^ ((i-1)&2)<<30; |
| 775 AV_WN32A(&s->raXin[i], v); | |
|
7738
93ba37a9098c
Replace obfuscated mdct in qmf_32_subbands() by ff_imdct_half().
michael
parents:
7737
diff
changeset
|
776 } |
| 4599 | 777 for (; i < 32; i++) |
| 10152 | 778 s->raXin[i] = 0.0; |
| 4599 | 779 |
| 11592 | 780 s->synth.synth_filter_float(&s->imdct, |
| 10467 | 781 s->subband_fir_hist[chans], &s->hist_index[chans], |
| 782 s->subband_fir_noidea[chans], prCoeff, | |
| 783 samples_out, s->raXin, scale, bias); | |
|
7738
93ba37a9098c
Replace obfuscated mdct in qmf_32_subbands() by ff_imdct_half().
michael
parents:
7737
diff
changeset
|
784 samples_out+= 32; |
| 4599 | 785 |
| 786 } | |
| 787 } | |
| 788 | |
| 789 static void lfe_interpolation_fir(int decimation_select, | |
| 790 int num_deci_sample, float *samples_in, | |
| 791 float *samples_out, float scale, | |
| 792 float bias) | |
| 793 { | |
| 794 /* samples_in: An array holding decimated samples. | |
| 795 * Samples in current subframe starts from samples_in[0], | |
| 796 * while samples_in[-1], samples_in[-2], ..., stores samples | |
| 797 * from last subframe as history. | |
| 798 * | |
| 799 * samples_out: An array holding interpolated samples | |
| 800 */ | |
| 801 | |
| 802 int decifactor, k, j; | |
| 803 const float *prCoeff; | |
| 804 | |
| 805 int interp_index = 0; /* Index to the interpolated samples */ | |
| 806 int deciindex; | |
| 807 | |
| 808 /* Select decimation filter */ | |
| 809 if (decimation_select == 1) { | |
| 810 decifactor = 128; | |
| 811 prCoeff = lfe_fir_128; | |
| 812 } else { | |
| 813 decifactor = 64; | |
| 814 prCoeff = lfe_fir_64; | |
| 815 } | |
| 816 /* Interpolation */ | |
| 817 for (deciindex = 0; deciindex < num_deci_sample; deciindex++) { | |
| 818 /* One decimated sample generates decifactor interpolated ones */ | |
| 819 for (k = 0; k < decifactor; k++) { | |
| 820 float rTmp = 0.0; | |
| 821 //FIXME the coeffs are symetric, fix that | |
| 822 for (j = 0; j < 512 / decifactor; j++) | |
| 823 rTmp += samples_in[deciindex - j] * prCoeff[k + j * decifactor]; | |
|
8062
17aeecee2a97
Fix dca decoder with non simd float2int16 conversion
banan
parents:
8061
diff
changeset
|
824 samples_out[interp_index++] = (rTmp * scale) + bias; |
| 4599 | 825 } |
| 826 } | |
| 827 } | |
| 828 | |
| 829 /* downmixing routines */ | |
| 4894 | 830 #define MIX_REAR1(samples, si1, rs, coef) \ |
| 831 samples[i] += samples[si1] * coef[rs][0]; \ | |
| 832 samples[i+256] += samples[si1] * coef[rs][1]; | |
| 4599 | 833 |
| 4894 | 834 #define MIX_REAR2(samples, si1, si2, rs, coef) \ |
| 835 samples[i] += samples[si1] * coef[rs][0] + samples[si2] * coef[rs+1][0]; \ | |
| 836 samples[i+256] += samples[si1] * coef[rs][1] + samples[si2] * coef[rs+1][1]; | |
| 4599 | 837 |
| 4894 | 838 #define MIX_FRONT3(samples, coef) \ |
| 4599 | 839 t = samples[i]; \ |
| 4894 | 840 samples[i] = t * coef[0][0] + samples[i+256] * coef[1][0] + samples[i+512] * coef[2][0]; \ |
| 841 samples[i+256] = t * coef[0][1] + samples[i+256] * coef[1][1] + samples[i+512] * coef[2][1]; | |
| 4599 | 842 |
| 843 #define DOWNMIX_TO_STEREO(op1, op2) \ | |
| 844 for(i = 0; i < 256; i++){ \ | |
| 845 op1 \ | |
| 846 op2 \ | |
| 847 } | |
| 848 | |
| 4894 | 849 static void dca_downmix(float *samples, int srcfmt, |
| 850 int downmix_coef[DCA_PRIM_CHANNELS_MAX][2]) | |
| 4599 | 851 { |
| 852 int i; | |
| 853 float t; | |
| 4894 | 854 float coef[DCA_PRIM_CHANNELS_MAX][2]; |
| 855 | |
| 856 for(i=0; i<DCA_PRIM_CHANNELS_MAX; i++) { | |
| 857 coef[i][0] = dca_downmix_coeffs[downmix_coef[i][0]]; | |
| 858 coef[i][1] = dca_downmix_coeffs[downmix_coef[i][1]]; | |
| 859 } | |
| 4599 | 860 |
| 861 switch (srcfmt) { | |
| 862 case DCA_MONO: | |
| 863 case DCA_CHANNEL: | |
| 864 case DCA_STEREO_TOTAL: | |
| 865 case DCA_STEREO_SUMDIFF: | |
| 866 case DCA_4F2R: | |
| 867 av_log(NULL, 0, "Not implemented!\n"); | |
| 868 break; | |
| 869 case DCA_STEREO: | |
| 870 break; | |
| 871 case DCA_3F: | |
| 4894 | 872 DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef),); |
| 4599 | 873 break; |
| 874 case DCA_2F1R: | |
| 4894 | 875 DOWNMIX_TO_STEREO(MIX_REAR1(samples, i + 512, 2, coef),); |
| 4599 | 876 break; |
| 877 case DCA_3F1R: | |
| 4894 | 878 DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef), |
| 879 MIX_REAR1(samples, i + 768, 3, coef)); | |
| 4599 | 880 break; |
| 881 case DCA_2F2R: | |
| 4894 | 882 DOWNMIX_TO_STEREO(MIX_REAR2(samples, i + 512, i + 768, 2, coef),); |
| 4599 | 883 break; |
| 884 case DCA_3F2R: | |
| 4894 | 885 DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef), |
| 886 MIX_REAR2(samples, i + 768, i + 1024, 3, coef)); | |
| 4599 | 887 break; |
| 888 } | |
| 889 } | |
| 890 | |
| 891 | |
| 892 /* Very compact version of the block code decoder that does not use table | |
| 893 * look-up but is slightly slower */ | |
| 894 static int decode_blockcode(int code, int levels, int *values) | |
| 895 { | |
| 896 int i; | |
| 897 int offset = (levels - 1) >> 1; | |
| 898 | |
| 899 for (i = 0; i < 4; i++) { | |
| 900 values[i] = (code % levels) - offset; | |
| 901 code /= levels; | |
| 902 } | |
| 903 | |
| 904 if (code == 0) | |
| 905 return 0; | |
| 906 else { | |
| 907 av_log(NULL, AV_LOG_ERROR, "ERROR: block code look-up failed\n"); | |
| 908 return -1; | |
| 909 } | |
| 910 } | |
| 911 | |
| 912 static const uint8_t abits_sizes[7] = { 7, 10, 12, 13, 15, 17, 19 }; | |
| 913 static const uint8_t abits_levels[7] = { 3, 5, 7, 9, 13, 17, 25 }; | |
| 914 | |
| 915 static int dca_subsubframe(DCAContext * s) | |
| 916 { | |
| 917 int k, l; | |
| 918 int subsubframe = s->current_subsubframe; | |
| 919 | |
| 6214 | 920 const float *quant_step_table; |
| 4599 | 921 |
| 922 /* FIXME */ | |
| 923 float subband_samples[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][8]; | |
| 924 | |
| 925 /* | |
| 926 * Audio data | |
| 927 */ | |
| 928 | |
| 929 /* Select quantization step size table */ | |
| 8077 | 930 if (s->bit_rate_index == 0x1f) |
| 6214 | 931 quant_step_table = lossless_quant_d; |
| 4599 | 932 else |
| 6214 | 933 quant_step_table = lossy_quant_d; |
| 4599 | 934 |
| 935 for (k = 0; k < s->prim_channels; k++) { | |
| 936 for (l = 0; l < s->vq_start_subband[k]; l++) { | |
| 937 int m; | |
| 938 | |
| 939 /* Select the mid-tread linear quantizer */ | |
| 940 int abits = s->bitalloc[k][l]; | |
| 941 | |
| 942 float quant_step_size = quant_step_table[abits]; | |
| 943 float rscale; | |
| 944 | |
| 945 /* | |
| 946 * Determine quantization index code book and its type | |
| 947 */ | |
| 948 | |
| 949 /* Select quantization index code book */ | |
| 950 int sel = s->quant_index_huffman[k][abits]; | |
| 951 | |
| 952 /* | |
| 953 * Extract bits from the bit stream | |
| 954 */ | |
| 955 if(!abits){ | |
| 956 memset(subband_samples[k][l], 0, 8 * sizeof(subband_samples[0][0][0])); | |
| 957 }else if(abits >= 11 || !dca_smpl_bitalloc[abits].vlc[sel].table){ | |
| 958 if(abits <= 7){ | |
| 959 /* Block code */ | |
| 960 int block_code1, block_code2, size, levels; | |
| 961 int block[8]; | |
| 962 | |
| 963 size = abits_sizes[abits-1]; | |
| 964 levels = abits_levels[abits-1]; | |
| 965 | |
| 966 block_code1 = get_bits(&s->gb, size); | |
| 967 /* FIXME Should test return value */ | |
| 968 decode_blockcode(block_code1, levels, block); | |
| 969 block_code2 = get_bits(&s->gb, size); | |
| 970 decode_blockcode(block_code2, levels, &block[4]); | |
| 971 for (m = 0; m < 8; m++) | |
| 972 subband_samples[k][l][m] = block[m]; | |
| 973 }else{ | |
| 974 /* no coding */ | |
| 975 for (m = 0; m < 8; m++) | |
| 976 subband_samples[k][l][m] = get_sbits(&s->gb, abits - 3); | |
| 977 } | |
| 978 }else{ | |
| 979 /* Huffman coded */ | |
| 980 for (m = 0; m < 8; m++) | |
| 981 subband_samples[k][l][m] = get_bitalloc(&s->gb, &dca_smpl_bitalloc[abits], sel); | |
| 982 } | |
| 983 | |
| 984 /* Deal with transients */ | |
| 985 if (s->transition_mode[k][l] && | |
| 986 subsubframe >= s->transition_mode[k][l]) | |
| 987 rscale = quant_step_size * s->scale_factor[k][l][1]; | |
| 988 else | |
| 989 rscale = quant_step_size * s->scale_factor[k][l][0]; | |
| 990 | |
| 991 rscale *= s->scalefactor_adj[k][sel]; | |
| 992 | |
| 993 for (m = 0; m < 8; m++) | |
| 994 subband_samples[k][l][m] *= rscale; | |
| 995 | |
| 996 /* | |
| 997 * Inverse ADPCM if in prediction mode | |
| 998 */ | |
| 999 if (s->prediction_mode[k][l]) { | |
| 1000 int n; | |
| 1001 for (m = 0; m < 8; m++) { | |
| 1002 for (n = 1; n <= 4; n++) | |
| 1003 if (m >= n) | |
| 1004 subband_samples[k][l][m] += | |
| 1005 (adpcm_vb[s->prediction_vq[k][l]][n - 1] * | |
| 1006 subband_samples[k][l][m - n] / 8192); | |
| 1007 else if (s->predictor_history) | |
| 1008 subband_samples[k][l][m] += | |
| 1009 (adpcm_vb[s->prediction_vq[k][l]][n - 1] * | |
| 1010 s->subband_samples_hist[k][l][m - n + | |
| 1011 4] / 8192); | |
| 1012 } | |
| 1013 } | |
| 1014 } | |
| 1015 | |
| 1016 /* | |
| 1017 * Decode VQ encoded high frequencies | |
| 1018 */ | |
| 1019 for (l = s->vq_start_subband[k]; l < s->subband_activity[k]; l++) { | |
| 1020 /* 1 vector -> 32 samples but we only need the 8 samples | |
| 1021 * for this subsubframe. */ | |
| 1022 int m; | |
| 1023 | |
| 1024 if (!s->debug_flag & 0x01) { | |
| 1025 av_log(s->avctx, AV_LOG_DEBUG, "Stream with high frequencies VQ coding\n"); | |
| 1026 s->debug_flag |= 0x01; | |
| 1027 } | |
| 1028 | |
| 1029 for (m = 0; m < 8; m++) { | |
| 1030 subband_samples[k][l][m] = | |
| 1031 high_freq_vq[s->high_freq_vq[k][l]][subsubframe * 8 + | |
| 1032 m] | |
| 1033 * (float) s->scale_factor[k][l][0] / 16.0; | |
| 1034 } | |
| 1035 } | |
| 1036 } | |
| 1037 | |
| 1038 /* Check for DSYNC after subsubframe */ | |
| 1039 if (s->aspf || subsubframe == s->subsubframes - 1) { | |
| 1040 if (0xFFFF == get_bits(&s->gb, 16)) { /* 0xFFFF */ | |
| 1041 #ifdef TRACE | |
| 1042 av_log(s->avctx, AV_LOG_DEBUG, "Got subframe DSYNC\n"); | |
| 1043 #endif | |
| 1044 } else { | |
| 1045 av_log(s->avctx, AV_LOG_ERROR, "Didn't get subframe DSYNC\n"); | |
| 1046 } | |
| 1047 } | |
| 1048 | |
| 1049 /* Backup predictor history for adpcm */ | |
| 1050 for (k = 0; k < s->prim_channels; k++) | |
| 1051 for (l = 0; l < s->vq_start_subband[k]; l++) | |
| 1052 memcpy(s->subband_samples_hist[k][l], &subband_samples[k][l][4], | |
| 1053 4 * sizeof(subband_samples[0][0][0])); | |
| 1054 | |
| 1055 /* 32 subbands QMF */ | |
| 1056 for (k = 0; k < s->prim_channels; k++) { | |
| 1057 /* static float pcm_to_double[8] = | |
| 1058 {32768.0, 32768.0, 524288.0, 524288.0, 0, 8388608.0, 8388608.0};*/ | |
|
8148
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
1059 qmf_32_subbands(s, k, subband_samples[k], &s->samples[256 * s->channel_order_tab[k]], |
|
8062
17aeecee2a97
Fix dca decoder with non simd float2int16 conversion
banan
parents:
8061
diff
changeset
|
1060 M_SQRT1_2*s->scale_bias /*pcm_to_double[s->source_pcm_res] */ , |
|
17aeecee2a97
Fix dca decoder with non simd float2int16 conversion
banan
parents:
8061
diff
changeset
|
1061 s->add_bias ); |
| 4599 | 1062 } |
| 1063 | |
| 1064 /* Down mixing */ | |
| 1065 | |
| 1066 if (s->prim_channels > dca_channels[s->output & DCA_CHANNEL_MASK]) { | |
| 4894 | 1067 dca_downmix(s->samples, s->amode, s->downmix_coef); |
| 4599 | 1068 } |
| 1069 | |
| 1070 /* Generate LFE samples for this subsubframe FIXME!!! */ | |
| 1071 if (s->output & DCA_LFE) { | |
| 1072 int lfe_samples = 2 * s->lfe * s->subsubframes; | |
| 1073 | |
| 1074 lfe_interpolation_fir(s->lfe, 2 * s->lfe, | |
| 1075 s->lfe_data + lfe_samples + | |
| 1076 2 * s->lfe * subsubframe, | |
|
8148
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
1077 &s->samples[256 * dca_lfe_index[s->amode]], |
|
8062
17aeecee2a97
Fix dca decoder with non simd float2int16 conversion
banan
parents:
8061
diff
changeset
|
1078 (1.0/256.0)*s->scale_bias, s->add_bias); |
| 4599 | 1079 /* Outputs 20bits pcm samples */ |
| 1080 } | |
| 1081 | |
| 1082 return 0; | |
| 1083 } | |
| 1084 | |
| 1085 | |
| 1086 static int dca_subframe_footer(DCAContext * s) | |
| 1087 { | |
| 1088 int aux_data_count = 0, i; | |
| 1089 int lfe_samples; | |
| 1090 | |
| 1091 /* | |
| 1092 * Unpack optional information | |
| 1093 */ | |
| 1094 | |
| 1095 if (s->timestamp) | |
| 1096 get_bits(&s->gb, 32); | |
| 1097 | |
| 1098 if (s->aux_data) | |
| 1099 aux_data_count = get_bits(&s->gb, 6); | |
| 1100 | |
| 1101 for (i = 0; i < aux_data_count; i++) | |
| 1102 get_bits(&s->gb, 8); | |
| 1103 | |
| 1104 if (s->crc_present && (s->downmix || s->dynrange)) | |
| 1105 get_bits(&s->gb, 16); | |
| 1106 | |
| 1107 lfe_samples = 2 * s->lfe * s->subsubframes; | |
| 1108 for (i = 0; i < lfe_samples; i++) { | |
| 1109 s->lfe_data[i] = s->lfe_data[i + lfe_samples]; | |
| 1110 } | |
| 1111 | |
| 1112 return 0; | |
| 1113 } | |
| 1114 | |
| 1115 /** | |
| 1116 * Decode a dca frame block | |
| 1117 * | |
| 1118 * @param s pointer to the DCAContext | |
| 1119 */ | |
| 1120 | |
| 1121 static int dca_decode_block(DCAContext * s) | |
| 1122 { | |
| 1123 | |
| 1124 /* Sanity check */ | |
| 1125 if (s->current_subframe >= s->subframes) { | |
| 1126 av_log(s->avctx, AV_LOG_DEBUG, "check failed: %i>%i", | |
| 1127 s->current_subframe, s->subframes); | |
| 1128 return -1; | |
| 1129 } | |
| 1130 | |
| 1131 if (!s->current_subsubframe) { | |
| 1132 #ifdef TRACE | |
| 1133 av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subframe_header\n"); | |
| 1134 #endif | |
| 1135 /* Read subframe header */ | |
| 1136 if (dca_subframe_header(s)) | |
| 1137 return -1; | |
| 1138 } | |
| 1139 | |
| 1140 /* Read subsubframe */ | |
| 1141 #ifdef TRACE | |
| 1142 av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subsubframe\n"); | |
| 1143 #endif | |
| 1144 if (dca_subsubframe(s)) | |
| 1145 return -1; | |
| 1146 | |
| 1147 /* Update state */ | |
| 1148 s->current_subsubframe++; | |
| 1149 if (s->current_subsubframe >= s->subsubframes) { | |
| 1150 s->current_subsubframe = 0; | |
| 1151 s->current_subframe++; | |
| 1152 } | |
| 1153 if (s->current_subframe >= s->subframes) { | |
| 1154 #ifdef TRACE | |
| 1155 av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subframe_footer\n"); | |
| 1156 #endif | |
| 1157 /* Read subframe footer */ | |
| 1158 if (dca_subframe_footer(s)) | |
| 1159 return -1; | |
| 1160 } | |
| 1161 | |
| 1162 return 0; | |
| 1163 } | |
| 1164 | |
| 1165 /** | |
| 1166 * Convert bitstream to one representation based on sync marker | |
| 1167 */ | |
| 6214 | 1168 static int dca_convert_bitstream(const uint8_t * src, int src_size, uint8_t * dst, |
| 4599 | 1169 int max_size) |
| 1170 { | |
| 1171 uint32_t mrk; | |
| 1172 int i, tmp; | |
| 6214 | 1173 const uint16_t *ssrc = (const uint16_t *) src; |
| 1174 uint16_t *sdst = (uint16_t *) dst; | |
| 4599 | 1175 PutBitContext pb; |
| 1176 | |
| 5027 | 1177 if((unsigned)src_size > (unsigned)max_size) { |
|
8226
ee1b8c54a603
Add support for parsing and decoding DCA-HD streams.
kostya
parents:
8148
diff
changeset
|
1178 // av_log(NULL, AV_LOG_ERROR, "Input frame size larger then DCA_MAX_FRAME_SIZE!\n"); |
|
ee1b8c54a603
Add support for parsing and decoding DCA-HD streams.
kostya
parents:
8148
diff
changeset
|
1179 // return -1; |
|
ee1b8c54a603
Add support for parsing and decoding DCA-HD streams.
kostya
parents:
8148
diff
changeset
|
1180 src_size = max_size; |
| 5027 | 1181 } |
| 4883 | 1182 |
| 4599 | 1183 mrk = AV_RB32(src); |
| 1184 switch (mrk) { | |
| 1185 case DCA_MARKER_RAW_BE: | |
| 7671 | 1186 memcpy(dst, src, src_size); |
| 1187 return src_size; | |
| 4599 | 1188 case DCA_MARKER_RAW_LE: |
| 7671 | 1189 for (i = 0; i < (src_size + 1) >> 1; i++) |
| 4599 | 1190 *sdst++ = bswap_16(*ssrc++); |
| 7671 | 1191 return src_size; |
| 4599 | 1192 case DCA_MARKER_14B_BE: |
| 1193 case DCA_MARKER_14B_LE: | |
| 1194 init_put_bits(&pb, dst, max_size); | |
| 1195 for (i = 0; i < (src_size + 1) >> 1; i++, src += 2) { | |
| 1196 tmp = ((mrk == DCA_MARKER_14B_BE) ? AV_RB16(src) : AV_RL16(src)) & 0x3FFF; | |
| 1197 put_bits(&pb, 14, tmp); | |
| 1198 } | |
| 1199 flush_put_bits(&pb); | |
| 1200 return (put_bits_count(&pb) + 7) >> 3; | |
| 1201 default: | |
| 1202 return -1; | |
| 1203 } | |
| 1204 } | |
| 1205 | |
| 1206 /** | |
| 1207 * Main frame decoding function | |
| 1208 * FIXME add arguments | |
| 1209 */ | |
| 1210 static int dca_decode_frame(AVCodecContext * avctx, | |
| 1211 void *data, int *data_size, | |
|
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
1212 AVPacket *avpkt) |
| 4599 | 1213 { |
|
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
1214 const uint8_t *buf = avpkt->data; |
|
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
1215 int buf_size = avpkt->size; |
| 4599 | 1216 |
|
7724
ea9aa2aa4caa
dca: Do float -> int16 interleaving in-place using s->dsp.float_to_int16_interleave()
andoma
parents:
7680
diff
changeset
|
1217 int i; |
| 4599 | 1218 int16_t *samples = data; |
| 1219 DCAContext *s = avctx->priv_data; | |
| 1220 int channels; | |
| 1221 | |
| 1222 | |
| 1223 s->dca_buffer_size = dca_convert_bitstream(buf, buf_size, s->dca_buffer, DCA_MAX_FRAME_SIZE); | |
| 1224 if (s->dca_buffer_size == -1) { | |
| 5027 | 1225 av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\n"); |
| 4599 | 1226 return -1; |
| 1227 } | |
| 1228 | |
| 1229 init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8); | |
| 1230 if (dca_parse_frame_header(s) < 0) { | |
| 1231 //seems like the frame is corrupt, try with the next one | |
| 5645 | 1232 *data_size=0; |
| 4599 | 1233 return buf_size; |
| 1234 } | |
| 1235 //set AVCodec values with parsed data | |
| 1236 avctx->sample_rate = s->sample_rate; | |
| 1237 avctx->bit_rate = s->bit_rate; | |
| 1238 | |
| 4893 | 1239 channels = s->prim_channels + !!s->lfe; |
|
8148
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
1240 |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
1241 if (s->amode<16) { |
| 8100 | 1242 avctx->channel_layout = dca_core_channel_layout[s->amode]; |
| 1243 | |
|
8148
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
1244 if (s->lfe) { |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
1245 avctx->channel_layout |= CH_LOW_FREQUENCY; |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
1246 s->channel_order_tab = dca_channel_reorder_lfe[s->amode]; |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
1247 } else |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
1248 s->channel_order_tab = dca_channel_reorder_nolfe[s->amode]; |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
1249 |
|
11304
3ef04d1190f0
Fixed a segfault in the DCA decoder with corrupted streams.
fenrir
parents:
10961
diff
changeset
|
1250 if (s->prim_channels > 0 && |
|
3ef04d1190f0
Fixed a segfault in the DCA decoder with corrupted streams.
fenrir
parents:
10961
diff
changeset
|
1251 s->channel_order_tab[s->prim_channels - 1] < 0) |
|
3ef04d1190f0
Fixed a segfault in the DCA decoder with corrupted streams.
fenrir
parents:
10961
diff
changeset
|
1252 return -1; |
|
3ef04d1190f0
Fixed a segfault in the DCA decoder with corrupted streams.
fenrir
parents:
10961
diff
changeset
|
1253 |
|
8148
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
1254 if(avctx->request_channels == 2 && s->prim_channels > 2) { |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
1255 channels = 2; |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
1256 s->output = DCA_STEREO; |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
1257 avctx->channel_layout = CH_LAYOUT_STEREO; |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
1258 } |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
1259 } else { |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
1260 av_log(avctx, AV_LOG_ERROR, "Non standard configuration %d !\n",s->amode); |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
1261 return -1; |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
1262 } |
|
146ac82af1e5
Proper channel output reordering for the dca decoder.
banan
parents:
8126
diff
changeset
|
1263 |
| 4893 | 1264 |
|
6577
1b90003d4d60
Only set channels in the stream if previously unset, fixes resampling crash on broken dca frames
banan
parents:
6517
diff
changeset
|
1265 /* There is nothing that prevents a dts frame to change channel configuration |
|
1b90003d4d60
Only set channels in the stream if previously unset, fixes resampling crash on broken dca frames
banan
parents:
6517
diff
changeset
|
1266 but FFmpeg doesn't support that so only set the channels if it is previously |
|
1b90003d4d60
Only set channels in the stream if previously unset, fixes resampling crash on broken dca frames
banan
parents:
6517
diff
changeset
|
1267 unset. Ideally during the first probe for channels the crc should be checked |
|
1b90003d4d60
Only set channels in the stream if previously unset, fixes resampling crash on broken dca frames
banan
parents:
6517
diff
changeset
|
1268 and only set avctx->channels when the crc is ok. Right now the decoder could |
|
1b90003d4d60
Only set channels in the stream if previously unset, fixes resampling crash on broken dca frames
banan
parents:
6517
diff
changeset
|
1269 set the channels based on a broken first frame.*/ |
|
1b90003d4d60
Only set channels in the stream if previously unset, fixes resampling crash on broken dca frames
banan
parents:
6517
diff
changeset
|
1270 if (!avctx->channels) |
|
1b90003d4d60
Only set channels in the stream if previously unset, fixes resampling crash on broken dca frames
banan
parents:
6517
diff
changeset
|
1271 avctx->channels = channels; |
|
1b90003d4d60
Only set channels in the stream if previously unset, fixes resampling crash on broken dca frames
banan
parents:
6517
diff
changeset
|
1272 |
| 4599 | 1273 if(*data_size < (s->sample_blocks / 8) * 256 * sizeof(int16_t) * channels) |
| 1274 return -1; | |
| 7725 | 1275 *data_size = 256 / 8 * s->sample_blocks * sizeof(int16_t) * channels; |
| 4599 | 1276 for (i = 0; i < (s->sample_blocks / 8); i++) { |
| 1277 dca_decode_block(s); | |
|
7724
ea9aa2aa4caa
dca: Do float -> int16 interleaving in-place using s->dsp.float_to_int16_interleave()
andoma
parents:
7680
diff
changeset
|
1278 s->dsp.float_to_int16_interleave(samples, s->samples_chanptr, 256, channels); |
|
ea9aa2aa4caa
dca: Do float -> int16 interleaving in-place using s->dsp.float_to_int16_interleave()
andoma
parents:
7680
diff
changeset
|
1279 samples += 256 * channels; |
| 4599 | 1280 } |
| 1281 | |
| 1282 return buf_size; | |
| 1283 } | |
| 1284 | |
| 1285 | |
| 1286 | |
| 1287 /** | |
| 1288 * DCA initialization | |
| 1289 * | |
| 1290 * @param avctx pointer to the AVCodecContext | |
| 1291 */ | |
| 1292 | |
|
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
6463
diff
changeset
|
1293 static av_cold int dca_decode_init(AVCodecContext * avctx) |
| 4599 | 1294 { |
| 1295 DCAContext *s = avctx->priv_data; | |
|
7724
ea9aa2aa4caa
dca: Do float -> int16 interleaving in-place using s->dsp.float_to_int16_interleave()
andoma
parents:
7680
diff
changeset
|
1296 int i; |
| 4599 | 1297 |
| 1298 s->avctx = avctx; | |
| 1299 dca_init_vlcs(); | |
| 1300 | |
| 1301 dsputil_init(&s->dsp, avctx); | |
|
9658
67a20f0eb42c
Support for getting (i)MDCT output multiplied by a constant scaling factor.
serge
parents:
9526
diff
changeset
|
1302 ff_mdct_init(&s->imdct, 6, 1, 1.0); |
| 11592 | 1303 ff_synth_filter_init(&s->synth); |
| 6120 | 1304 |
|
7724
ea9aa2aa4caa
dca: Do float -> int16 interleaving in-place using s->dsp.float_to_int16_interleave()
andoma
parents:
7680
diff
changeset
|
1305 for(i = 0; i < 6; i++) |
|
ea9aa2aa4caa
dca: Do float -> int16 interleaving in-place using s->dsp.float_to_int16_interleave()
andoma
parents:
7680
diff
changeset
|
1306 s->samples_chanptr[i] = s->samples + i * 256; |
|
7451
85ab7655ad4d
Modify all codecs to report their supported input and output sample format(s).
pross
parents:
7040
diff
changeset
|
1307 avctx->sample_fmt = SAMPLE_FMT_S16; |
|
8062
17aeecee2a97
Fix dca decoder with non simd float2int16 conversion
banan
parents:
8061
diff
changeset
|
1308 |
|
10377
98816e4d5522
dca and aac decoders use float_to_int16_interleave, so check for
conrad
parents:
10199
diff
changeset
|
1309 if(s->dsp.float_to_int16_interleave == ff_float_to_int16_interleave_c) { |
|
8062
17aeecee2a97
Fix dca decoder with non simd float2int16 conversion
banan
parents:
8061
diff
changeset
|
1310 s->add_bias = 385.0f; |
|
17aeecee2a97
Fix dca decoder with non simd float2int16 conversion
banan
parents:
8061
diff
changeset
|
1311 s->scale_bias = 1.0 / 32768.0; |
|
17aeecee2a97
Fix dca decoder with non simd float2int16 conversion
banan
parents:
8061
diff
changeset
|
1312 } else { |
|
17aeecee2a97
Fix dca decoder with non simd float2int16 conversion
banan
parents:
8061
diff
changeset
|
1313 s->add_bias = 0.0f; |
|
17aeecee2a97
Fix dca decoder with non simd float2int16 conversion
banan
parents:
8061
diff
changeset
|
1314 s->scale_bias = 1.0; |
|
8063
6bc70b15451d
Disable codec downmix when not using simd instead of silently produce silence
banan
parents:
8062
diff
changeset
|
1315 |
|
6bc70b15451d
Disable codec downmix when not using simd instead of silently produce silence
banan
parents:
8062
diff
changeset
|
1316 /* allow downmixing to stereo */ |
|
6bc70b15451d
Disable codec downmix when not using simd instead of silently produce silence
banan
parents:
8062
diff
changeset
|
1317 if (avctx->channels > 0 && avctx->request_channels < avctx->channels && |
|
6bc70b15451d
Disable codec downmix when not using simd instead of silently produce silence
banan
parents:
8062
diff
changeset
|
1318 avctx->request_channels == 2) { |
|
6bc70b15451d
Disable codec downmix when not using simd instead of silently produce silence
banan
parents:
8062
diff
changeset
|
1319 avctx->channels = avctx->request_channels; |
|
6bc70b15451d
Disable codec downmix when not using simd instead of silently produce silence
banan
parents:
8062
diff
changeset
|
1320 } |
|
8062
17aeecee2a97
Fix dca decoder with non simd float2int16 conversion
banan
parents:
8061
diff
changeset
|
1321 } |
|
17aeecee2a97
Fix dca decoder with non simd float2int16 conversion
banan
parents:
8061
diff
changeset
|
1322 |
|
17aeecee2a97
Fix dca decoder with non simd float2int16 conversion
banan
parents:
8061
diff
changeset
|
1323 |
| 4599 | 1324 return 0; |
| 1325 } | |
| 1326 | |
|
7738
93ba37a9098c
Replace obfuscated mdct in qmf_32_subbands() by ff_imdct_half().
michael
parents:
7737
diff
changeset
|
1327 static av_cold int dca_decode_end(AVCodecContext * avctx) |
|
93ba37a9098c
Replace obfuscated mdct in qmf_32_subbands() by ff_imdct_half().
michael
parents:
7737
diff
changeset
|
1328 { |
|
93ba37a9098c
Replace obfuscated mdct in qmf_32_subbands() by ff_imdct_half().
michael
parents:
7737
diff
changeset
|
1329 DCAContext *s = avctx->priv_data; |
|
93ba37a9098c
Replace obfuscated mdct in qmf_32_subbands() by ff_imdct_half().
michael
parents:
7737
diff
changeset
|
1330 ff_mdct_end(&s->imdct); |
|
93ba37a9098c
Replace obfuscated mdct in qmf_32_subbands() by ff_imdct_half().
michael
parents:
7737
diff
changeset
|
1331 return 0; |
|
93ba37a9098c
Replace obfuscated mdct in qmf_32_subbands() by ff_imdct_half().
michael
parents:
7737
diff
changeset
|
1332 } |
| 4599 | 1333 |
| 1334 AVCodec dca_decoder = { | |
| 1335 .name = "dca", | |
|
11560
8a4984c5cacc
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
11370
diff
changeset
|
1336 .type = AVMEDIA_TYPE_AUDIO, |
| 4599 | 1337 .id = CODEC_ID_DTS, |
| 1338 .priv_data_size = sizeof(DCAContext), | |
| 1339 .init = dca_decode_init, | |
| 1340 .decode = dca_decode_frame, | |
|
7738
93ba37a9098c
Replace obfuscated mdct in qmf_32_subbands() by ff_imdct_half().
michael
parents:
7737
diff
changeset
|
1341 .close = dca_decode_end, |
|
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6710
diff
changeset
|
1342 .long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"), |
| 4599 | 1343 }; |
