annotate ps.c @ 11886:2d81202be6e2 libavcodec

Add HE-AAC v2 support to the AAC decoder.
author alexc
date Sat, 19 Jun 2010 14:14:51 +0000
parents
children c432b63b345e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11886
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1 /*
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
2 * MPEG-4 Parametric Stereo decoding functions
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
3 * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
4 *
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
5 * This file is part of FFmpeg.
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
6 *
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
11 *
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
15 * Lesser General Public License for more details.
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
16 *
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
20 */
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
21
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
22 #include <stdint.h>
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
23 #include "libavutil/mathematics.h"
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
24 #include "avcodec.h"
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
25 #include "get_bits.h"
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
26 #include "ps.h"
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
27 #include "ps_tablegen.h"
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
28 #include "psdata.c"
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
29
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
30 #define PS_BASELINE 0
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
31
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
32 #define numQMFSlots 32 //numTimeSlots * RATE
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
33
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
34 static const int8_t num_env_tab[2][4] = {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
35 { 0, 1, 2, 4, },
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
36 { 1, 2, 3, 4, },
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
37 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
38
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
39 static const int8_t nr_iidicc_par_tab[] = {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
40 10, 20, 34, 10, 20, 34,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
41 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
42
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
43 static const int8_t nr_iidopd_par_tab[] = {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
44 5, 11, 17, 5, 11, 17,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
45 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
46
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
47 enum {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
48 huff_iid_df1,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
49 huff_iid_dt1,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
50 huff_iid_df0,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
51 huff_iid_dt0,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
52 huff_icc_df,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
53 huff_icc_dt,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
54 huff_ipd_df,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
55 huff_ipd_dt,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
56 huff_opd_df,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
57 huff_opd_dt,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
58 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
59
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
60 static const int huff_iid[] = {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
61 huff_iid_df0,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
62 huff_iid_df1,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
63 huff_iid_dt0,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
64 huff_iid_dt1,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
65 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
66
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
67 static VLC vlc_ps[10];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
68
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
69 /**
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
70 * Read Inter-channel Intensity Difference parameters from the bitstream.
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
71 *
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
72 * @param avctx contains the current codec context
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
73 * @param gb pointer to the input bitstream
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
74 * @param ps pointer to the Parametric Stereo context
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
75 * @param e envelope to decode
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
76 * @param dt 1: time delta-coded, 0: frequency delta-coded
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
77 */
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
78 static int iid_data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, int e, int dt)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
79 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
80 int b;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
81 int table_idx = huff_iid[2*dt+ps->iid_quant];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
82 VLC_TYPE (*vlc_table)[2] = vlc_ps[table_idx].table;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
83 if (dt) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
84 int e_prev = e ? e - 1 : ps->num_env_old - 1;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
85 e_prev = FFMAX(e_prev, 0);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
86 for (b = 0; b < ps->nr_iid_par; b++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
87 ps->iid_par[e][b] = ps->iid_par[e_prev][b] +
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
88 get_vlc2(gb, vlc_table, 9, 3) -
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
89 huff_offset[table_idx];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
90 if (FFABS(ps->iid_par[e][b]) > 7 + 8 * ps->iid_quant)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
91 goto err;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
92 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
93 } else {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
94 int prev = 0;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
95 for (b = 0; b < ps->nr_iid_par; b++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
96 prev += get_vlc2(gb, vlc_table, 9, 3) -
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
97 huff_offset[table_idx];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
98 ps->iid_par[e][b] = prev;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
99 if (FFABS(ps->iid_par[e][b]) > 7 + 8 * ps->iid_quant)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
100 goto err;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
101 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
102 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
103 return 0;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
104 err:
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
105 av_log(avctx, AV_LOG_ERROR, "illegal iid\n");
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
106 return -1;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
107 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
108
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
109 /**
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
110 * Read Inter-Channel Coherence parameters from the bitstream.
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
111 *
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
112 * @param avctx contains the current codec context
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
113 * @param gb pointer to the input bitstream
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
114 * @param ps pointer to the Parametric Stereo context
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
115 * @param e envelope to decode
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
116 * @param dt 1: time delta-coded, 0: frequency delta-coded
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
117 */
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
118 static int icc_data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, int e, int dt)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
119 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
120 int b;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
121 int table_idx = dt ? huff_icc_dt : huff_icc_df;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
122 VLC_TYPE (*vlc_table)[2] = vlc_ps[table_idx].table;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
123 if (dt) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
124 int e_prev = e ? e - 1 : ps->num_env_old - 1;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
125 e_prev = FFMAX(e_prev, 0);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
126 for (b = 0; b < ps->nr_icc_par; b++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
127 ps->icc_par[e][b] = ps->icc_par[e_prev][b] + get_vlc2(gb, vlc_table, 9, 3) - huff_offset[table_idx];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
128 if (ps->icc_par[e][b] > 7U)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
129 goto err;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
130 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
131 } else {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
132 int prev = 0;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
133 for (b = 0; b < ps->nr_icc_par; b++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
134 prev += get_vlc2(gb, vlc_table, 9, 3) - huff_offset[table_idx];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
135 ps->icc_par[e][b] = prev;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
136 if (ps->icc_par[e][b] > 7U)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
137 goto err;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
138 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
139 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
140 return 0;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
141 err:
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
142 av_log(avctx, AV_LOG_ERROR, "illegal icc\n");
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
143 return -1;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
144 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
145
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
146 /**
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
147 * Read Inter-channel Phase Difference parameters from the bitstream.
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
148 *
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
149 * @param gb pointer to the input bitstream
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
150 * @param ps pointer to the Parametric Stereo context
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
151 * @param e envelope to decode
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
152 * @param dt 1: time delta-coded, 0: frequency delta-coded
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
153 */
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
154 static void ipd_data(GetBitContext *gb, PSContext *ps, int e, int dt)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
155 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
156 int b;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
157 int table_idx = dt ? huff_ipd_dt : huff_ipd_df;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
158 VLC_TYPE (*vlc_table)[2] = vlc_ps[table_idx].table;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
159 if (dt) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
160 int e_prev = e ? e - 1 : ps->num_env_old - 1;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
161 e_prev = FFMAX(e_prev, 0);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
162 for (b = 0; b < ps->nr_ipdopd_par; b++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
163 ps->ipd_par[e][b] = (ps->ipd_par[e_prev][b] + get_vlc2(gb, vlc_table, 9, 1)) & 0x07;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
164 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
165 } else {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
166 int prev = 0;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
167 for (b = 0; b < ps->nr_ipdopd_par; b++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
168 prev += get_vlc2(gb, vlc_table, 9, 3);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
169 prev &= 0x07;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
170 ps->ipd_par[e][b] = prev;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
171 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
172 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
173 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
174
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
175 /**
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
176 * Read Overall Phase Difference parameters from the bitstream.
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
177 *
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
178 * @param gb pointer to the input bitstream
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
179 * @param ps pointer to the Parametric Stereo context
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
180 * @param e envelope to decode
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
181 * @param dt 1: time delta-coded, 0: frequency delta-coded
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
182 */
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
183 static void opd_data(GetBitContext *gb, PSContext *ps, int e, int dt)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
184 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
185 int b;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
186 int table_idx = dt ? huff_opd_dt : huff_opd_df;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
187 VLC_TYPE (*vlc_table)[2] = vlc_ps[table_idx].table;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
188 if (dt) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
189 int e_prev = e ? e - 1 : ps->num_env_old - 1;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
190 e_prev = FFMAX(e_prev, 0);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
191 for (b = 0; b < ps->nr_ipdopd_par; b++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
192 ps->opd_par[e][b] = (ps->opd_par[e_prev][b] + get_vlc2(gb, vlc_table, 9, 1)) & 0x07;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
193 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
194 } else {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
195 int prev = 0;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
196 for (b = 0; b < ps->nr_ipdopd_par; b++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
197 prev += get_vlc2(gb, vlc_table, 9, 3);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
198 prev &= 0x07;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
199 ps->opd_par[e][b] = prev;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
200 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
201 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
202 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
203
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
204 static int ps_extension(GetBitContext *gb, PSContext *ps, int ps_extension_id)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
205 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
206 int e;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
207 int count = get_bits_count(gb);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
208
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
209 if (ps_extension_id)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
210 return 0;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
211
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
212 ps->enable_ipdopd = get_bits1(gb);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
213 if (ps->enable_ipdopd) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
214 for (e = 0; e < ps->num_env; e++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
215 int dt = get_bits1(gb);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
216 ipd_data(gb, ps, e, dt);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
217 dt = get_bits1(gb);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
218 opd_data(gb, ps, e, dt);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
219 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
220 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
221 skip_bits1(gb); //reserved_ps
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
222 return get_bits_count(gb) - count;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
223 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
224
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
225 static void ipdopd_reset(int8_t *opd_hist, int8_t *ipd_hist)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
226 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
227 int i;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
228 for (i = 0; i < PS_MAX_NR_IPDOPD; i++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
229 opd_hist[i] = 0;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
230 ipd_hist[i] = 0;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
231 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
232 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
233
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
234 int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps, int bits_left)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
235 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
236 int e;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
237 int bit_count_start = get_bits_count(gb_host);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
238 int header;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
239 int bits_consumed;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
240 GetBitContext gbc = *gb_host, *gb = &gbc;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
241
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
242 header = get_bits1(gb);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
243 if (header) { //enable_ps_header
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
244 ps->enable_iid = get_bits1(gb);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
245 if (ps->enable_iid) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
246 ps->iid_mode = get_bits(gb, 3);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
247 if (ps->iid_mode > 5) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
248 av_log(avctx, AV_LOG_ERROR, "iid_mode %d is reserved.\n",
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
249 ps->iid_mode);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
250 goto err;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
251 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
252 ps->nr_iid_par = nr_iidicc_par_tab[ps->iid_mode];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
253 ps->iid_quant = ps->iid_mode > 2;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
254 ps->nr_ipdopd_par = nr_iidopd_par_tab[ps->iid_mode];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
255 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
256 ps->enable_icc = get_bits1(gb);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
257 if (ps->enable_icc) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
258 ps->icc_mode = get_bits(gb, 3);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
259 if (ps->icc_mode > 5) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
260 av_log(avctx, AV_LOG_ERROR, "icc_mode %d is reserved.\n",
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
261 ps->icc_mode);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
262 goto err;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
263 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
264 ps->nr_icc_par = nr_iidicc_par_tab[ps->icc_mode];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
265 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
266 ps->enable_ext = get_bits1(gb);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
267 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
268
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
269 ps->frame_class = get_bits1(gb);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
270 ps->num_env_old = ps->num_env;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
271 ps->num_env = num_env_tab[ps->frame_class][get_bits(gb, 2)];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
272
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
273 ps->border_position[0] = -1;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
274 if (ps->frame_class) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
275 for (e = 1; e <= ps->num_env; e++)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
276 ps->border_position[e] = get_bits(gb, 5);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
277 } else
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
278 for (e = 1; e <= ps->num_env; e++)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
279 ps->border_position[e] = e * numQMFSlots / ps->num_env - 1;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
280
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
281 if (ps->enable_iid) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
282 for (e = 0; e < ps->num_env; e++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
283 int dt = get_bits1(gb);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
284 if (iid_data(avctx, gb, ps, e, dt))
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
285 goto err;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
286 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
287 } else
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
288 memset(ps->iid_par, 0, sizeof(ps->iid_par));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
289
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
290 if (ps->enable_icc)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
291 for (e = 0; e < ps->num_env; e++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
292 int dt = get_bits1(gb);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
293 if (icc_data(avctx, gb, ps, e, dt))
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
294 goto err;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
295 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
296 else
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
297 memset(ps->icc_par, 0, sizeof(ps->icc_par));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
298
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
299 if (ps->enable_ext) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
300 int cnt = get_bits(gb, 4);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
301 if (cnt == 15) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
302 cnt += get_bits(gb, 8);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
303 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
304 cnt *= 8;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
305 while (cnt > 7) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
306 int ps_extension_id = get_bits(gb, 2);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
307 cnt -= 2 + ps_extension(gb, ps, ps_extension_id);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
308 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
309 if (cnt < 0) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
310 av_log(avctx, AV_LOG_ERROR, "ps extension overflow %d", cnt);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
311 goto err;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
312 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
313 skip_bits(gb, cnt);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
314 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
315
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
316 ps->enable_ipdopd &= !PS_BASELINE;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
317
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
318 //Fix up envelopes
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
319 if (!ps->num_env || ps->border_position[ps->num_env] < numQMFSlots - 1) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
320 //Create a fake envelope
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
321 int source = ps->num_env ? ps->num_env - 1 : ps->num_env_old - 1;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
322 if (source >= 0 && source != ps->num_env) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
323 if (ps->enable_iid && ps->num_env_old > 1) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
324 memcpy(ps->iid_par+ps->num_env, ps->iid_par+source, sizeof(ps->iid_par[0]));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
325 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
326 if (ps->enable_icc && ps->num_env_old > 1) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
327 memcpy(ps->icc_par+ps->num_env, ps->icc_par+source, sizeof(ps->icc_par[0]));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
328 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
329 if (ps->enable_ipdopd && ps->num_env_old > 1) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
330 memcpy(ps->ipd_par+ps->num_env, ps->ipd_par+source, sizeof(ps->ipd_par[0]));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
331 memcpy(ps->opd_par+ps->num_env, ps->opd_par+source, sizeof(ps->opd_par[0]));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
332 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
333 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
334 ps->num_env++;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
335 ps->border_position[ps->num_env] = numQMFSlots - 1;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
336 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
337
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
338
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
339 ps->is34bands_old = ps->is34bands;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
340 if (!PS_BASELINE && (ps->enable_iid || ps->enable_icc))
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
341 ps->is34bands = (ps->enable_iid && ps->nr_iid_par == 34) ||
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
342 (ps->enable_icc && ps->nr_icc_par == 34);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
343
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
344 //Baseline
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
345 if (!ps->enable_ipdopd) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
346 memset(ps->ipd_par, 0, sizeof(ps->ipd_par));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
347 memset(ps->opd_par, 0, sizeof(ps->opd_par));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
348 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
349
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
350 if (header)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
351 ps->start = 1;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
352
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
353 bits_consumed = get_bits_count(gb) - bit_count_start;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
354 if (bits_consumed <= bits_left) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
355 skip_bits_long(gb_host, bits_consumed);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
356 return bits_consumed;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
357 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
358 av_log(avctx, AV_LOG_ERROR, "Expected to read %d PS bits actually read %d.\n", bits_left, bits_consumed);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
359 err:
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
360 ps->start = 0;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
361 skip_bits_long(gb_host, bits_left);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
362 return bits_left;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
363 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
364
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
365 /** Split one subband into 2 subsubbands with a symmetric real filter.
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
366 * The filter must have its non-center even coefficients equal to zero. */
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
367 static void hybrid2_re(float (*in)[2], float (*out)[32][2], const float filter[7], int len, int reverse)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
368 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
369 int i, j;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
370 for (i = 0; i < len; i++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
371 float re_in = filter[6] * in[6+i][0]; //real inphase
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
372 float re_op = 0.0f; //real out of phase
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
373 float im_in = filter[6] * in[6+i][1]; //imag inphase
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
374 float im_op = 0.0f; //imag out of phase
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
375 for (j = 0; j < 6; j += 2) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
376 re_op += filter[j+1] * (in[i+j+1][0] + in[12-j-1+i][0]);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
377 im_op += filter[j+1] * (in[i+j+1][1] + in[12-j-1+i][1]);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
378 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
379 out[ reverse][i][0] = re_in + re_op;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
380 out[ reverse][i][1] = im_in + im_op;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
381 out[!reverse][i][0] = re_in - re_op;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
382 out[!reverse][i][1] = im_in - im_op;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
383 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
384 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
385
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
386 /** Split one subband into 6 subsubbands with a complex filter */
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
387 static void hybrid6_cx(float (*in)[2], float (*out)[32][2], const float (*filter)[7][2], int len)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
388 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
389 int i, j, ssb;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
390 int N = 8;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
391 float temp[8][2];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
392
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
393 for (i = 0; i < len; i++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
394 for (ssb = 0; ssb < N; ssb++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
395 float sum_re = filter[ssb][6][0] * in[i+6][0], sum_im = filter[ssb][6][0] * in[i+6][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
396 for (j = 0; j < 6; j++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
397 float in0_re = in[i+j][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
398 float in0_im = in[i+j][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
399 float in1_re = in[i+12-j][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
400 float in1_im = in[i+12-j][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
401 sum_re += filter[ssb][j][0] * (in0_re + in1_re) - filter[ssb][j][1] * (in0_im - in1_im);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
402 sum_im += filter[ssb][j][0] * (in0_im + in1_im) + filter[ssb][j][1] * (in0_re - in1_re);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
403 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
404 temp[ssb][0] = sum_re;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
405 temp[ssb][1] = sum_im;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
406 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
407 out[0][i][0] = temp[6][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
408 out[0][i][1] = temp[6][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
409 out[1][i][0] = temp[7][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
410 out[1][i][1] = temp[7][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
411 out[2][i][0] = temp[0][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
412 out[2][i][1] = temp[0][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
413 out[3][i][0] = temp[1][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
414 out[3][i][1] = temp[1][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
415 out[4][i][0] = temp[2][0] + temp[5][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
416 out[4][i][1] = temp[2][1] + temp[5][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
417 out[5][i][0] = temp[3][0] + temp[4][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
418 out[5][i][1] = temp[3][1] + temp[4][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
419 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
420 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
421
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
422 static void hybrid4_8_12_cx(float (*in)[2], float (*out)[32][2], const float (*filter)[7][2], int N, int len)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
423 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
424 int i, j, ssb;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
425
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
426 for (i = 0; i < len; i++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
427 for (ssb = 0; ssb < N; ssb++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
428 float sum_re = filter[ssb][6][0] * in[i+6][0], sum_im = filter[ssb][6][0] * in[i+6][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
429 for (j = 0; j < 6; j++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
430 float in0_re = in[i+j][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
431 float in0_im = in[i+j][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
432 float in1_re = in[i+12-j][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
433 float in1_im = in[i+12-j][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
434 sum_re += filter[ssb][j][0] * (in0_re + in1_re) - filter[ssb][j][1] * (in0_im - in1_im);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
435 sum_im += filter[ssb][j][0] * (in0_im + in1_im) + filter[ssb][j][1] * (in0_re - in1_re);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
436 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
437 out[ssb][i][0] = sum_re;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
438 out[ssb][i][1] = sum_im;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
439 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
440 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
441 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
442
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
443 static void hybrid_analysis(float out[91][32][2], float in[5][44][2], float L[2][38][64], int is34, int len)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
444 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
445 int i, j;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
446 for (i = 0; i < 5; i++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
447 for (j = 0; j < 38; j++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
448 in[i][j+6][0] = L[0][j][i];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
449 in[i][j+6][1] = L[1][j][i];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
450 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
451 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
452 if(is34) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
453 hybrid4_8_12_cx(in[0], out, f34_0_12, 12, len);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
454 hybrid4_8_12_cx(in[1], out+12, f34_1_8, 8, len);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
455 hybrid4_8_12_cx(in[2], out+20, f34_2_4, 4, len);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
456 hybrid4_8_12_cx(in[3], out+24, f34_2_4, 4, len);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
457 hybrid4_8_12_cx(in[4], out+28, f34_2_4, 4, len);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
458 for (i = 0; i < 59; i++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
459 for (j = 0; j < len; j++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
460 out[i+32][j][0] = L[0][j][i+5];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
461 out[i+32][j][1] = L[1][j][i+5];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
462 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
463 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
464 } else {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
465 hybrid6_cx(in[0], out, f20_0_8, len);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
466 hybrid2_re(in[1], out+6, g1_Q2, len, 1);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
467 hybrid2_re(in[2], out+8, g1_Q2, len, 0);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
468 for (i = 0; i < 61; i++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
469 for (j = 0; j < len; j++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
470 out[i+10][j][0] = L[0][j][i+3];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
471 out[i+10][j][1] = L[1][j][i+3];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
472 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
473 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
474 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
475 //update in_buf
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
476 for (i = 0; i < 5; i++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
477 memcpy(in[i], in[i]+32, 6 * sizeof(in[i][0]));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
478 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
479 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
480
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
481 static void hybrid_synthesis(float out[2][38][64], float in[91][32][2], int is34, int len)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
482 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
483 int i, n;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
484 if(is34) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
485 for (n = 0; n < len; n++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
486 memset(out[0][n], 0, 5*sizeof(out[0][n][0]));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
487 memset(out[1][n], 0, 5*sizeof(out[1][n][0]));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
488 for(i = 0; i < 12; i++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
489 out[0][n][0] += in[ i][n][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
490 out[1][n][0] += in[ i][n][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
491 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
492 for(i = 0; i < 8; i++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
493 out[0][n][1] += in[12+i][n][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
494 out[1][n][1] += in[12+i][n][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
495 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
496 for(i = 0; i < 4; i++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
497 out[0][n][2] += in[20+i][n][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
498 out[1][n][2] += in[20+i][n][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
499 out[0][n][3] += in[24+i][n][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
500 out[1][n][3] += in[24+i][n][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
501 out[0][n][4] += in[28+i][n][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
502 out[1][n][4] += in[28+i][n][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
503 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
504 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
505 for (i = 0; i < 59; i++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
506 for (n = 0; n < len; n++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
507 out[0][n][i+5] = in[i+32][n][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
508 out[1][n][i+5] = in[i+32][n][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
509 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
510 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
511 } else {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
512 for (n = 0; n < len; n++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
513 out[0][n][0] = in[0][n][0] + in[1][n][0] + in[2][n][0] +
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
514 in[3][n][0] + in[4][n][0] + in[5][n][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
515 out[1][n][0] = in[0][n][1] + in[1][n][1] + in[2][n][1] +
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
516 in[3][n][1] + in[4][n][1] + in[5][n][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
517 out[0][n][1] = in[6][n][0] + in[7][n][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
518 out[1][n][1] = in[6][n][1] + in[7][n][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
519 out[0][n][2] = in[8][n][0] + in[9][n][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
520 out[1][n][2] = in[8][n][1] + in[9][n][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
521 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
522 for (i = 0; i < 61; i++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
523 for (n = 0; n < len; n++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
524 out[0][n][i+3] = in[i+10][n][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
525 out[1][n][i+3] = in[i+10][n][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
526 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
527 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
528 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
529 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
530
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
531 /// All-pass filter decay slope
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
532 #define DECAY_SLOPE 0.05f
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
533 /// Number of frequency bands that can be addressed by the parameter index, b(k)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
534 static const int NR_PAR_BANDS[] = { 20, 34 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
535 /// Number of frequency bands that can be addressed by the sub subband index, k
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
536 static const int NR_BANDS[] = { 71, 91 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
537 /// Start frequency band for the all-pass filter decay slope
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
538 static const int DECAY_CUTOFF[] = { 10, 32 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
539 /// Number of all-pass filer bands
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
540 static const int NR_ALLPASS_BANDS[] = { 30, 50 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
541 /// First stereo band using the short one sample delay
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
542 static const int SHORT_DELAY_BAND[] = { 42, 62 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
543
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
544 /** Table 8.46 */
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
545 static void map_idx_10_to_20(int8_t *par_mapped, const int8_t *par, int full)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
546 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
547 int b;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
548 if (full)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
549 b = 9;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
550 else {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
551 b = 4;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
552 par_mapped[10] = 0;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
553 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
554 for (; b >= 0; b--) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
555 par_mapped[2*b+1] = par_mapped[2*b] = par[b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
556 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
557 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
558
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
559 static void map_idx_34_to_20(int8_t *par_mapped, const int8_t *par, int full)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
560 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
561 par_mapped[ 0] = (2*par[ 0] + par[ 1]) / 3;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
562 par_mapped[ 1] = ( par[ 1] + 2*par[ 2]) / 3;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
563 par_mapped[ 2] = (2*par[ 3] + par[ 4]) / 3;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
564 par_mapped[ 3] = ( par[ 4] + 2*par[ 5]) / 3;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
565 par_mapped[ 4] = ( par[ 6] + par[ 7]) / 2;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
566 par_mapped[ 5] = ( par[ 8] + par[ 9]) / 2;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
567 par_mapped[ 6] = par[10];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
568 par_mapped[ 7] = par[11];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
569 par_mapped[ 8] = ( par[12] + par[13]) / 2;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
570 par_mapped[ 9] = ( par[14] + par[15]) / 2;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
571 par_mapped[10] = par[16];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
572 if (full) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
573 par_mapped[11] = par[17];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
574 par_mapped[12] = par[18];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
575 par_mapped[13] = par[19];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
576 par_mapped[14] = ( par[20] + par[21]) / 2;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
577 par_mapped[15] = ( par[22] + par[23]) / 2;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
578 par_mapped[16] = ( par[24] + par[25]) / 2;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
579 par_mapped[17] = ( par[26] + par[27]) / 2;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
580 par_mapped[18] = ( par[28] + par[29] + par[30] + par[31]) / 4;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
581 par_mapped[19] = ( par[32] + par[33]) / 2;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
582 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
583 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
584
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
585 static void map_val_34_to_20(float par[PS_MAX_NR_IIDICC])
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
586 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
587 par[ 0] = (2*par[ 0] + par[ 1]) * 0.33333333f;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
588 par[ 1] = ( par[ 1] + 2*par[ 2]) * 0.33333333f;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
589 par[ 2] = (2*par[ 3] + par[ 4]) * 0.33333333f;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
590 par[ 3] = ( par[ 4] + 2*par[ 5]) * 0.33333333f;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
591 par[ 4] = ( par[ 6] + par[ 7]) * 0.5f;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
592 par[ 5] = ( par[ 8] + par[ 9]) * 0.5f;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
593 par[ 6] = par[10];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
594 par[ 7] = par[11];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
595 par[ 8] = ( par[12] + par[13]) * 0.5f;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
596 par[ 9] = ( par[14] + par[15]) * 0.5f;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
597 par[10] = par[16];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
598 par[11] = par[17];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
599 par[12] = par[18];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
600 par[13] = par[19];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
601 par[14] = ( par[20] + par[21]) * 0.5f;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
602 par[15] = ( par[22] + par[23]) * 0.5f;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
603 par[16] = ( par[24] + par[25]) * 0.5f;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
604 par[17] = ( par[26] + par[27]) * 0.5f;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
605 par[18] = ( par[28] + par[29] + par[30] + par[31]) * 0.25f;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
606 par[19] = ( par[32] + par[33]) * 0.5f;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
607 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
608
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
609 static void map_idx_10_to_34(int8_t *par_mapped, const int8_t *par, int full)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
610 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
611 if (full) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
612 par_mapped[33] = par[9];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
613 par_mapped[32] = par[9];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
614 par_mapped[31] = par[9];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
615 par_mapped[30] = par[9];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
616 par_mapped[29] = par[9];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
617 par_mapped[28] = par[9];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
618 par_mapped[27] = par[8];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
619 par_mapped[26] = par[8];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
620 par_mapped[25] = par[8];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
621 par_mapped[24] = par[8];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
622 par_mapped[23] = par[7];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
623 par_mapped[22] = par[7];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
624 par_mapped[21] = par[7];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
625 par_mapped[20] = par[7];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
626 par_mapped[19] = par[6];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
627 par_mapped[18] = par[6];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
628 par_mapped[17] = par[5];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
629 par_mapped[16] = par[5];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
630 } else {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
631 par_mapped[16] = 0;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
632 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
633 par_mapped[15] = par[4];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
634 par_mapped[14] = par[4];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
635 par_mapped[13] = par[4];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
636 par_mapped[12] = par[4];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
637 par_mapped[11] = par[3];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
638 par_mapped[10] = par[3];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
639 par_mapped[ 9] = par[2];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
640 par_mapped[ 8] = par[2];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
641 par_mapped[ 7] = par[2];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
642 par_mapped[ 6] = par[2];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
643 par_mapped[ 5] = par[1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
644 par_mapped[ 4] = par[1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
645 par_mapped[ 3] = par[1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
646 par_mapped[ 2] = par[0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
647 par_mapped[ 1] = par[0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
648 par_mapped[ 0] = par[0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
649 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
650
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
651 static void map_idx_20_to_34(int8_t *par_mapped, const int8_t *par, int full)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
652 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
653 if (full) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
654 par_mapped[33] = par[19];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
655 par_mapped[32] = par[19];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
656 par_mapped[31] = par[18];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
657 par_mapped[30] = par[18];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
658 par_mapped[29] = par[18];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
659 par_mapped[28] = par[18];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
660 par_mapped[27] = par[17];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
661 par_mapped[26] = par[17];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
662 par_mapped[25] = par[16];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
663 par_mapped[24] = par[16];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
664 par_mapped[23] = par[15];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
665 par_mapped[22] = par[15];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
666 par_mapped[21] = par[14];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
667 par_mapped[20] = par[14];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
668 par_mapped[19] = par[13];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
669 par_mapped[18] = par[12];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
670 par_mapped[17] = par[11];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
671 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
672 par_mapped[16] = par[10];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
673 par_mapped[15] = par[ 9];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
674 par_mapped[14] = par[ 9];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
675 par_mapped[13] = par[ 8];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
676 par_mapped[12] = par[ 8];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
677 par_mapped[11] = par[ 7];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
678 par_mapped[10] = par[ 6];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
679 par_mapped[ 9] = par[ 5];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
680 par_mapped[ 8] = par[ 5];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
681 par_mapped[ 7] = par[ 4];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
682 par_mapped[ 6] = par[ 4];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
683 par_mapped[ 5] = par[ 3];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
684 par_mapped[ 4] = (par[ 2] + par[ 3]) / 2;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
685 par_mapped[ 3] = par[ 2];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
686 par_mapped[ 2] = par[ 1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
687 par_mapped[ 1] = (par[ 0] + par[ 1]) / 2;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
688 par_mapped[ 0] = par[ 0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
689 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
690
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
691 static void map_val_20_to_34(float par[PS_MAX_NR_IIDICC])
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
692 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
693 par[33] = par[19];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
694 par[32] = par[19];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
695 par[31] = par[18];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
696 par[30] = par[18];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
697 par[29] = par[18];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
698 par[28] = par[18];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
699 par[27] = par[17];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
700 par[26] = par[17];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
701 par[25] = par[16];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
702 par[24] = par[16];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
703 par[23] = par[15];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
704 par[22] = par[15];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
705 par[21] = par[14];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
706 par[20] = par[14];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
707 par[19] = par[13];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
708 par[18] = par[12];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
709 par[17] = par[11];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
710 par[16] = par[10];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
711 par[15] = par[ 9];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
712 par[14] = par[ 9];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
713 par[13] = par[ 8];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
714 par[12] = par[ 8];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
715 par[11] = par[ 7];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
716 par[10] = par[ 6];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
717 par[ 9] = par[ 5];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
718 par[ 8] = par[ 5];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
719 par[ 7] = par[ 4];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
720 par[ 6] = par[ 4];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
721 par[ 5] = par[ 3];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
722 par[ 4] = (par[ 2] + par[ 3]) * 0.5f;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
723 par[ 3] = par[ 2];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
724 par[ 2] = par[ 1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
725 par[ 1] = (par[ 0] + par[ 1]) * 0.5f;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
726 par[ 0] = par[ 0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
727 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
728
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
729 static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[32][2], int is34)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
730 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
731 float power[34][PS_QMF_TIME_SLOTS] = {{0}};
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
732 float transient_gain[34][PS_QMF_TIME_SLOTS];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
733 float *peak_decay_nrg = ps->peak_decay_nrg;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
734 float *power_smooth = ps->power_smooth;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
735 float *peak_decay_diff_smooth = ps->peak_decay_diff_smooth;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
736 float (*delay)[PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2] = ps->delay;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
737 float (*ap_delay)[PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2] = ps->ap_delay;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
738 const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
739 const float peak_decay_factor = 0.76592833836465f;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
740 const float transient_impact = 1.5f;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
741 const float a_smooth = 0.25f; //< Smoothing coefficient
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
742 int i, k, m, n;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
743 int n0 = 0, nL = 32;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
744 static const int link_delay[] = { 3, 4, 5 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
745 static const float a[] = { 0.65143905753106f,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
746 0.56471812200776f,
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
747 0.48954165955695f };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
748
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
749 if (is34 != ps->is34bands_old) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
750 memset(ps->peak_decay_nrg, 0, sizeof(ps->peak_decay_nrg));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
751 memset(ps->power_smooth, 0, sizeof(ps->power_smooth));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
752 memset(ps->peak_decay_diff_smooth, 0, sizeof(ps->peak_decay_diff_smooth));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
753 memset(ps->delay, 0, sizeof(ps->delay));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
754 memset(ps->ap_delay, 0, sizeof(ps->ap_delay));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
755 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
756
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
757 for (n = n0; n < nL; n++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
758 for (k = 0; k < NR_BANDS[is34]; k++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
759 int i = k_to_i[k];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
760 power[i][n] += s[k][n][0] * s[k][n][0] + s[k][n][1] * s[k][n][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
761 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
762 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
763
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
764 //Transient detection
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
765 for (i = 0; i < NR_PAR_BANDS[is34]; i++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
766 for (n = n0; n < nL; n++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
767 float decayed_peak = peak_decay_factor * peak_decay_nrg[i];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
768 float denom;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
769 peak_decay_nrg[i] = FFMAX(decayed_peak, power[i][n]);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
770 power_smooth[i] += a_smooth * (power[i][n] - power_smooth[i]);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
771 peak_decay_diff_smooth[i] += a_smooth * (peak_decay_nrg[i] - power[i][n] - peak_decay_diff_smooth[i]);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
772 denom = transient_impact * peak_decay_diff_smooth[i];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
773 transient_gain[i][n] = (denom > power_smooth[i]) ?
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
774 power_smooth[i] / denom : 1.0f;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
775 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
776 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
777
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
778 //Decorrelation and transient reduction
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
779 // PS_AP_LINKS - 1
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
780 // -----
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
781 // | | Q_fract_allpass[k][m]*z^-link_delay[m] - a[m]*g_decay_slope[k]
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
782 //H[k][z] = z^-2 * phi_fract[k] * | | ----------------------------------------------------------------
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
783 // | | 1 - a[m]*g_decay_slope[k]*Q_fract_allpass[k][m]*z^-link_delay[m]
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
784 // m = 0
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
785 //d[k][z] (out) = transient_gain_mapped[k][z] * H[k][z] * s[k][z]
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
786 for (k = 0; k < NR_ALLPASS_BANDS[is34]; k++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
787 int b = k_to_i[k];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
788 float g_decay_slope = 1.f - DECAY_SLOPE * (k - DECAY_CUTOFF[is34]);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
789 float ag[PS_AP_LINKS];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
790 g_decay_slope = av_clipf(g_decay_slope, 0.f, 1.f);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
791 memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0]));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
792 memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0]));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
793 for (m = 0; m < PS_AP_LINKS; m++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
794 memcpy(ap_delay[k][m], ap_delay[k][m]+numQMFSlots, 5*sizeof(ap_delay[k][m][0]));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
795 ag[m] = a[m] * g_decay_slope;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
796 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
797 for (n = n0; n < nL; n++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
798 float in_re = delay[k][n+PS_MAX_DELAY-2][0] * phi_fract[is34][k][0] -
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
799 delay[k][n+PS_MAX_DELAY-2][1] * phi_fract[is34][k][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
800 float in_im = delay[k][n+PS_MAX_DELAY-2][0] * phi_fract[is34][k][1] +
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
801 delay[k][n+PS_MAX_DELAY-2][1] * phi_fract[is34][k][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
802 for (m = 0; m < PS_AP_LINKS; m++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
803 float a_re = ag[m] * in_re;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
804 float a_im = ag[m] * in_im;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
805 float link_delay_re = ap_delay[k][m][n+5-link_delay[m]][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
806 float link_delay_im = ap_delay[k][m][n+5-link_delay[m]][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
807 float fractional_delay_re = Q_fract_allpass[is34][k][m][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
808 float fractional_delay_im = Q_fract_allpass[is34][k][m][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
809 ap_delay[k][m][n+5][0] = in_re;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
810 ap_delay[k][m][n+5][1] = in_im;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
811 in_re = link_delay_re * fractional_delay_re - link_delay_im * fractional_delay_im - a_re;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
812 in_im = link_delay_re * fractional_delay_im + link_delay_im * fractional_delay_re - a_im;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
813 ap_delay[k][m][n+5][0] += ag[m] * in_re;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
814 ap_delay[k][m][n+5][1] += ag[m] * in_im;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
815 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
816 out[k][n][0] = transient_gain[b][n] * in_re;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
817 out[k][n][1] = transient_gain[b][n] * in_im;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
818 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
819 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
820 for (; k < SHORT_DELAY_BAND[is34]; k++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
821 memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0]));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
822 memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0]));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
823 for (n = n0; n < nL; n++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
824 //H = delay 14
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
825 out[k][n][0] = transient_gain[k_to_i[k]][n] * delay[k][n+PS_MAX_DELAY-14][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
826 out[k][n][1] = transient_gain[k_to_i[k]][n] * delay[k][n+PS_MAX_DELAY-14][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
827 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
828 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
829 for (; k < NR_BANDS[is34]; k++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
830 memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0]));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
831 memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0]));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
832 for (n = n0; n < nL; n++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
833 //H = delay 1
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
834 out[k][n][0] = transient_gain[k_to_i[k]][n] * delay[k][n+PS_MAX_DELAY-1][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
835 out[k][n][1] = transient_gain[k_to_i[k]][n] * delay[k][n+PS_MAX_DELAY-1][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
836 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
837 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
838 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
839
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
840 static void remap34(int8_t (**p_par_mapped)[PS_MAX_NR_IIDICC],
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
841 int8_t (*par)[PS_MAX_NR_IIDICC],
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
842 int num_par, int num_env, int full)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
843 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
844 int8_t (*par_mapped)[PS_MAX_NR_IIDICC] = *p_par_mapped;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
845 int e;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
846 if (num_par == 20 || num_par == 11) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
847 for (e = 0; e < num_env; e++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
848 map_idx_20_to_34(par_mapped[e], par[e], full);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
849 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
850 } else if (num_par == 10 || num_par == 5) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
851 for (e = 0; e < num_env; e++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
852 map_idx_10_to_34(par_mapped[e], par[e], full);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
853 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
854 } else {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
855 *p_par_mapped = par;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
856 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
857 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
858
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
859 static void remap20(int8_t (**p_par_mapped)[PS_MAX_NR_IIDICC],
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
860 int8_t (*par)[PS_MAX_NR_IIDICC],
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
861 int num_par, int num_env, int full)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
862 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
863 int8_t (*par_mapped)[PS_MAX_NR_IIDICC] = *p_par_mapped;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
864 int e;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
865 if (num_par == 34 || num_par == 17) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
866 for (e = 0; e < num_env; e++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
867 map_idx_34_to_20(par_mapped[e], par[e], full);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
868 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
869 } else if (num_par == 10 || num_par == 5) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
870 for (e = 0; e < num_env; e++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
871 map_idx_10_to_20(par_mapped[e], par[e], full);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
872 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
873 } else {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
874 *p_par_mapped = par;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
875 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
876 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
877
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
878 static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2], int is34)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
879 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
880 int e, b, k, n;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
881
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
882 float (*H11)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H11;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
883 float (*H12)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H12;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
884 float (*H21)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H21;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
885 float (*H22)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H22;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
886 int8_t *opd_hist = ps->opd_hist;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
887 int8_t *ipd_hist = ps->ipd_hist;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
888 int8_t iid_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
889 int8_t icc_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
890 int8_t ipd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
891 int8_t opd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
892 int8_t (*iid_mapped)[PS_MAX_NR_IIDICC] = iid_mapped_buf;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
893 int8_t (*icc_mapped)[PS_MAX_NR_IIDICC] = icc_mapped_buf;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
894 int8_t (*ipd_mapped)[PS_MAX_NR_IIDICC] = ipd_mapped_buf;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
895 int8_t (*opd_mapped)[PS_MAX_NR_IIDICC] = opd_mapped_buf;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
896 const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
897 const float (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
898
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
899 //Remapping
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
900 for (b = 0; b < PS_MAX_NR_IIDICC; b++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
901 H11[0][0][b] = H11[0][ps->num_env_old][b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
902 H12[0][0][b] = H12[0][ps->num_env_old][b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
903 H21[0][0][b] = H21[0][ps->num_env_old][b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
904 H22[0][0][b] = H22[0][ps->num_env_old][b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
905 H11[1][0][b] = H11[1][ps->num_env_old][b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
906 H12[1][0][b] = H12[1][ps->num_env_old][b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
907 H21[1][0][b] = H21[1][ps->num_env_old][b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
908 H22[1][0][b] = H22[1][ps->num_env_old][b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
909 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
910 if (is34) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
911 remap34(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
912 remap34(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
913 if (ps->enable_ipdopd) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
914 remap34(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
915 remap34(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
916 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
917 if (!ps->is34bands_old) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
918 map_val_20_to_34(H11[0][0]);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
919 map_val_20_to_34(H11[1][0]);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
920 map_val_20_to_34(H12[0][0]);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
921 map_val_20_to_34(H12[1][0]);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
922 map_val_20_to_34(H21[0][0]);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
923 map_val_20_to_34(H21[1][0]);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
924 map_val_20_to_34(H22[0][0]);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
925 map_val_20_to_34(H22[1][0]);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
926 ipdopd_reset(ipd_hist, opd_hist);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
927 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
928 } else {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
929 remap20(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
930 remap20(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
931 if (ps->enable_ipdopd) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
932 remap20(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
933 remap20(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
934 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
935 if (ps->is34bands_old) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
936 map_val_34_to_20(H11[0][0]);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
937 map_val_34_to_20(H11[1][0]);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
938 map_val_34_to_20(H12[0][0]);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
939 map_val_34_to_20(H12[1][0]);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
940 map_val_34_to_20(H21[0][0]);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
941 map_val_34_to_20(H21[1][0]);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
942 map_val_34_to_20(H22[0][0]);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
943 map_val_34_to_20(H22[1][0]);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
944 ipdopd_reset(ipd_hist, opd_hist);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
945 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
946 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
947
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
948 //Mixing
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
949 for (e = 0; e < ps->num_env; e++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
950 for (b = 0; b < NR_PAR_BANDS[is34]; b++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
951 float h11, h12, h21, h22;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
952 h11 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
953 h12 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
954 h21 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][2];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
955 h22 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][3];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
956 if (!PS_BASELINE && ps->enable_ipdopd && b < ps->nr_ipdopd_par) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
957 //The spec say says to only run this smoother when enable_ipdopd
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
958 //is set but the reference decoder appears to run it constantly
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
959 float h11i, h12i, h21i, h22i;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
960 float ipd_adj_re, ipd_adj_im;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
961 int opd_idx = opd_hist[b] * 8 + opd_mapped[e][b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
962 int ipd_idx = ipd_hist[b] * 8 + ipd_mapped[e][b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
963 float opd_re = pd_re_smooth[opd_idx];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
964 float opd_im = pd_im_smooth[opd_idx];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
965 float ipd_re = pd_re_smooth[ipd_idx];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
966 float ipd_im = pd_im_smooth[ipd_idx];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
967 opd_hist[b] = opd_idx & 0x3F;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
968 ipd_hist[b] = ipd_idx & 0x3F;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
969
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
970 ipd_adj_re = opd_re*ipd_re + opd_im*ipd_im;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
971 ipd_adj_im = opd_im*ipd_re - opd_re*ipd_im;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
972 h11i = h11 * opd_im;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
973 h11 = h11 * opd_re;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
974 h12i = h12 * ipd_adj_im;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
975 h12 = h12 * ipd_adj_re;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
976 h21i = h21 * opd_im;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
977 h21 = h21 * opd_re;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
978 h22i = h22 * ipd_adj_im;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
979 h22 = h22 * ipd_adj_re;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
980 H11[1][e+1][b] = h11i;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
981 H12[1][e+1][b] = h12i;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
982 H21[1][e+1][b] = h21i;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
983 H22[1][e+1][b] = h22i;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
984 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
985 H11[0][e+1][b] = h11;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
986 H12[0][e+1][b] = h12;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
987 H21[0][e+1][b] = h21;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
988 H22[0][e+1][b] = h22;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
989 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
990 for (k = 0; k < NR_BANDS[is34]; k++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
991 float h11r, h12r, h21r, h22r;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
992 float h11i, h12i, h21i, h22i;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
993 float h11r_step, h12r_step, h21r_step, h22r_step;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
994 float h11i_step, h12i_step, h21i_step, h22i_step;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
995 int start = ps->border_position[e];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
996 int stop = ps->border_position[e+1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
997 float width = 1.f / (stop - start);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
998 b = k_to_i[k];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
999 h11r = H11[0][e][b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1000 h12r = H12[0][e][b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1001 h21r = H21[0][e][b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1002 h22r = H22[0][e][b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1003 if (!PS_BASELINE && ps->enable_ipdopd) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1004 //Is this necessary? ps_04_new seems unchanged
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1005 if ((is34 && k <= 13 && k >= 9) || (!is34 && k <= 1)) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1006 h11i = -H11[1][e][b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1007 h12i = -H12[1][e][b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1008 h21i = -H21[1][e][b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1009 h22i = -H22[1][e][b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1010 } else {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1011 h11i = H11[1][e][b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1012 h12i = H12[1][e][b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1013 h21i = H21[1][e][b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1014 h22i = H22[1][e][b];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1015 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1016 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1017 //Interpolation
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1018 h11r_step = (H11[0][e+1][b] - h11r) * width;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1019 h12r_step = (H12[0][e+1][b] - h12r) * width;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1020 h21r_step = (H21[0][e+1][b] - h21r) * width;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1021 h22r_step = (H22[0][e+1][b] - h22r) * width;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1022 if (!PS_BASELINE && ps->enable_ipdopd) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1023 h11i_step = (H11[1][e+1][b] - h11i) * width;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1024 h12i_step = (H12[1][e+1][b] - h12i) * width;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1025 h21i_step = (H21[1][e+1][b] - h21i) * width;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1026 h22i_step = (H22[1][e+1][b] - h22i) * width;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1027 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1028 for (n = start + 1; n <= stop; n++) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1029 //l is s, r is d
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1030 float l_re = l[k][n][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1031 float l_im = l[k][n][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1032 float r_re = r[k][n][0];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1033 float r_im = r[k][n][1];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1034 h11r += h11r_step;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1035 h12r += h12r_step;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1036 h21r += h21r_step;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1037 h22r += h22r_step;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1038 if (!PS_BASELINE && ps->enable_ipdopd) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1039 h11i += h11i_step;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1040 h12i += h12i_step;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1041 h21i += h21i_step;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1042 h22i += h22i_step;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1043
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1044 l[k][n][0] = h11r*l_re + h21r*r_re - h11i*l_im - h21i*r_im;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1045 l[k][n][1] = h11r*l_im + h21r*r_im + h11i*l_re + h21i*r_re;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1046 r[k][n][0] = h12r*l_re + h22r*r_re - h12i*l_im - h22i*r_im;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1047 r[k][n][1] = h12r*l_im + h22r*r_im + h12i*l_re + h22i*r_re;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1048 } else {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1049 l[k][n][0] = h11r*l_re + h21r*r_re;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1050 l[k][n][1] = h11r*l_im + h21r*r_im;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1051 r[k][n][0] = h12r*l_re + h22r*r_re;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1052 r[k][n][1] = h12r*l_im + h22r*r_im;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1053 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1054 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1055 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1056 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1057 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1058
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1059 int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float R[2][38][64], int top)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1060 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1061 float Lbuf[91][32][2];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1062 float Rbuf[91][32][2];
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1063 const int len = 32;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1064 int is34 = ps->is34bands;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1065
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1066 top += NR_BANDS[is34] - 64;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1067 memset(ps->delay+top, 0, (NR_BANDS[is34] - top)*sizeof(ps->delay[0]));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1068 if (top < NR_ALLPASS_BANDS[is34])
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1069 memset(ps->ap_delay + top, 0, (NR_ALLPASS_BANDS[is34] - top)*sizeof(ps->ap_delay[0]));
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1070
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1071 hybrid_analysis(Lbuf, ps->in_buf, L, is34, len);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1072 decorrelation(ps, Rbuf, Lbuf, is34);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1073 stereo_processing(ps, Lbuf, Rbuf, is34);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1074 hybrid_synthesis(L, Lbuf, is34, len);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1075 hybrid_synthesis(R, Rbuf, is34, len);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1076
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1077 return 0;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1078 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1079
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1080 #define PS_INIT_VLC_STATIC(num, size) \
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1081 INIT_VLC_STATIC(&vlc_ps[num], 9, ps_tmp[num].table_size / ps_tmp[num].elem_size, \
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1082 ps_tmp[num].ps_bits, 1, 1, \
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1083 ps_tmp[num].ps_codes, ps_tmp[num].elem_size, ps_tmp[num].elem_size, \
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1084 size);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1085
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1086 #define PS_VLC_ROW(name) \
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1087 { name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1088
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1089 av_cold void ff_ps_init(void) {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1090 // Syntax initialization
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1091 static const struct {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1092 const void *ps_codes, *ps_bits;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1093 const unsigned int table_size, elem_size;
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1094 } ps_tmp[] = {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1095 PS_VLC_ROW(huff_iid_df1),
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1096 PS_VLC_ROW(huff_iid_dt1),
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1097 PS_VLC_ROW(huff_iid_df0),
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1098 PS_VLC_ROW(huff_iid_dt0),
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1099 PS_VLC_ROW(huff_icc_df),
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1100 PS_VLC_ROW(huff_icc_dt),
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1101 PS_VLC_ROW(huff_ipd_df),
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1102 PS_VLC_ROW(huff_ipd_dt),
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1103 PS_VLC_ROW(huff_opd_df),
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1104 PS_VLC_ROW(huff_opd_dt),
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1105 };
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1106
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1107 PS_INIT_VLC_STATIC(0, 1544);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1108 PS_INIT_VLC_STATIC(1, 832);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1109 PS_INIT_VLC_STATIC(2, 1024);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1110 PS_INIT_VLC_STATIC(3, 1036);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1111 PS_INIT_VLC_STATIC(4, 544);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1112 PS_INIT_VLC_STATIC(5, 544);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1113 PS_INIT_VLC_STATIC(6, 512);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1114 PS_INIT_VLC_STATIC(7, 512);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1115 PS_INIT_VLC_STATIC(8, 512);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1116 PS_INIT_VLC_STATIC(9, 512);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1117
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1118 ps_tableinit();
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1119 }
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1120
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1121 av_cold void ff_ps_ctx_init(PSContext *ps)
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1122 {
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1123 ipdopd_reset(ps->ipd_hist, ps->opd_hist);
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents:
diff changeset
1124 }