74 if (*ptr >= end || val > INT_MAX - 254)
102 pkt->
code = (i ) & 0x3;
103 pkt->
stereo = (i >> 2) & 0x1;
104 pkt->
config = (i >> 3) & 0x1F;
107 if (pkt->
code >= 2 && buf_size < 2)
116 if (self_delimiting) {
118 if (len < 0 || len > end - ptr)
121 buf_size = end -
buf;
124 frame_bytes = end - ptr;
135 if (self_delimiting) {
137 if (len < 0 || 2 * len > end - ptr)
140 buf_size = end -
buf;
143 frame_bytes = end - ptr;
161 if (self_delimiting) {
163 if (len < 0 || len + frame_bytes > end - ptr)
165 end = ptr + frame_bytes +
len;
166 buf_size = end -
buf;
183 padding = (i >> 6) & 0x01;
184 pkt->
vbr = (i >> 7) & 0x01;
206 total_bytes += frame_bytes;
209 if (self_delimiting) {
211 if (len < 0 || len + total_bytes + padding > end - ptr)
213 end = ptr + total_bytes + len + padding;
214 buf_size = end -
buf;
217 frame_bytes = end - ptr - padding;
218 if (total_bytes > frame_bytes)
227 if (self_delimiting) {
229 if (frame_bytes < 0 || pkt->frame_count * frame_bytes + padding > end - ptr)
231 end = ptr + pkt->
frame_count * frame_bytes + padding;
232 buf_size = end -
buf;
234 frame_bytes = end - ptr - padding;
262 }
else if (pkt->
config < 16) {
276 memset(pkt, 0,
sizeof(*pkt));
293 static const uint8_t default_channel_map[2] = { 0, 1 };
299 int version, channels, map_type, streams, stereo_streams, i, j;
305 "Multichannel configuration without extradata.\n");
315 if (extradata_size < 19) {
321 version = extradata[8];
339 map_type = extradata[18];
343 "Channel mapping 0 is only specified for up to 2 channels\n");
348 stereo_streams = channels - 1;
349 channel_map = default_channel_map;
350 }
else if (map_type == 1 || map_type == 255) {
351 if (extradata_size < 21 + channels) {
357 streams = extradata[19];
358 stereo_streams = extradata[20];
359 if (!streams || stereo_streams > streams ||
360 streams + stereo_streams > 255) {
362 "Invalid stream/stereo stream count: %d/%d\n", streams, stereo_streams);
369 "Channel mapping 1 is only specified for up to 8 channels\n");
377 channel_map = extradata + 21;
387 for (i = 0; i < channels; i++) {
389 uint8_t idx = channel_map[channel_reorder(channels, i)];
394 }
else if (idx >= streams + stereo_streams) {
396 "Invalid channel map for output channel %d: %d\n", i, idx);
402 for (j = 0; j < i; j++)
403 if (channel_map[channel_reorder(channels, j)] == idx) {
409 if (idx < 2 * stereo_streams) {
int ff_opus_parse_packet(OpusPacket *pkt, const uint8_t *buf, int buf_size, int self_delimiting)
Parse Opus packet info from raw packet data.
static int channel_reorder_vorbis(int nb_channels, int channel_idx)
const char const char void * val
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int frame_count
frame count
static int channel_reorder_unknown(int nb_channels, int channel_idx)
#define AV_CH_LAYOUT_STEREO
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
const int * channel_map
channel index (or -1 if muted channel) map
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
static av_cold int end(AVCodecContext *avctx)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
ChannelMap * channel_maps
static const uint8_t opus_default_extradata[30]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint64_t channel_layout
Audio channel layout.
common internal API header
int frame_size[MAX_FRAMES]
frame sizes
int frame_duration
frame duration, in samples @ 48kHz
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static int xiph_lacing_16bit(const uint8_t **ptr, const uint8_t *end)
Read a 1- or 2-byte frame length.
static int xiph_lacing_full(const uint8_t **ptr, const uint8_t *end)
Read a multi-byte length (used for code 3 packet padding size)
main external API structure.
const uint64_t ff_vorbis_channel_layouts[9]
int config
configuration: tells the audio mode, bandwidth, and frame duration
int stereo
whether this packet is mono or stereo
int data_size
size of the useful data – packet size - padding
static const uint16_t opus_frame_duration[32]
int packet_size
packet size
int channels
number of audio channels
int frame_offset[MAX_FRAMES]
frame offsets
enum OpusBandwidth bandwidth
bandwidth
static void * av_mallocz_array(size_t nmemb, size_t size)
av_cold int ff_opus_parse_extradata(AVCodecContext *avctx, OpusContext *s)
static av_always_inline double ff_exp10(double x)
Compute 10^x for floating point values.
const uint8_t ff_vorbis_channel_layout_offsets[8][8]
int code
packet code: specifies the frame layout
#define AV_CH_LAYOUT_MONO