1 /*
2 * QCP format (.qcp) demuxer
3 * Copyright (c) 2009 Kenan Gillet
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 * QCP format (.qcp) demuxer
25 * @author Kenan Gillet
26 * @see RFC 3625: "The QCP File Format and Media Types for Speech Data"
27 * http://tools.ietf.org/html/rfc3625
28 */
29
36
39
40 #define QCP_MAX_MODE 4
42 ///< to each mode, -1 if no size.
44
45 /**
46 * Last 15 out of 16 bytes of QCELP-13K GUID, as stored in the file;
47 * the first byte of the GUID can be either 0x41 or 0x42.
48 */
50 0x6d, 0x7f, 0x5e, 0x15, 0xb1, 0xd0, 0x11, 0xba,
51 0x91, 0x00, 0x80, 0x5f, 0xb4, 0xb9, 0x7e
52 };
53
54 /**
55 * EVRC GUID as stored in the file
56 */
58 0x8d, 0xd4, 0x89, 0xe6, 0x76, 0x90, 0xb5, 0x46,
59 0x91, 0xef, 0x73, 0x6a, 0x51, 0x00, 0xce, 0xb4
60 };
61
63 0xca, 0x29, 0xfd, 0x3c, 0x53, 0xf6, 0xf5, 0x4e,
64 0x90, 0xe9, 0xf4, 0x23, 0x6d, 0x59, 0x9b, 0x61
65 };
66
67 /**
68 * SMV GUID as stored in the file
69 */
71 0x75, 0x2b, 0x7c, 0x8d, 0x97, 0xa7, 0x49, 0xed,
72 0x98, 0x5e, 0xd5, 0x3c, 0x8c, 0xc7, 0x5f, 0x84
73 };
74
75 /**
76 * @param guid contains at least 16 bytes
77 * @return 1 if the guid is a qcelp_13k guid, 0 otherwise
78 */
80 return (guid[0] == 0x41 || guid[0] == 0x42)
82 }
83
85 {
89 return 0;
90 }
91
93 {
97 uint8_t buf[16];
100 unsigned nb_rates;
101
102 if (!st)
104
106 avio_skip(pb, 4 + 8 + 4 + 1 + 1);
// filesize + "QLCMfmt " + chunk-size + major-version + minor-version
107
115 }
else if (!memcmp(buf,
guid_evrc, 16)) {
117 }
else if (!memcmp(buf,
guid_smv, 16)) {
119 }
else if (!memcmp(buf,
guid_4gv, 16)) {
121 } else {
125 }
126 avio_skip(pb, 2 + 80);
// codec-version + codec-name
128
133
134 memset(
c->rates_per_mode, -1,
sizeof(
c->rates_per_mode));
136 nb_rates =
FFMIN(nb_rates, 8);
137 for (
i=0;
i<nb_rates;
i++) {
142 } else
144 }
145 avio_skip(pb, 16 - 2*nb_rates + 20);
// empty entries of rate-map-table + reserved
146
147 return 0;
148 }
149
151 {
154 unsigned int chunk_size,
tag;
155
159
160 if (
s->packet_size) {
161 pkt_size =
s->packet_size - 1;
164 continue;
165 }
166
167 if (
c->data_size <= pkt_size) {
169 pkt_size =
c->data_size - 1;
170 }
171
175
176 c->data_size -= pkt_size + 1;
177 }
179 }
180
183
187 case MKTAG(
'v',
'r',
'a',
't'):
191 break;
192 case MKTAG(
'd',
'a',
't',
'a'):
193 c->data_size = chunk_size;
194 break;
195
196 default:
198 }
199 }
201 }
202
210 };