Skip to content

Commit

Permalink
Update code to use pkt_type
Browse files Browse the repository at this point in the history
Just like FFmpeg.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
  • Loading branch information
felipec committed Sep 11, 2010
1 parent 406ee99 commit a7cd19c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions gstavdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,19 @@ vorbis_header(GstAVDec *self,
{
const uint8_t *p = GST_BUFFER_DATA(buf);
struct oggvorbis_private *priv = &self->priv;
int pkt_type = *p;

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

if (GST_BUFFER_SIZE(buf) < 1)
if (GST_BUFFER_SIZE(buf) < 1 || pkt_type > 5)
return -1;

priv->len[self->seq] = GST_BUFFER_SIZE(buf);
priv->packet[self->seq] = g_malloc0(GST_BUFFER_SIZE(buf));
memcpy(priv->packet[self->seq], GST_BUFFER_DATA(buf), GST_BUFFER_SIZE(buf));
priv->len[pkt_type >> 1] = GST_BUFFER_SIZE(buf);
priv->packet[pkt_type >> 1] = g_malloc0(GST_BUFFER_SIZE(buf));
memcpy(priv->packet[pkt_type >> 1], GST_BUFFER_DATA(buf), GST_BUFFER_SIZE(buf));

if (p[0] == 1) {
if (pkt_type == 1) {
/* tag */
unsigned blocksize, bs0, bs1;
p += 7; /* skip "\001vorbis" tag */
Expand Down Expand Up @@ -99,7 +100,7 @@ vorbis_header(GstAVDec *self,
if (GST_READ_UINT8(p) != 1)
return -1;
}
else if (p[0] == 3) {
else if (pkt_type == 3) {
/* comment */
handle_comment(self, buf);
}
Expand All @@ -109,7 +110,7 @@ vorbis_header(GstAVDec *self,
fixup_vorbis_headers(&self->priv, &self->av_ctx->extradata);
}

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

static inline void
Expand Down

0 comments on commit a7cd19c

Please sign in to comment.