38 #define MAX_PAGE_SIZE 65307
39 #define DECODER_BUFFER_SIZE MAX_PAGE_SIZE
124 for (i = 0; i < ogg->
nstreams; i++){
148 for (i = 0; ogg_codecs[i]; i++)
151 return ogg_codecs[i];
226 if (sync[sp & 3] ==
'O' &&
227 sync[(sp + 1) & 3] ==
'g' &&
228 sync[(sp + 2) & 3] ==
'g' && sync[(sp + 3) & 3] ==
'S')
256 for (n = 0; n < ogg->
nstreams; n++) {
285 for (i = 0; i <
nsegs; i++)
349 av_dlog(s,
"ogg_packet: idx=%d pstart=%d psize=%d segp=%d nsegs=%d\n",
387 av_dlog(s,
"ogg_packet: idx %i, frame size %i, start %i\n",
411 for (i = 0; i < ogg->
nstreams; i++) {
513 for (i = 0; i < ogg->
nstreams; i++) {
584 int64_t fpos, pts, dts;
589 ret =
ogg_packet(s, &idx, &pstart, &psize, &fpos);
592 }
while (idx < 0 || !s->streams[idx]);
609 memcpy (pkt->
data, os->
buf + pstart, psize);
621 int64_t *pos_arg, int64_t pos_limit)
631 if (i == stream_index) {
645 int64_t timestamp,
int flags)
658 os = ogg->
streams + stream_index;
666 if (!memcmp(
"OggS", p->
buf, 5) && p->
buf[5] <= 0x7)
674 .priv_data_size =
sizeof(
struct ogg),
int granule_is_start
1 if granule is the start time of the associated packet.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t avio_size(AVIOContext *s)
Get the filesize.
Copyright (C) 2005 Michael Ahlberg, Måns Rullgård.
static const struct ogg_codec * ogg_find_codec(uint8_t *buf, int size)
const struct ogg_codec ff_celt_codec
#define DECODER_BUFFER_SIZE
int64_t pos
byte position in stream, -1 if unknown
static int ogg_new_buf(struct ogg *ogg, int idx)
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define AV_LOG_WARNING
Something somehow does not look correct.
const struct ogg_codec * codec
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
static int sync(AVFormatContext *s, uint8_t *header)
Read input until we find the next ident.
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
void(* cleanup)(AVFormatContext *s, int idx)
int64_t data_offset
offset of the first packet
static int ogg_get_length(AVFormatContext *s)
static int ogg_probe(AVProbeData *p)
static const struct ogg_codec *const ogg_codecs[]
static int ogg_read_packet(AVFormatContext *s, AVPacket *pkt)
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
const struct ogg_codec ff_ogm_old_codec
static int ogg_restore(AVFormatContext *s, int discard)
int64_t sync_pos
file offset of the first page needed to reconstruct the current packet
const struct ogg_codec ff_ogm_video_codec
int id
format-specific stream ID
int64_t page_pos
file offset of the current page
#define AVERROR_EOF
End of file.
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 duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
const struct ogg_codec ff_skeleton_codec
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
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)
void av_log(void *avcl, int level, const char *fmt,...)
AVStream * avformat_new_stream(AVFormatContext *s, AVCodec *c)
Add a new stream to a media file.
int flags
A combination of AV_PKT_FLAG values.
int avio_r8(AVIOContext *s)
AVCodecContext * codec
codec context
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.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
static int ogg_get_headers(AVFormatContext *s)
static int64_t ogg_calc_pts(AVFormatContext *s, int idx, int64_t *dts)
static av_always_inline int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
int(* packet)(AVFormatContext *, int)
struct ogg_stream * streams
const struct ogg_codec ff_vorbis_codec
static int ogg_new_stream(AVFormatContext *s, uint32_t serial, int new_avstream)
int page_end
current packet is the last one completed in the page
AVInputFormat ff_ogg_demuxer
#define av_dlog(pctx,...)
av_dlog macros Useful to print debug messages that shouldn't get compiled in normally.
const struct ogg_codec ff_ogm_audio_codec
const struct ogg_codec ff_theora_codec
static int ogg_find_stream(struct ogg *ogg, int serial)
enum AVMediaType codec_type
const struct ogg_codec ff_flac_codec
const struct ogg_codec ff_old_dirac_codec
static int ogg_read_page(AVFormatContext *s, int *str)
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int ogg_read_header(AVFormatContext *s)
static int ogg_reset(struct ogg *ogg)
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
This structure contains the data a format has to probe a file.
const struct ogg_codec ff_old_flac_codec
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 stream time base.
const struct ogg_codec ff_ogm_text_codec
static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize, int64_t *fpos)
int eof_reached
true if eof reached
static int ogg_save(AVFormatContext *s)
void * priv_data
Format private data.
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
Decoding: duration of the stream, in AV_TIME_BASE fractional seconds.
struct ogg_stream streams[1]
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.