1 /*
2 * audio encoder psychoacoustic model
3 * Copyright (C) 2008 Konstantin Shishkov
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 #include <string.h>
23
28
30
32 const uint8_t **
bands,
const int* num_bands,
33 int num_groups, const uint8_t *group_map)
34 {
36
43
44 if (!
ctx->ch || !
ctx->group || !
ctx->bands || !
ctx->num_bands) {
47 }
48
49 memcpy(
ctx->bands,
bands,
sizeof(
ctx->bands[0]) * num_lens);
50 memcpy(
ctx->num_bands, num_bands,
sizeof(
ctx->num_bands[0]) * num_lens);
51
52 /* assign channels to groups (with virtual channels for coupling) */
53 for (
i = 0;
i < num_groups;
i++) {
54 /* NOTE: Add 1 to handle the AAC chan_config without modification.
55 * This has the side effect of allowing an array of 0s to map
56 * to one channel per group.
57 */
58 ctx->group[
i].num_ch = group_map[
i] + 1;
59 for (j = 0; j <
ctx->group[
i].num_ch * 2; j++)
60 ctx->group[
i].ch[j] = &
ctx->ch[k++];
61 }
62
63 switch (
ctx->avctx->codec_id) {
66 break;
67 }
69 return ctx->model->init(
ctx);
70 return 0;
71 }
72
74 {
76
78 ch +=
ctx->group[
i++].num_ch;
79
80 return &
ctx->group[
i-1];
81 }
82
84 {
85 if (
ctx->model &&
ctx->model->end)
91 }
92
100
102
104 {
107 float cutoff_coeff = 0;
112
113 /* AAC has its own LP method */
117
118 if (cutoff_coeff && cutoff_coeff < 0.98)
121 cutoff_coeff, 0.0, 0.0);
128 }
131 }
132 }
133
135
137 }
138
140 {
141 int ch;
144
149 }
150 }
151
153 {
157 for (
i = 0;
i <
ctx->avctx->channels;
i++)
161 }