]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/oggparsevorbis.c
Check mp3 header before calling avpriv_mpegaudio_decode_header().
[ffmpeg] / libavformat / oggparsevorbis.c
index c19b54552c9a5b3688ce601aa74de20fd9cbf6ae..58cb4a67fc72cae67d67cdc549087f3939c94b4e 100644 (file)
@@ -36,6 +36,7 @@
 #include "internal.h"
 #include "oggdec.h"
 #include "vorbiscomment.h"
+#include "replaygain.h"
 
 static int ogm_chapter(AVFormatContext *as, uint8_t *key, uint8_t *val)
 {
@@ -71,7 +72,8 @@ static int ogm_chapter(AVFormatContext *as, uint8_t *key, uint8_t *val)
 }
 
 int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
-                      const uint8_t *buf, int size)
+                      const uint8_t *buf, int size,
+                      int parse_picture)
 {
     const uint8_t *p   = buf;
     const uint8_t *end = buf + size;
@@ -136,7 +138,7 @@ int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
              * 'METADATA_BLOCK_PICTURE'. This is the preferred and
              * recommended way of embedding cover art within VorbisComments."
              */
-            if (!strcmp(tt, "METADATA_BLOCK_PICTURE")) {
+            if (!strcmp(tt, "METADATA_BLOCK_PICTURE") && parse_picture) {
                 int ret;
                 char *pict = av_malloc(vl);
 
@@ -304,9 +306,15 @@ static int vorbis_header(AVFormatContext *s, int idx)
     } else if (os->buf[os->pstart] == 3) {
         if (os->psize > 8 &&
             ff_vorbis_comment(s, &st->metadata, os->buf + os->pstart + 7,
-                              os->psize - 8) >= 0) {
+                              os->psize - 8, 1) >= 0) {
+            unsigned new_len;
+
+            int ret = ff_replaygain_export(st, st->metadata);
+            if (ret < 0)
+                return ret;
+
             // drop all metadata we parsed and which is not required by libvorbis
-            unsigned new_len = 7 + 4 + AV_RL32(priv->packet[1] + 7) + 4 + 1;
+            new_len = 7 + 4 + AV_RL32(priv->packet[1] + 7) + 4 + 1;
             if (new_len >= 16 && new_len < os->psize) {
                 AV_WL32(priv->packet[1] + new_len - 5, 0);
                 priv->packet[1][new_len - 1] = 1;