Go to the documentation of this file.
69 if (*ptr >= end ||
val > INT_MAX - 254)
87 const uint8_t *ptr = buf;
88 const uint8_t *end = buf + buf_size;
97 pkt->code = (
i ) & 0x3;
98 pkt->stereo = (
i >> 2) & 0x1;
99 pkt->config = (
i >> 3) & 0x1F;
102 if (
pkt->code >= 2 && buf_size < 2)
108 pkt->frame_count = 1;
111 if (self_delimiting) {
113 if (len < 0 || len > end - ptr)
116 buf_size = end - buf;
119 frame_bytes = end - ptr;
122 pkt->frame_offset[0] = ptr - buf;
123 pkt->frame_size[0] = frame_bytes;
127 pkt->frame_count = 2;
130 if (self_delimiting) {
132 if (len < 0 || 2 * len > end - ptr)
135 buf_size = end - buf;
138 frame_bytes = end - ptr;
141 pkt->frame_offset[0] = ptr - buf;
142 pkt->frame_size[0] = frame_bytes >> 1;
143 pkt->frame_offset[1] =
pkt->frame_offset[0] +
pkt->frame_size[0];
144 pkt->frame_size[1] = frame_bytes >> 1;
148 pkt->frame_count = 2;
156 if (self_delimiting) {
158 if (len < 0 || len + frame_bytes > end - ptr)
160 end = ptr + frame_bytes +
len;
161 buf_size = end - buf;
164 pkt->frame_offset[0] = ptr - buf;
165 pkt->frame_size[0] = frame_bytes;
168 frame_bytes = end - ptr -
pkt->frame_size[0];
171 pkt->frame_offset[1] =
pkt->frame_offset[0] +
pkt->frame_size[0];
172 pkt->frame_size[1] = frame_bytes;
177 pkt->frame_count = (
i ) & 0x3F;
178 padding = (
i >> 6) & 0x01;
179 pkt->vbr = (
i >> 7) & 0x01;
196 for (
i = 0;
i <
pkt->frame_count - 1;
i++) {
200 pkt->frame_size[
i] = frame_bytes;
201 total_bytes += frame_bytes;
204 if (self_delimiting) {
206 if (len < 0 || len + total_bytes + padding > end - ptr)
208 end = ptr + total_bytes +
len + padding;
209 buf_size = end - buf;
212 frame_bytes = end - ptr - padding;
213 if (total_bytes > frame_bytes)
215 pkt->frame_offset[0] = ptr - buf;
216 for (
i = 1;
i <
pkt->frame_count;
i++)
217 pkt->frame_offset[
i] =
pkt->frame_offset[
i-1] +
pkt->frame_size[
i-1];
218 pkt->frame_size[
pkt->frame_count-1] = frame_bytes - total_bytes;
222 if (self_delimiting) {
224 if (frame_bytes < 0 || pkt->frame_count * frame_bytes + padding > end - ptr)
226 end = ptr +
pkt->frame_count * frame_bytes + padding;
227 buf_size = end - buf;
229 frame_bytes = end - ptr - padding;
230 if (frame_bytes %
pkt->frame_count ||
233 frame_bytes /=
pkt->frame_count;
236 pkt->frame_offset[0] = ptr - buf;
237 pkt->frame_size[0] = frame_bytes;
238 for (
i = 1;
i <
pkt->frame_count;
i++) {
239 pkt->frame_offset[
i] =
pkt->frame_offset[
i-1] +
pkt->frame_size[
i-1];
240 pkt->frame_size[
i] = frame_bytes;
245 pkt->packet_size = buf_size;
246 pkt->data_size =
pkt->packet_size - padding;
254 if (
pkt->config < 12) {
256 pkt->bandwidth =
pkt->config >> 2;
257 }
else if (
pkt->config < 16) {
262 pkt->bandwidth = (
pkt->config - 16) >> 2;
271 memset(
pkt, 0,
sizeof(*
pkt));
288 static const uint8_t default_channel_map[2] = { 0, 1 };
295 int version, map_type, streams, stereo_streams,
i, j,
ret;
301 "Multichannel configuration without extradata.\n");
311 if (extradata_size < 19) {
333 s->gain_i =
AV_RL16(extradata + 16);
335 map_type = extradata[18];
339 "Channel mapping 0 is only specified for up to 2 channels\n");
348 }
else if (map_type == 1 || map_type == 2 || map_type == 255) {
349 if (extradata_size < 21 +
channels) {
356 streams = extradata[19];
357 stereo_streams = extradata[20];
358 if (!streams || stereo_streams > streams ||
359 streams + stereo_streams > 255) {
361 "Invalid stream/stereo stream count: %d/%d\n", streams, stereo_streams);
369 "Channel mapping 1 is only specified for up to 8 channels\n");
375 }
else if (map_type == 2) {
377 if (
channels != ((ambisonic_order + 1) * (ambisonic_order + 1)) &&
378 channels != ((ambisonic_order + 1) * (ambisonic_order + 1) + 2)) {
380 "Channel mapping 2 is only specified for channel counts"
381 " which can be written as (n + 1)^2 or (n + 1)^2 + 2"
382 " for nonnegative integer n\n");
394 if (
channels != ((ambisonic_order + 1) * (ambisonic_order + 1)))
408 if (!
s->channel_maps) {
420 }
else if (idx >= streams + stereo_streams) {
422 "Invalid channel map for output channel %d: %d\n",
i, idx);
430 for (j = 0; j <
i; j++)
437 if (idx < 2 * stereo_streams) {
438 map->stream_idx = idx / 2;
439 map->channel_idx = idx & 1;
441 map->stream_idx = idx - stereo_streams;
442 map->channel_idx = 0;
450 s->nb_streams = streams;
451 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)
int skip_samples
Number of audio samples to skip at the start of the next decoded frame.
#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.
struct AVCodecInternal * internal
Private context used for internal data.
#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.
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
#define i(width, name, range_min, range_max)
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.