36#define OPUS_SEEK_PREROLL_MS 80
37#define OPUS_HEAD_SIZE 19
102 if (os->
psize < 8 || memcmp(packet,
"OpusTags", 8))
114 unsigned nb_frames = 1;
115 unsigned toc =
src[0];
116 unsigned toc_config = toc >> 3;
117 unsigned toc_count = toc & 3;
118 unsigned frame_size = toc_config < 12 ?
FFMAX(480, 960 * (toc_config & 3)) :
119 toc_config < 16 ? 480 << (toc_config & 1) :
120 120 << (toc_config & 3);
121 if (toc_count == 3) {
124 nb_frames =
src[1] & 0x3F;
125 }
else if (toc_count) {
143 if (os->
granule > (1LL << 62)) {
148 if (os->
psize > 8 && !memcmp(packet,
"OpusHead", 8)) {
156 if (os->
psize > 8 && !memcmp(packet,
"OpusTags", 8)) {
169 uint8_t *last_pkt = os->
buf + os->
pstart;
170 uint8_t *next_pkt = last_pkt;
180 last_pkt = next_pkt = next_pkt + os->
psize;
181 for (; seg < os->
nsegs; seg++) {
183 if (os->
segments[seg] < 255 && next_pkt != last_pkt) {
212 "Last packet was truncated to %d due to end trimming.\n",
static void BS_FUNC skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
static const uint8_t frame_size[4]
#define AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
#define AV_NOPTS_VALUE
Undefined timestamp value.
Memory handling functions.
int ff_vorbis_update_metadata(AVFormatContext *s, AVStream *st, const uint8_t *buf, int size)
Parse Vorbis comments, add metadata to an AVStream.
int ff_vorbis_stream_comment(AVFormatContext *as, AVStream *st, const uint8_t *buf, int size)
Parse Vorbis comments and add metadata to an AVStream.
const struct ogg_codec ff_opus_codec
static int parse_opus_header(AVFormatContext *avf, AVStream *st, struct ogg_stream *os, struct oggopus_private *priv, uint8_t *packet, size_t psize)
static int opus_packet(AVFormatContext *avf, int idx)
static int opus_duration(uint8_t *src, int size)
#define OPUS_SEEK_PREROLL_MS
static int opus_header(AVFormatContext *avf, int idx)
int nb_channels
Number of channels in this layout.
AVChannelLayout ch_layout
The channel layout and number of channels.
int seek_preroll
Number of audio samples to skip after a discontinuity.
enum AVMediaType codec_type
General type of the encoded data.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int sample_rate
The number of audio samples per second.
int initial_padding
Number of padding audio samples at the start.
void * priv_data
Format private data.
AVStream ** streams
A list of all streams in the file.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
Copyright (C) 2005 Michael Ahlberg, Måns Rullgård.
int end_trimming
set the number of packets to drop from the end
int start_trimming
set the number of packets to drop from the start
struct ogg_stream * streams