Go to the documentation of this file.
70 if (*ptr >= end ||
val > INT_MAX - 254)
88 const uint8_t *ptr = buf;
89 const uint8_t *end = buf + buf_size;
98 pkt->code = (
i ) & 0x3;
99 pkt->stereo = (
i >> 2) & 0x1;
100 pkt->config = (
i >> 3) & 0x1F;
103 if (
pkt->code >= 2 && buf_size < 2)
109 pkt->frame_count = 1;
112 if (self_delimiting) {
114 if (len < 0 || len > end - ptr)
117 buf_size = end - buf;
120 frame_bytes = end - ptr;
123 pkt->frame_offset[0] = ptr - buf;
124 pkt->frame_size[0] = frame_bytes;
128 pkt->frame_count = 2;
131 if (self_delimiting) {
133 if (len < 0 || 2 * len > end - ptr)
136 buf_size = end - buf;
139 frame_bytes = end - ptr;
142 pkt->frame_offset[0] = ptr - buf;
143 pkt->frame_size[0] = frame_bytes >> 1;
144 pkt->frame_offset[1] =
pkt->frame_offset[0] +
pkt->frame_size[0];
145 pkt->frame_size[1] = frame_bytes >> 1;
149 pkt->frame_count = 2;
157 if (self_delimiting) {
159 if (len < 0 || len + frame_bytes > end - ptr)
161 end = ptr + frame_bytes +
len;
162 buf_size = end - buf;
165 pkt->frame_offset[0] = ptr - buf;
166 pkt->frame_size[0] = frame_bytes;
169 frame_bytes = end - ptr -
pkt->frame_size[0];
172 pkt->frame_offset[1] =
pkt->frame_offset[0] +
pkt->frame_size[0];
173 pkt->frame_size[1] = frame_bytes;
178 pkt->frame_count = (
i ) & 0x3F;
179 padding = (
i >> 6) & 0x01;
180 pkt->vbr = (
i >> 7) & 0x01;
197 for (
i = 0;
i <
pkt->frame_count - 1;
i++) {
201 pkt->frame_size[
i] = frame_bytes;
202 total_bytes += frame_bytes;
205 if (self_delimiting) {
207 if (len < 0 || len + total_bytes + padding > end - ptr)
209 end = ptr + total_bytes +
len + padding;
210 buf_size = end - buf;
213 frame_bytes = end - ptr - padding;
214 if (total_bytes > frame_bytes)
216 pkt->frame_offset[0] = ptr - buf;
217 for (
i = 1;
i <
pkt->frame_count;
i++)
218 pkt->frame_offset[
i] =
pkt->frame_offset[
i-1] +
pkt->frame_size[
i-1];
219 pkt->frame_size[
pkt->frame_count-1] = frame_bytes - total_bytes;
223 if (self_delimiting) {
225 if (frame_bytes < 0 || pkt->frame_count * frame_bytes + padding > end - ptr)
227 end = ptr +
pkt->frame_count * frame_bytes + padding;
228 buf_size = end - buf;
230 frame_bytes = end - ptr - padding;
231 if (frame_bytes %
pkt->frame_count ||
234 frame_bytes /=
pkt->frame_count;
237 pkt->frame_offset[0] = ptr - buf;
238 pkt->frame_size[0] = frame_bytes;
239 for (
i = 1;
i <
pkt->frame_count;
i++) {
240 pkt->frame_offset[
i] =
pkt->frame_offset[
i-1] +
pkt->frame_size[
i-1];
241 pkt->frame_size[
i] = frame_bytes;
246 pkt->packet_size = buf_size;
247 pkt->data_size =
pkt->packet_size - padding;
255 if (
pkt->config < 12) {
257 pkt->bandwidth =
pkt->config >> 2;
258 }
else if (
pkt->config < 16) {
263 pkt->bandwidth = (
pkt->config - 16) >> 2;
272 memset(
pkt, 0,
sizeof(*
pkt));
289 static const uint8_t default_channel_map[2] = { 0, 1 };
296 int version, map_type, streams, stereo_streams,
i, j,
ret;
302 "Multichannel configuration without extradata.\n");
312 if (extradata_size < 19) {
332 s->gain_i =
AV_RL16(extradata + 16);
334 map_type = extradata[18];
338 "Channel mapping 0 is only specified for up to 2 channels\n");
347 }
else if (map_type == 1 || map_type == 2 || map_type == 255) {
348 if (extradata_size < 21 +
channels) {
355 streams = extradata[19];
356 stereo_streams = extradata[20];
357 if (!streams || stereo_streams > streams ||
358 streams + stereo_streams > 255) {
360 "Invalid stream/stereo stream count: %d/%d\n", streams, stereo_streams);
368 "Channel mapping 1 is only specified for up to 8 channels\n");
374 }
else if (map_type == 2) {
376 if (
channels != ((ambisonic_order + 1) * (ambisonic_order + 1)) &&
377 channels != ((ambisonic_order + 1) * (ambisonic_order + 1) + 2)) {
379 "Channel mapping 2 is only specified for channel counts"
380 " which can be written as (n + 1)^2 or (n + 1)^2 + 2"
381 " for nonnegative integer n\n");
393 if (
channels != ((ambisonic_order + 1) * (ambisonic_order + 1)))
407 if (!
s->channel_maps) {
419 }
else if (idx >= streams + stereo_streams) {
421 "Invalid channel map for output channel %d: %d\n",
i, idx);
429 for (j = 0; j <
i; j++)
436 if (idx < 2 * stereo_streams) {
437 map->stream_idx = idx / 2;
438 map->channel_idx = idx & 1;
440 map->stream_idx = idx - stereo_streams;
441 map->channel_idx = 0;
449 s->nb_streams = streams;
450 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
#define AV_CHANNEL_LAYOUT_STEREO
static const uint8_t opus_default_extradata[30]
static int channel_reorder_vorbis(int nb_channels, int channel_idx)
#define OPUS_MAX_FRAME_SIZE
static int channel_reorder_unknown(int nb_channels, int channel_idx)
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.
const uint16_t ff_opus_frame_duration[32]
av_cold int ff_opus_parse_extradata(AVCodecContext *avctx, OpusParseContext *s)
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
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.
#define OPUS_MAX_PACKET_DUR
@ OPUS_BANDWIDTH_SUPERWIDEBAND
static int xiph_lacing_16bit(const uint8_t **ptr, const uint8_t *end)
Read a 1- or 2-byte frame length.
An AVChannelLayout holds information about the channel layout of audio data.
#define i(width, name, range_min, range_max)
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)
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
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
void * av_calloc(size_t nmemb, size_t size)
main external API structure.
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
#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.