1 /*
2 * Audio Processing Technology codec for Bluetooth (aptX)
3 *
4 * Copyright (C) 2017 Aurelien Jacobs <aurel@gnuage.org>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #include "config_components.h"
24
29
30 /*
31 * Half-band QMF synthesis filter realized with a polyphase FIR filter.
32 * Join 2 subbands and upsample by 2.
33 * So for each 2 subbands sample that goes in, a pair of samples goes out.
34 */
42 {
45
46 subbands[0] = low_subband_input + high_subband_input;
47 subbands[1] = low_subband_input - high_subband_input;
48
52 }
53 }
54
55 /*
56 * Two stage QMF synthesis tree.
57 * Join 4 subbands and upsample by 4.
58 * So for each 4 subbands sample that goes in, a group of 4 samples goes out.
59 */
63 {
64 int32_t intermediate_samples[4];
66
67 /* Join 4 subbands into 2 intermediate subbands upsampled to 2 samples. */
68 for (
i = 0;
i < 2;
i++)
71 subband_samples[2*
i+0],
72 subband_samples[2*
i+1],
73 &intermediate_samples[2*
i]);
74
75 /* Join 2 samples from intermediate subbands upsampled to 4 samples. */
76 for (
i = 0;
i < 2;
i++)
79 intermediate_samples[0+
i],
80 intermediate_samples[2+
i],
82 }
83
84
86 {
88 int subband;
90 subband_samples[subband] =
channel->prediction[subband].previous_reconstructed_sample;
92 }
93
95 {
100 channel->quantize[3].quantized_sample = (
channel->quantize[3].quantized_sample & ~1)
102 }
103
105 {
110 channel->quantize[3].quantized_sample = (
channel->quantize[3].quantized_sample & ~1)
112 }
113
115 const uint8_t *
input,
117 {
119
122
126 else
130 }
131
133
136
138 }
139
141 int *got_frame_ptr,
AVPacket *avpkt)
142 {
145
146 if (avpkt->
size <
s->block_size) {
149 }
150
151 /* get output buffer */
154 frame->nb_samples = 4 * (avpkt->
size /
s->block_size);
157
158 for (
pos = 0, opos = 0; opos <
frame->nb_samples;
pos +=
s->block_size, opos += 4) {
160
164 }
165
170 }
171
172 *got_frame_ptr = 1;
173 return s->block_size *
frame->nb_samples / 4;
174 }
175
176 #if CONFIG_APTX_DECODER
188 };
189 #endif
190
191 #if CONFIG_APTX_HD_DECODER
194 CODEC_LONG_NAME(
"aptX HD (Audio Processing Technology for Bluetooth)"),
203 };
204 #endif