]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/blobdiff - libavformat/mp3.c
frsh: Export information about the last RTP contract and VRES
[frescor/ffmpeg.git] / libavformat / mp3.c
index 857661ba6043412fc6861faad6c6d8444dea1f37..e835a3442420061f0ea5c11325b93ccefaf3cdf5 100644 (file)
@@ -170,16 +170,14 @@ static unsigned int id3v2_get_size(ByteIOContext *s, int len)
 static void id3v2_read_ttag(AVFormatContext *s, int taglen, const char *key)
 {
     char *q, dst[512];
-    int len, dstlen = sizeof(dst);
+    int len, dstlen = sizeof(dst) - 1;
     unsigned genre;
 
-    if(dstlen > 0)
-        dst[0]= 0;
+    dst[0]= 0;
     if(taglen < 1)
         return;
 
     taglen--; /* account for encoding type byte */
-    dstlen--; /* Leave space for zero terminator */
 
     switch(get_byte(s->pb)) { /* encoding type */
 
@@ -200,7 +198,8 @@ static void id3v2_read_ttag(AVFormatContext *s, int taglen, const char *key)
     }
 
     if (!strcmp(key, "genre")
-        && sscanf(dst, "(%d)", &genre) == 1 && genre <= ID3v1_GENRE_MAX)
+        && (sscanf(dst, "(%d)", &genre) == 1 || sscanf(dst, "%d", &genre) == 1)
+        && genre <= ID3v1_GENRE_MAX)
         av_strlcpy(dst, id3v1_genre_str[genre], sizeof(dst));
 
     if (*dst)
@@ -392,9 +391,11 @@ static int mp3_read_probe(AVProbeData *p)
     }
     if   (first_frames>=3) return AVPROBE_SCORE_MAX/2+1;
     else if(max_frames>500)return AVPROBE_SCORE_MAX/2;
-    else if(max_frames>=3) return AVPROBE_SCORE_MAX/4;
+    else if(max_frames>=4) return AVPROBE_SCORE_MAX/4;
+    else if(buf0!=p->buf)  return AVPROBE_SCORE_MAX/4-1;
     else if(max_frames>=1) return 1;
     else                   return 0;
+//mpegps_mp3_unrecognized_format.mpg has max_frames=3
 }
 
 /**
@@ -555,14 +556,14 @@ static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
         count++;
     }
     if ((tag = av_metadata_get(s->metadata, "genre", NULL, 0))) {
-    for(i = 0; i <= ID3v1_GENRE_MAX; i++) {
-        if (!strcasecmp(tag->value, id3v1_genre_str[i])) {
-            buf[127] = i;
-            count++;
-            break;
+        for(i = 0; i <= ID3v1_GENRE_MAX; i++) {
+            if (!strcasecmp(tag->value, id3v1_genre_str[i])) {
+                buf[127] = i;
+                count++;
+                break;
+            }
         }
     }
-    }
     return count;
 }
 
@@ -658,7 +659,7 @@ static int mp3_write_trailer(struct AVFormatContext *s)
 #if CONFIG_MP3_DEMUXER
 AVInputFormat mp3_demuxer = {
     "mp3",
-    NULL_IF_CONFIG_SMALL("MPEG audio"),
+    NULL_IF_CONFIG_SMALL("MPEG audio layer 2/3"),
     0,
     mp3_read_probe,
     mp3_read_header,