1 /*
2 * ADX ADPCM codecs
3 * Copyright (c) 2001,2003 BERO
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
27
28 /**
29 * @file
30 * SEGA CRI adx codecs.
31 *
32 * Reference documents:
33 * http://ku-www.ss.titech.ac.jp/~yatsushi/adx.html
34 * adx2wav & wav2adx http://www.geocities.co.jp/Playtown/2004/
35 */
36
38 {
41
48 }
51 }
52
54
55 return 0;
56 }
57
58 /**
59 * Decode 32 samples from 18 bytes.
60 *
61 * A 16-bit scalar value is applied to 32 residuals, which then have a
62 * 2nd-order LPC filter applied to it to form the output signal for a single
63 * channel.
64 */
67 {
71 int i;
73
74 /* check if this is an EOF packet */
75 if (scale & 0x8000)
76 return -1;
77
86 s1 = av_clip_int16(s0);
88 }
91
92 return 0;
93 }
94
97 {
99 int buf_size = avpkt->
size;
101 int16_t **samples;
102 int samples_offset;
105 int num_blocks, ch,
ret;
106
108 *got_frame_ptr = 0;
109 return buf_size;
110 }
111
113 int header_size;
118 }
121 if (buf_size < header_size)
123 buf += header_size;
124 buf_size -= header_size;
125 }
128
129 /* calculate number of blocks in the packet */
131
132 /* if the packet is not an even multiple of BLOCK_SIZE, check for an EOF
133 packet */
135 if (buf_size >= 4 && (
AV_RB16(buf) & 0x8000)) {
137 *got_frame_ptr = 0;
139 }
141 }
142
143 /* get output buffer */
146 return ret;
148 samples_offset = 0;
149
150 while (num_blocks--) {
151 for (ch = 0; ch < c->
channels; ch++) {
155 break;
156 }
159 }
161 }
162
163 *got_frame_ptr = 1;
164
165 return buf - avpkt->
data;
166 }
167
169 {
171 memset(c->
prev, 0,
sizeof(c->
prev));
173 }
174
187 };