From: 汪亚强 <wangyaqian...@kuaishou.com>

detect only audio formats where the tag might exist.

For example, if an rgb rawvideo data starts with ID3,

 it will cause the packet data to be missing by 10 bytes,

causing a transcoding error.

Signed-off-by: 汪亚强 <wangyaqian...@kuaishou.com>
---
 libavformat/demux.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/demux.c b/libavformat/demux.c
index 0e39346f62..d9c9766d51 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -299,9 +299,10 @@ int avformat_open_input(AVFormatContext **ps, const char 
*filename,
                 goto fail;
         }
     }
-
+    int id3v2_check = (!strcmp(s->iformat->name, "mp3") || 
!strcmp(s->iformat->name, "aac") ||
+                       !strcmp(s->iformat->name, "tta") || 
!strcmp(s->iformat->name, "wav"));
     /* e.g. AVFMT_NOFILE formats will not have an AVIOContext */
-    if (s->pb)
+    if (s->pb && id3v2_check)
         ff_id3v2_read_dict(s->pb, &si->id3v2_meta, ID3v2_DEFAULT_MAGIC, 
&id3v2_extra_meta);
 
     if (ffifmt(s->iformat)->read_header)
@@ -320,8 +321,7 @@ int avformat_open_input(AVFormatContext **ps, const char 
*filename,
     }
 
     if (id3v2_extra_meta) {
-        if (!strcmp(s->iformat->name, "mp3") || !strcmp(s->iformat->name, 
"aac") ||
-            !strcmp(s->iformat->name, "tta") || !strcmp(s->iformat->name, 
"wav")) {
+        if (id3v2_check) {
             if ((ret = ff_id3v2_parse_apic(s, id3v2_extra_meta)) < 0)
                 goto close;
             if ((ret = ff_id3v2_parse_chapters(s, id3v2_extra_meta)) < 0)
-- 
2.39.3 (Apple Git-146)

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to