Go to the documentation of this file.
80 if (*ptr >= end ||
val > INT_MAX - 254)
98 const uint8_t *ptr = buf;
99 const uint8_t *end = buf + buf_size;
108 pkt->code = (
i ) & 0x3;
109 pkt->stereo = (
i >> 2) & 0x1;
110 pkt->config = (
i >> 3) & 0x1F;
113 if (
pkt->code >= 2 && buf_size < 2)
119 pkt->frame_count = 1;
122 if (self_delimiting) {
124 if (len < 0 || len > end - ptr)
127 buf_size = end - buf;
130 frame_bytes = end - ptr;
133 pkt->frame_offset[0] = ptr - buf;
134 pkt->frame_size[0] = frame_bytes;
138 pkt->frame_count = 2;
141 if (self_delimiting) {
143 if (len < 0 || 2 * len > end - ptr)
146 buf_size = end - buf;
149 frame_bytes = end - ptr;
152 pkt->frame_offset[0] = ptr - buf;
153 pkt->frame_size[0] = frame_bytes >> 1;
154 pkt->frame_offset[1] =
pkt->frame_offset[0] +
pkt->frame_size[0];
155 pkt->frame_size[1] = frame_bytes >> 1;
159 pkt->frame_count = 2;
167 if (self_delimiting) {
169 if (len < 0 || len + frame_bytes > end - ptr)
171 end = ptr + frame_bytes +
len;
172 buf_size = end - buf;
175 pkt->frame_offset[0] = ptr - buf;
176 pkt->frame_size[0] = frame_bytes;
179 frame_bytes = end - ptr -
pkt->frame_size[0];
182 pkt->frame_offset[1] =
pkt->frame_offset[0] +
pkt->frame_size[0];
183 pkt->frame_size[1] = frame_bytes;
188 pkt->frame_count = (
i ) & 0x3F;
189 padding = (
i >> 6) & 0x01;
190 pkt->vbr = (
i >> 7) & 0x01;
207 for (
i = 0;
i <
pkt->frame_count - 1;
i++) {
211 pkt->frame_size[
i] = frame_bytes;
212 total_bytes += frame_bytes;
215 if (self_delimiting) {
217 if (len < 0 || len + total_bytes + padding > end - ptr)
219 end = ptr + total_bytes +
len + padding;
220 buf_size = end - buf;
223 frame_bytes = end - ptr - padding;
224 if (total_bytes > frame_bytes)
226 pkt->frame_offset[0] = ptr - buf;
227 for (
i = 1;
i <
pkt->frame_count;
i++)
228 pkt->frame_offset[
i] =
pkt->frame_offset[
i-1] +
pkt->frame_size[
i-1];
229 pkt->frame_size[
pkt->frame_count-1] = frame_bytes - total_bytes;
233 if (self_delimiting) {
235 if (frame_bytes < 0 || pkt->frame_count * frame_bytes + padding > end - ptr)
237 end = ptr +
pkt->frame_count * frame_bytes + padding;
238 buf_size = end - buf;
240 frame_bytes = end - ptr - padding;
241 if (frame_bytes %
pkt->frame_count ||
244 frame_bytes /=
pkt->frame_count;
247 pkt->frame_offset[0] = ptr - buf;
248 pkt->frame_size[0] = frame_bytes;
249 for (
i = 1;
i <
pkt->frame_count;
i++) {
250 pkt->frame_offset[
i] =
pkt->frame_offset[
i-1] +
pkt->frame_size[
i-1];
251 pkt->frame_size[
i] = frame_bytes;
256 pkt->packet_size = buf_size;
257 pkt->data_size =
pkt->packet_size - padding;
265 if (
pkt->config < 12) {
267 pkt->bandwidth =
pkt->config >> 2;
268 }
else if (
pkt->config < 16) {
273 pkt->bandwidth = (
pkt->config - 16) >> 2;
282 memset(
pkt, 0,
sizeof(*
pkt));
299 static const uint8_t default_channel_map[2] = { 0, 1 };
306 int version, map_type, streams, stereo_streams,
i, j,
ret;
312 "Multichannel configuration without extradata.\n");
322 if (extradata_size < 19) {
344 s->gain_i =
AV_RL16(extradata + 16);
346 map_type = extradata[18];
350 "Channel mapping 0 is only specified for up to 2 channels\n");
359 }
else if (map_type == 1 || map_type == 2 || map_type == 255) {
360 if (extradata_size < 21 +
channels) {
367 streams = extradata[19];
368 stereo_streams = extradata[20];
369 if (!streams || stereo_streams > streams ||
370 streams + stereo_streams > 255) {
372 "Invalid stream/stereo stream count: %d/%d\n", streams, stereo_streams);
380 "Channel mapping 1 is only specified for up to 8 channels\n");
386 }
else if (map_type == 2) {
388 if (
channels != ((ambisonic_order + 1) * (ambisonic_order + 1)) &&
389 channels != ((ambisonic_order + 1) * (ambisonic_order + 1) + 2)) {
391 "Channel mapping 2 is only specified for channel counts"
392 " which can be written as (n + 1)^2 or (n + 1)^2 + 2"
393 " for nonnegative integer n\n");
405 if (
channels != ((ambisonic_order + 1) * (ambisonic_order + 1)))
419 if (!
s->channel_maps) {
431 }
else if (idx >= streams + stereo_streams) {
433 "Invalid channel map for output channel %d: %d\n",
i, idx);
441 for (j = 0; j <
i; j++)
448 if (idx < 2 * stereo_streams) {
449 map->stream_idx = idx / 2;
450 map->channel_idx = idx & 1;
452 map->stream_idx = idx - stereo_streams;
453 map->channel_idx = 0;
461 s->nb_streams = streams;
462 s->nb_stereo_streams = stereo_streams;
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
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)
#define AV_CHANNEL_LAYOUT_STEREO
static int channel_reorder_vorbis(int nb_channels, int channel_idx)
static const uint8_t opus_default_extradata[30]
int skip_samples
Number of audio samples to skip at the start of the next decoded frame.
#define OPUS_MAX_FRAME_SIZE
int nb_channels
Number of channels in this layout.
AVChannelLayout ch_layout
Audio channel layout.
static double val(void *priv, double ch)
#define AV_CH_LAYOUT_STEREO
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
static int xiph_lacing_16bit(const uint8_t **ptr, const uint8_t *end)
Read a 1- or 2-byte frame length.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
static const uint8_t channel_map[8][8]
@ AV_CHANNEL_ORDER_AMBISONIC
The audio is represented as the decomposition of the sound field into spherical harmonics.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
struct AVCodecInternal * internal
Private context used for internal data.
#define OPUS_MAX_PACKET_DUR
@ OPUS_BANDWIDTH_SUPERWIDEBAND
An AVChannelLayout holds information about the channel layout of audio data.
const uint8_t ff_vorbis_channel_layout_offsets[8][8]
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel layout
#define i(width, name, range_min, range_max)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static int channel_reorder_unknown(int nb_channels, int channel_idx)
void * av_calloc(size_t nmemb, size_t size)
main external API structure.
static const uint16_t opus_frame_duration[32]
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
#define avpriv_request_sample(...)
const AVChannelLayout ff_vorbis_ch_layouts[9]
const VDPAUPixFmtMap * map
#define AV_CHANNEL_LAYOUT_MONO
av_cold int ff_opus_parse_extradata(AVCodecContext *avctx, OpusParseContext *s)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
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.