]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/mp3.c
Set cur_dts to 0 only during creating new streams and not every time cur_dts happens
[ffmpeg] / libavformat / mp3.c
index 5d6af0f9b676a7b9bec7a1703cf57967739a9248..e987904f6a85772cd5330960138e2b2a5f99c481 100644 (file)
  * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
+
+#include "libavutil/avstring.h"
+#include "libavcodec/mpegaudio.h"
+#include "libavcodec/mpegaudiodecheader.h"
 #include "avformat.h"
-#include "mpegaudio.h"
-#include "avstring.h"
-#include "mpegaudiodecheader.h"
 
 #define ID3v2_HEADER_SIZE 10
 #define ID3v1_TAG_SIZE 128
@@ -160,7 +161,7 @@ static const char *id3v1_genre_str[ID3v1_GENRE_MAX + 1] = {
 /* buf must be ID3v2_HEADER_SIZE byte long */
 static int id3v2_match(const uint8_t *buf)
 {
-    return (buf[0] == 'I' &&
+    return  buf[0] == 'I' &&
             buf[1] == 'D' &&
             buf[2] == '3' &&
             buf[3] != 0xff &&
@@ -168,7 +169,7 @@ static int id3v2_match(const uint8_t *buf)
             (buf[6] & 0x80) == 0 &&
             (buf[7] & 0x80) == 0 &&
             (buf[8] & 0x80) == 0 &&
-            (buf[9] & 0x80) == 0);
+            (buf[9] & 0x80) == 0;
 }
 
 static unsigned int id3v2_get_size(ByteIOContext *s, int len)
@@ -184,6 +185,8 @@ static void id3v2_read_ttag(AVFormatContext *s, int taglen, char *dst, int dstle
     char *q;
     int len;
 
+    if(dstlen > 0)
+        dst[0]= 0;
     if(taglen < 1)
         return;
 
@@ -202,7 +205,7 @@ static void id3v2_read_ttag(AVFormatContext *s, int taglen, char *dst, int dstle
         break;
 
     case 3:  /* UTF-8 */
-        len = FFMIN(taglen, dstlen);
+        len = FFMIN(taglen, dstlen-1);
         get_buffer(s->pb, dst, len);
         dst[len] = 0;
         break;
@@ -548,11 +551,6 @@ static int mp3_read_packet(AVFormatContext *s, AVPacket *pkt)
     return ret;
 }
 
-static int mp3_read_close(AVFormatContext *s)
-{
-    return 0;
-}
-
 #ifdef CONFIG_MUXERS
 /* simple formats */
 
@@ -564,7 +562,7 @@ static void id3v2_put_size(AVFormatContext *s, int size)
     put_byte(s->pb, size       & 0x7f);
 }
 
-static void id3v2_put_ttag(AVFormatContext *s, char *string, uint32_t tag)
+static void id3v2_put_ttag(AVFormatContext *s, const char *string, uint32_t tag)
 {
     int len = strlen(string);
     put_be32(s->pb, tag);
@@ -645,12 +643,11 @@ static int mp3_write_trailer(struct AVFormatContext *s)
 #ifdef CONFIG_MP3_DEMUXER
 AVInputFormat mp3_demuxer = {
     "mp3",
-    "MPEG audio",
+    NULL_IF_CONFIG_SMALL("MPEG audio"),
     0,
     mp3_read_probe,
     mp3_read_header,
     mp3_read_packet,
-    mp3_read_close,
     .flags= AVFMT_GENERIC_INDEX,
     .extensions = "mp2,mp3,m2a", /* XXX: use probe */
 };
@@ -658,7 +655,7 @@ AVInputFormat mp3_demuxer = {
 #ifdef CONFIG_MP2_MUXER
 AVOutputFormat mp2_muxer = {
     "mp2",
-    "MPEG audio layer 2",
+    NULL_IF_CONFIG_SMALL("MPEG audio layer 2"),
     "audio/x-mpeg",
 #ifdef CONFIG_LIBMP3LAME
     "mp2,m2a",
@@ -667,7 +664,7 @@ AVOutputFormat mp2_muxer = {
 #endif
     0,
     CODEC_ID_MP2,
-    0,
+    CODEC_ID_NONE,
     NULL,
     mp3_write_packet,
     mp3_write_trailer,
@@ -676,12 +673,12 @@ AVOutputFormat mp2_muxer = {
 #ifdef CONFIG_MP3_MUXER
 AVOutputFormat mp3_muxer = {
     "mp3",
-    "MPEG audio layer 3",
+    NULL_IF_CONFIG_SMALL("MPEG audio layer 3"),
     "audio/x-mpeg",
     "mp3",
     0,
     CODEC_ID_MP3,
-    0,
+    CODEC_ID_NONE,
     mp3_write_header,
     mp3_write_packet,
     mp3_write_trailer,