1 /*
2 * AAC encoder intensity stereo
3 * Copyright (C) 2015 Rostislav Pehlivanov
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * @file
24 * AAC encoder Intensity Stereo
25 * @author Rostislav Pehlivanov ( atomnuker gmail com )
26 */
27
32
34 int start,
int w,
int g,
float ener0,
36 int use_pcoeffs,
int phase)
37 {
43 float *L34 = &
s->scoefs[256*0], *R34 = &
s->scoefs[256*1];
44 float *IS = &
s->scoefs[256*2], *I34 = &
s->scoefs[256*3];
47
48 if (
ener01 <= 0 || ener0 <= 0) {
50 return is_error;
51 }
52
54 FFPsyBand *band0 = &
s->psy.ch[
s->cur_channel+0].psy_bands[(
w+w2)*16+
g];
55 FFPsyBand *band1 = &
s->psy.ch[
s->cur_channel+1].psy_bands[(
w+w2)*16+
g];
56 int is_band_type, is_sf_idx =
FFMAX(1, sce0->
sf_idx[
w*16+
g]-4);
58 float maxval, dist_spec_err = 0.0f;
78 is_sf_idx, is_band_type,
81 dist_spec_err += (L34[
i] - I34[
i])*(L34[
i] - I34[
i]);
82 dist_spec_err += (R34[
i] - I34[
i]*e01_34)*(R34[
i] - I34[
i]*e01_34);
83 }
84 dist_spec_err *=
s->lambda / minthr;
85 dist2 += dist_spec_err;
86 }
87
94
95 return is_error;
96 }
97
99 {
102 int start = 0, count = 0,
w, w2,
g,
i, prev_sf1 = -1, prev_bt = -1, prev_is = 0;
104 uint8_t nextband1[128];
105
107 return;
108
109 /** Scout out next nonzero bands */
111
113 start = 0;
119 float ener0 = 0.0f, ener1 = 0.0f,
ener01 = 0.0f, ener01p = 0.0f;
123 float coef0 = sce0->
coeffs[start+(
w+w2)*128+
i];
124 float coef1 = sce1->
coeffs[start+(
w+w2)*128+
i];
125 ener0 += coef0*coef0;
126 ener1 += coef1*coef1;
127 ener01 += (coef0 + coef1)*(coef0 + coef1);
128 ener01p += (coef0 - coef1)*(coef0 - coef1);
129 }
130 }
132 ener0, ener1, ener01p, 0, -1);
134 ener0, ener1,
ener01, 0, +1);
135 best = (ph_err1.
pass && ph_err1.
error < ph_err2.
error) ? &ph_err1 : &ph_err2;
143 /** Flip M/S mask and pick the other CB, since it encodes more efficiently */
146 }
148 count++;
149 }
150 }
155 }
156 }
158 }