]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/vorbis_parser.c
avcodec/vp9: make last_invisible local.
[ffmpeg] / libavcodec / vorbis_parser.c
index fcbecc89e93ec45fd43e48122a273a4a396a3e7c..1e2cab3927a9cbbe9f03ece9e9b2f7702a661b4e 100644 (file)
@@ -201,8 +201,8 @@ int avpriv_vorbis_parse_extradata(AVCodecContext *avctx, VorbisParseContext *s)
     return 0;
 }
 
-int avpriv_vorbis_parse_frame(VorbisParseContext *s, const uint8_t *buf,
-                              int buf_size)
+int avpriv_vorbis_parse_frame_flags(VorbisParseContext *s, const uint8_t *buf,
+                                    int buf_size, int *flags)
 {
     int duration = 0;
 
@@ -211,6 +211,22 @@ int avpriv_vorbis_parse_frame(VorbisParseContext *s, const uint8_t *buf,
         int previous_blocksize = s->previous_blocksize;
 
         if (buf[0] & 1) {
+            /* If the user doesn't care about special packets, it's a bad one. */
+            if (!flags)
+                goto bad_packet;
+
+            /* Set the flag for which kind of special packet it is. */
+            if (buf[0] == 1)
+                *flags |= VORBIS_FLAG_HEADER;
+            else if (buf[0] == 3)
+                *flags |= VORBIS_FLAG_COMMENT;
+            else
+                goto bad_packet;
+
+            /* Special packets have no duration. */
+            return 0;
+
+bad_packet:
             av_log(s->avctx, AV_LOG_ERROR, "Invalid packet\n");
             return AVERROR_INVALIDDATA;
         }
@@ -234,6 +250,12 @@ int avpriv_vorbis_parse_frame(VorbisParseContext *s, const uint8_t *buf,
     return duration;
 }
 
+int avpriv_vorbis_parse_frame(VorbisParseContext *s, const uint8_t *buf,
+                              int buf_size)
+{
+    return avpriv_vorbis_parse_frame_flags(s, buf, buf_size, NULL);
+}
+
 void avpriv_vorbis_parse_reset(VorbisParseContext *s)
 {
     if (s->valid_extradata)