summaryrefslogtreecommitdiff
path: root/libavformat/oggdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-05-13 04:40:40 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-05-13 04:40:40 +0200
commit72153419b52c96b1ed4a1bfb7e7793ddde7d71b2 (patch)
tree2e5b40aecf44ad40dd0d6bf122fd8918a889805e /libavformat/oggdec.c
parent410ca3bc2d5e95078f3d6698a2f9e53c2fd24f95 (diff)
parent552a99957f7c6f6ed13795caee7ab7b9deb5d76e (diff)
Merge remote branch 'qatar/master'
* qatar/master: (33 commits) rtpdec_qdm2: Don't try to parse data packet if no configuration is received ac3enc: put the counting of stereo rematrixing bits in the same place to make the code easier to understand. ac3enc: clean up count_frame_bits() and count_frame_bits_fixed() mpegvideo: make FF_DEBUG_DCT_COEFF output coeffs via av_log() instead of just via AVFrame. srtdec: make sure we don't write past the end of buffer wmaenc: improve channel count and bitrate error handling in encode_init() matroskaenc: make sure we don't produce invalid file with no codec ID matroskadec: check that pointers were initialized before accessing them lavf: fix function name in compute_pkt_fields2 av_dlog message lavf: fix av_find_best_stream when providing a wanted stream. lavf: fix av_find_best_stream when decoder_ret is given and using a related stream. ffmpeg: factorize quality calculation tiff: add support for SamplesPerPixel tag in tiff_decode_tag() tiff: Prefer enum TiffCompr over int for TiffContext.compr. mov: Support edit list atom version 1. configure: Enable libpostproc automatically if GPL code is enabled. Cosmetics: fix prototypes in oggdec oggdec: fix memleak with continuous streams. matroskaenc: add missing new line in av_log() call dnxhdenc: add AVClass in private context. ... swscale changes largely rewritten by me or replaced by baptsites due to lots of bugs in ronalds code. Above code is also just in case its not obvios to a large extended duplicates that where cherry picked from ffmpeg. Conflicts: configure ffmpeg.c libavformat/matroskaenc.c libavutil/pixfmt.h libswscale/ppc/swscale_template.c libswscale/swscale.c libswscale/swscale_template.c libswscale/utils.c libswscale/x86/swscale_template.c tests/fate/h264.mak tests/ref/lavfi/pixdesc_le tests/ref/lavfi/pixfmts_copy_le tests/ref/lavfi/pixfmts_null_le tests/ref/lavfi/pixfmts_scale_le tests/ref/lavfi/pixfmts_vflip_le Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/oggdec.c')
-rw-r--r--libavformat/oggdec.c94
1 files changed, 40 insertions, 54 deletions
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index b9ac3d9f0e..c799ce5205 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -56,8 +56,7 @@ static const struct ogg_codec * const ogg_codecs[] = {
};
//FIXME We could avoid some structure duplication
-static int
-ogg_save (AVFormatContext * s)
+static int ogg_save(AVFormatContext *s)
{
struct ogg *ogg = s->priv_data;
struct ogg_state *ost =
@@ -81,8 +80,7 @@ ogg_save (AVFormatContext * s)
return 0;
}
-static int
-ogg_restore (AVFormatContext * s, int discard)
+static int ogg_restore(AVFormatContext *s, int discard)
{
struct ogg *ogg = s->priv_data;
AVIOContext *bc = s->pb;
@@ -110,8 +108,7 @@ ogg_restore (AVFormatContext * s, int discard)
return 0;
}
-static int
-ogg_reset (struct ogg * ogg)
+static int ogg_reset(struct ogg *ogg)
{
int i;
@@ -135,8 +132,7 @@ ogg_reset (struct ogg * ogg)
return 0;
}
-static const struct ogg_codec *
-ogg_find_codec (uint8_t * buf, int size)
+static const struct ogg_codec *ogg_find_codec(uint8_t *buf, int size)
{
int i;
@@ -148,8 +144,7 @@ ogg_find_codec (uint8_t * buf, int size)
return NULL;
}
-static int
-ogg_new_stream (AVFormatContext * s, uint32_t serial)
+static int ogg_new_stream(AVFormatContext *s, uint32_t serial, int new_avstream)
{
struct ogg *ogg = s->priv_data;
@@ -166,17 +161,18 @@ ogg_new_stream (AVFormatContext * s, uint32_t serial)
os->buf = av_malloc(os->bufsize);
os->header = -1;
- st = av_new_stream (s, idx);
- if (!st)
- return AVERROR(ENOMEM);
+ if (new_avstream) {
+ st = av_new_stream(s, idx);
+ if (!st)
+ return AVERROR(ENOMEM);
- av_set_pts_info(st, 64, 1, 1000000);
+ av_set_pts_info(st, 64, 1, 1000000);
+ }
return idx;
}
-static int
-ogg_new_buf(struct ogg *ogg, int idx)
+static int ogg_new_buf(struct ogg *ogg, int idx)
{
struct ogg_stream *os = ogg->streams + idx;
uint8_t *nb = av_malloc(os->bufsize);
@@ -192,8 +188,7 @@ ogg_new_buf(struct ogg *ogg, int idx)
return 0;
}
-static int
-ogg_read_page (AVFormatContext * s, int *str)
+static int ogg_read_page(AVFormatContext *s, int *str)
{
AVIOContext *bc = s->pb;
struct ogg *ogg = s->priv_data;
@@ -251,8 +246,10 @@ ogg_read_page (AVFormatContext * s, int *str)
}
ogg->curidx = -1;
ogg->nstreams = 0;
+ idx = ogg_new_stream(s, serial, 0);
+ } else {
+ idx = ogg_new_stream(s, serial, 1);
}
- idx = ogg_new_stream (s, serial);
if (idx < 0)
return -1;
}
@@ -308,8 +305,8 @@ ogg_read_page (AVFormatContext * s, int *str)
return 0;
}
-static int
-ogg_packet (AVFormatContext * s, int *str, int *dstart, int *dsize, int64_t *fpos)
+static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize,
+ int64_t *fpos)
{
struct ogg *ogg = s->priv_data;
int idx, i;
@@ -439,8 +436,7 @@ ogg_packet (AVFormatContext * s, int *str, int *dstart, int *dsize, int64_t *fpo
return 0;
}
-static int
-ogg_get_headers (AVFormatContext * s)
+static int ogg_get_headers(AVFormatContext *s)
{
struct ogg *ogg = s->priv_data;
@@ -456,8 +452,7 @@ ogg_get_headers (AVFormatContext * s)
return 0;
}
-static int
-ogg_get_length (AVFormatContext * s)
+static int ogg_get_length(AVFormatContext *s)
{
struct ogg *ogg = s->priv_data;
int i;
@@ -505,9 +500,7 @@ ogg_get_length (AVFormatContext * s)
return 0;
}
-
-static int
-ogg_read_header (AVFormatContext * s, AVFormatParameters * ap)
+static int ogg_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
struct ogg *ogg = s->priv_data;
int i;
@@ -558,8 +551,7 @@ static int64_t ogg_calc_pts(AVFormatContext *s, int idx, int64_t *dts)
return pts;
}
-static int
-ogg_read_packet (AVFormatContext * s, AVPacket * pkt)
+static int ogg_read_packet(AVFormatContext *s, AVPacket *pkt)
{
struct ogg *ogg;
struct ogg_stream *os;
@@ -599,9 +591,7 @@ retry:
return psize;
}
-
-static int
-ogg_read_close (AVFormatContext * s)
+static int ogg_read_close(AVFormatContext *s)
{
struct ogg *ogg = s->priv_data;
int i;
@@ -614,10 +604,8 @@ ogg_read_close (AVFormatContext * s)
return 0;
}
-
-static int64_t
-ogg_read_timestamp (AVFormatContext * s, int stream_index, int64_t * pos_arg,
- int64_t pos_limit)
+static int64_t ogg_read_timestamp(AVFormatContext *s, int stream_index,
+ int64_t *pos_arg, int64_t pos_limit)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + stream_index;
@@ -640,7 +628,8 @@ ogg_read_timestamp (AVFormatContext * s, int stream_index, int64_t * pos_arg,
return pts;
}
-static int ogg_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
+static int ogg_read_seek(AVFormatContext *s, int stream_index,
+ int64_t timestamp, int flags)
{
struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + stream_index;
@@ -660,24 +649,21 @@ static int ogg_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
static int ogg_probe(AVProbeData *p)
{
- if (p->buf[0] == 'O' && p->buf[1] == 'g' &&
- p->buf[2] == 'g' && p->buf[3] == 'S' &&
- p->buf[4] == 0x0 && p->buf[5] <= 0x7 )
+ if (!memcmp("OggS", p->buf, 5) && p->buf[5] <= 0x7)
return AVPROBE_SCORE_MAX;
- else
- return 0;
+ return 0;
}
AVInputFormat ff_ogg_demuxer = {
- "ogg",
- NULL_IF_CONFIG_SMALL("Ogg"),
- sizeof (struct ogg),
- ogg_probe,
- ogg_read_header,
- ogg_read_packet,
- ogg_read_close,
- ogg_read_seek,
- ogg_read_timestamp,
- .extensions = "ogg",
- .flags = AVFMT_GENERIC_INDEX,
+ .name = "ogg",
+ .long_name = NULL_IF_CONFIG_SMALL("Ogg"),
+ .priv_data_size = sizeof(struct ogg),
+ .read_probe = ogg_probe,
+ .read_header = ogg_read_header,
+ .read_packet = ogg_read_packet,
+ .read_close = ogg_read_close,
+ .read_seek = ogg_read_seek,
+ .read_timestamp = ogg_read_timestamp,
+ .extensions = "ogg",
+ .flags = AVFMT_GENERIC_INDEX,
};