73 if (*ptr >= end || val > INT_MAX - 254)
101 pkt->
code = (i ) & 0x3;
102 pkt->
stereo = (i >> 2) & 0x1;
103 pkt->
config = (i >> 3) & 0x1F;
106 if (pkt->
code >= 2 && buf_size < 2)
115 if (self_delimiting) {
117 if (len < 0 || len > end - ptr)
120 buf_size = end -
buf;
123 frame_bytes = end - ptr;
134 if (self_delimiting) {
136 if (len < 0 || 2 * len > end - ptr)
139 buf_size = end -
buf;
142 frame_bytes = end - ptr;
160 if (self_delimiting) {
162 if (len < 0 || len + frame_bytes > end - ptr)
164 end = ptr + frame_bytes +
len;
165 buf_size = end -
buf;
182 padding = (i >> 6) & 0x01;
183 pkt->
vbr = (i >> 7) & 0x01;
205 total_bytes += frame_bytes;
208 if (self_delimiting) {
210 if (len < 0 || len + total_bytes + padding > end - ptr)
212 end = ptr + total_bytes + len + padding;
213 buf_size = end -
buf;
216 frame_bytes = end - ptr - padding;
217 if (total_bytes > frame_bytes)
226 if (self_delimiting) {
228 if (frame_bytes < 0 || pkt->frame_count * frame_bytes + padding > end - ptr)
230 end = ptr + pkt->
frame_count * frame_bytes + padding;
231 buf_size = end -
buf;
233 frame_bytes = end - ptr - padding;
261 }
else if (pkt->
config < 16) {
275 memset(pkt, 0,
sizeof(*pkt));
292 static const uint8_t default_channel_map[2] = { 0, 1 };
293 uint8_t default_extradata[19] = {
294 'O',
'p',
'u',
's',
'H',
'e',
'a',
'd',
295 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
302 int version, channels, map_type, streams, stereo_streams, i, j;
308 "Multichannel configuration without extradata.\n");
311 default_extradata[9] = (avctx->
channels == 1) ? 1 : 2;
312 extradata = default_extradata;
313 extradata_size =
sizeof(default_extradata);
319 if (extradata_size < 19) {
325 version = extradata[8];
333 channels = extradata[9];
343 map_type = extradata[18];
347 "Channel mapping 0 is only specified for up to 2 channels\n");
352 stereo_streams = channels - 1;
353 channel_map = default_channel_map;
354 }
else if (map_type == 1 || map_type == 255) {
355 if (extradata_size < 21 + channels) {
361 streams = extradata[19];
362 stereo_streams = extradata[20];
363 if (!streams || stereo_streams > streams ||
364 streams + stereo_streams > 255) {
366 "Invalid stream/stereo stream count: %d/%d\n", streams, stereo_streams);
373 "Channel mapping 1 is only specified for up to 8 channels\n");
381 channel_map = extradata + 21;
391 for (i = 0; i < channels; i++) {
393 uint8_t idx = channel_map[channel_reorder(channels, i)];
398 }
else if (idx >= streams + stereo_streams) {
400 "Invalid channel map for output channel %d: %d\n", i, idx);
406 for (j = 0; j < i; j++)
407 if (channel_map[channel_reorder(channels, j)] == idx) {
413 if (idx < 2 * stereo_streams) {