Browse Source

oggdec: Don't use ogg_stream's seq for vorbis or speex headers

Originally committed as revision 22459 to svn://svn.ffmpeg.org/ffmpeg/trunk
tags/v0.6
David Conrad 15 years ago
parent
commit
8f8320d7c3
2 changed files with 18 additions and 14 deletions
  1. +10
    -7
      libavformat/oggparsespeex.c
  2. +8
    -7
      libavformat/oggparsevorbis.c

+ 10
- 7
libavformat/oggparsespeex.c View File

@@ -32,18 +32,25 @@


struct speex_params { struct speex_params {
int final_packet_duration; int final_packet_duration;
int seq;
}; };


static int speex_header(AVFormatContext *s, int idx) { static int speex_header(AVFormatContext *s, int idx) {
struct ogg *ogg = s->priv_data; struct ogg *ogg = s->priv_data;
struct ogg_stream *os = ogg->streams + idx; struct ogg_stream *os = ogg->streams + idx;
struct speex_params *spxp = os->private;
AVStream *st = s->streams[idx]; AVStream *st = s->streams[idx];
uint8_t *p = os->buf + os->pstart; uint8_t *p = os->buf + os->pstart;


if (os->seq > 1)
if (!spxp) {
spxp = av_mallocz(sizeof(*spxp));
os->private = spxp;
}

if (spxp->seq > 1)
return 0; return 0;


if (os->seq == 0) {
if (spxp->seq == 0) {
int frames_per_packet; int frames_per_packet;
st->codec->codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_SPEEX; st->codec->codec_id = CODEC_ID_SPEEX;
@@ -70,6 +77,7 @@ static int speex_header(AVFormatContext *s, int idx) {
} else } else
vorbis_comment(s, p, os->psize); vorbis_comment(s, p, os->psize);


spxp->seq++;
return 1; return 1;
} }


@@ -90,11 +98,6 @@ static int speex_packet(AVFormatContext *s, int idx)
struct speex_params *spxp = os->private; struct speex_params *spxp = os->private;
int packet_size = s->streams[idx]->codec->frame_size; int packet_size = s->streams[idx]->codec->frame_size;


if (!spxp) {
spxp = av_mallocz(sizeof(*spxp));
os->private = spxp;
}

if (os->flags & OGG_FLAG_EOS && os->lastpts != AV_NOPTS_VALUE && if (os->flags & OGG_FLAG_EOS && os->lastpts != AV_NOPTS_VALUE &&
os->granule > 0) { os->granule > 0) {
/* first packet of final page. we have to calculate the final packet /* first packet of final page. we have to calculate the final packet


+ 8
- 7
libavformat/oggparsevorbis.c View File

@@ -166,23 +166,24 @@ vorbis_header (AVFormatContext * s, int idx)
struct ogg_stream *os = ogg->streams + idx; struct ogg_stream *os = ogg->streams + idx;
AVStream *st = s->streams[idx]; AVStream *st = s->streams[idx];
struct oggvorbis_private *priv; struct oggvorbis_private *priv;
int pkt_type = os->buf[os->pstart];


if (os->seq > 2)
if (!(pkt_type & 1))
return 0; return 0;


if (os->seq == 0) {
if (!os->private) {
os->private = av_mallocz(sizeof(struct oggvorbis_private)); os->private = av_mallocz(sizeof(struct oggvorbis_private));
if (!os->private) if (!os->private)
return 0; return 0;
} }


if (os->psize < 1)
if (os->psize < 1 || pkt_type > 5)
return -1; return -1;


priv = os->private; priv = os->private;
priv->len[os->seq] = os->psize;
priv->packet[os->seq] = av_mallocz(os->psize);
memcpy(priv->packet[os->seq], os->buf + os->pstart, os->psize);
priv->len[pkt_type >> 1] = os->psize;
priv->packet[pkt_type >> 1] = av_mallocz(os->psize);
memcpy(priv->packet[pkt_type >> 1], os->buf + os->pstart, os->psize);
if (os->buf[os->pstart] == 1) { if (os->buf[os->pstart] == 1) {
const uint8_t *p = os->buf + os->pstart + 7; /* skip "\001vorbis" tag */ const uint8_t *p = os->buf + os->pstart + 7; /* skip "\001vorbis" tag */
unsigned blocksize, bs0, bs1; unsigned blocksize, bs0, bs1;
@@ -224,7 +225,7 @@ vorbis_header (AVFormatContext * s, int idx)
fixup_vorbis_headers(s, priv, &st->codec->extradata); fixup_vorbis_headers(s, priv, &st->codec->extradata);
} }


return os->seq < 3;
return 1;
} }


const struct ogg_codec ff_vorbis_codec = { const struct ogg_codec ff_vorbis_codec = {


Loading…
Cancel
Save