39 #define MAX_PAGE_SIZE 65307
40 #define DECODER_BUFFER_SIZE MAX_PAGE_SIZE
99 for (i = 0; i < ogg->
nstreams; i++) {
130 for (i = 0; i < ogg->
nstreams; i++) {
163 for (i = 0; i < ogg->
nstreams; i++) {
177 if (start_pos <= s->internal->data_offset) {
195 for (i = 0; ogg_codecs[i]; i++)
198 return ogg_codecs[i];
226 for (i = 0; i < ogg->
nstreams; i++) {
252 memset(os, 0,
sizeof(*os));
273 "in between Ogg context save/restore operations.\n");
283 memset(os, 0,
sizeof(*os));
356 if (sync[sp & 3] ==
'O' &&
357 sync[(sp + 1) & 3] ==
'g' &&
358 sync[(sp + 2) & 3] ==
'g' && sync[(sp + 3) & 3] ==
'S')
422 for (i = 0; i <
nsegs; i++)
529 if (!complete && os->
segp == os->
nsegs) {
542 "Page at %"PRId64
" is missing granule\n",
568 for (i = 0; i < ogg->
nstreams; i++) {
694 for (i = 0; i < ogg->
nstreams; i++) {
721 for (i = 0; i < ogg->
nstreams; i++) {
730 "Headers mismatch for stream %d: "
731 "expected %d received %d.\n",
810 int64_t fpos,
pts, dts;
820 ret =
ogg_packet(s, &idx, &pstart, &psize, &fpos);
823 }
while (idx < 0 || !s->streams[idx]);
841 memcpy(pkt->
data, os->
buf + pstart, psize);
878 int64_t *pos_arg, int64_t pos_limit)
890 && !
ogg_packet(s, &i, &pstart, &psize, pos_arg)) {
891 if (i == stream_index) {
919 int64_t timestamp,
int flags)
938 os = ogg->
streams + stream_index;
946 if (!memcmp(
"OggS", p->
buf, 5) && p->
buf[5] <= 0x7)
954 .priv_data_size =
sizeof(
struct ogg),
int granule_is_start
1 if granule is the start time of the associated packet.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t avio_size(AVIOContext *s)
Get the filesize.
A list of zero terminated key/value strings.
Copyright (C) 2005 Michael Ahlberg, Måns Rullgård.
static const struct ogg_codec * ogg_find_codec(uint8_t *buf, int size)
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
const struct ogg_codec ff_celt_codec
#define DECODER_BUFFER_SIZE
int nb_header
set to the number of parsed headers
#define AV_LOG_WARNING
Something somehow does not look correct.
int64_t pos
byte position in stream, -1 if unknown
static int ogg_new_buf(struct ogg *ogg, int idx)
#define OGG_NOGRANULE_VALUE
const struct ogg_codec * codec
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
AVFormatInternal * internal
An opaque field for libavformat internal usage.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
void(* cleanup)(AVFormatContext *s, int idx)
static int ogg_get_length(AVFormatContext *s)
static int ogg_probe(AVProbeData *p)
static const struct ogg_codec *const ogg_codecs[]
static int ogg_restore(AVFormatContext *s)
static int ogg_read_packet(AVFormatContext *s, AVPacket *pkt)
const struct ogg_codec ff_ogm_old_codec
int64_t sync_pos
file offset of the first page needed to reconstruct the current packet
#define av_assert0(cond)
assert() equivalent, that is always enabled.
const struct ogg_codec ff_ogm_video_codec
static int data_packets_seen(const struct ogg *ogg)
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
static av_cold int end(AVCodecContext *avctx)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int id
Format-specific stream ID.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
int64_t page_pos
file offset of the current page
AVStream ** streams
A list of all streams in the file.
#define AVERROR_EOF
End of file.
int end_trimming
set the number of packets to drop from the end
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
static int ogg_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
const struct ogg_codec ff_skeleton_codec
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned int avio_rl32(AVIOContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int ogg_read_close(AVFormatContext *s)
enum AVMediaType codec_type
General type of the encoded data.
simple assert() macros that are a bit more flexible than ISO C assert().
const struct ogg_codec ff_opus_codec
int flags
A combination of AV_PKT_FLAG values.
int avio_r8(AVIOContext *s)
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
int incomplete
whether we're expecting a continuation in the next page
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
#define ss(width, name, subs,...)
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
unsigned int new_metadata_size
static int ogg_read_page(AVFormatContext *s, int *sid)
static int64_t ogg_calc_pts(AVFormatContext *s, int idx, int64_t *dts)
static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, int nsegs)
Replace the current stream with a new one.
int(* packet)(AVFormatContext *, int)
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
struct ogg_stream * streams
const struct ogg_codec ff_vorbis_codec
const struct ogg_codec ff_vp8_codec
int page_end
current packet is the last one completed in the page
AVInputFormat ff_ogg_demuxer
#define AV_EF_EXPLODE
abort decoding on minor error detection
const struct ogg_codec ff_ogm_audio_codec
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
const struct ogg_codec ff_theora_codec
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
static int ogg_find_stream(struct ogg *ogg, int serial)
#define AV_LOG_INFO
Standard information.
AVIOContext * pb
I/O context.
static int ogg_packet(AVFormatContext *s, int *sid, int *dstart, int *dsize, int64_t *fpos)
find the next Ogg packet
const struct ogg_codec ff_flac_codec
const struct ogg_codec ff_old_dirac_codec
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
int io_repositioned
IO repositioned flag.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
static int ogg_read_header(AVFormatContext *s)
int nb_header
Number of expected headers.
Recommmends skipping the specified number of samples.
static int ogg_reset(AVFormatContext *s)
This structure contains the data a format has to probe a file.
const struct ogg_codec ff_old_flac_codec
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
#define flags(name, subs,...)
const struct ogg_codec ff_dirac_codec
int64_t duration
Decoding: duration of the stream, in stream time base.
const struct ogg_codec ff_speex_codec
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base...
int error_recognition
Error recognition; higher values will detect more errors but may misdetect some more or less valid pa...
int got_data
1 if the stream got some data (non-initial packets), 0 otherwise
static int av_size_mult(size_t a, size_t b, size_t *r)
Multiply two size_t values checking for overflow.
const struct ogg_codec ff_ogm_text_codec
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static void free_stream(AVFormatContext *s, int i)
static int ogg_save(AVFormatContext *s)
int64_t page_pos
file offset of the current page
void * priv_data
Format private data.
const struct ogg_codec ff_daala_codec
static int ogg_new_stream(AVFormatContext *s, uint32_t serial)
static void ogg_validate_keyframe(AVFormatContext *s, int idx, int pstart, int psize)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
static int64_t ogg_read_timestamp(AVFormatContext *s, int stream_index, int64_t *pos_arg, int64_t pos_limit)
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int avio_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
struct ogg_stream streams[1]
This structure stores compressed data.
uint64_t avio_rl64(AVIOContext *s)
int(* header)(AVFormatContext *, int)
Attempt to process a packet as a header.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
static uint64_t ogg_gptopts(AVFormatContext *s, int i, uint64_t gp, int64_t *dts)
#define AV_NOPTS_VALUE
Undefined timestamp value.