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 {
40 int ret, header_size;
41
48 }
51 }
52
54
57
58 return 0;
59 }
60
61 /**
62 * Decode 32 samples from 18 bytes.
63 *
64 * A 16-bit scalar value is applied to 32 residuals, which then have a
65 * 2nd-order LPC filter applied to it to form the output signal for a single
66 * channel.
67 */
70 {
74 int i;
76
77 /* check if this is an EOF packet */
78 if (scale & 0x8000)
79 return -1;
80
89 s1 = av_clip_int16(s0);
91 }
94
95 return 0;
96 }
97
100 {
101 int buf_size = avpkt->
size;
104 int samples_offset;
107 int num_blocks, ch, ret;
108
110 *got_frame_ptr = 0;
111 return buf_size;
112 }
113
115 int header_size;
120 }
123 if (buf_size < header_size)
125 buf += header_size;
126 buf_size -= header_size;
127 }
130
131 /* calculate number of blocks in the packet */
133
134 /* if the packet is not an even multiple of BLOCK_SIZE, check for an EOF
135 packet */
137 if (buf_size >= 4 && (
AV_RB16(buf) & 0x8000)) {
139 *got_frame_ptr = 0;
141 }
143 }
144
145 /* get output buffer */
149 return ret;
150 }
152 samples_offset = 0;
153
154 while (num_blocks--) {
155 for (ch = 0; ch < c->
channels; ch++) {
159 break;
160 }
163 }
165 }
166
167 *got_frame_ptr = 1;
169
170 return buf - avpkt->
data;
171 }
172
174 {
176 memset(c->
prev, 0,
sizeof(c->
prev));
178 }
179
192 };