]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/ape.c
Prevent invalid timestamps from being stored.
[ffmpeg] / libavformat / ape.c
index f05ecf46edf6ab18b68a9d45c052b3af8c75b7f3..4c5d0461e28e5d82b28559168c6ac60e0bc49d9f 100644 (file)
 
 #include "avformat.h"
 
+#define ENABLE_DEBUG 0
+
 /* The earliest and latest file formats supported by this library */
-#define APE_MIN_VERSION 3970
+#define APE_MIN_VERSION 3950
 #define APE_MAX_VERSION 3990
 
 #define MAC_FORMAT_FLAG_8_BIT                 1 // is 8-bit [OBSOLETE]
@@ -48,7 +50,7 @@
 #define TAG(name, field)  {name, offsetof(AVFormatContext, field), sizeof(((AVFormatContext *)0)->field)}
 
 static const struct {
-    char *name;
+    const char *name;
     int offset;
     int size;
 } tags[] = {
@@ -108,7 +110,7 @@ typedef struct {
 
 static void ape_tag_read_field(AVFormatContext *s)
 {
-    ByteIOContext *pb = &s->pb;
+    ByteIOContext *pb = s->pb;
     uint8_t buf[1024];
     uint32_t size;
     int i;
@@ -141,7 +143,7 @@ static void ape_tag_read_field(AVFormatContext *s)
 
 static void ape_parse_tag(AVFormatContext *s)
 {
-    ByteIOContext *pb = &s->pb;
+    ByteIOContext *pb = s->pb;
     int file_size = url_fsize(pb);
     uint32_t val, fields, tag_bytes;
     uint8_t buf[8];
@@ -154,7 +156,6 @@ static void ape_parse_tag(AVFormatContext *s)
 
     get_buffer(pb, buf, 8);    /* APETAGEX */
     if (strncmp(buf, "APETAGEX", 8)) {
-        av_log(NULL, AV_LOG_ERROR, "Invalid APE Tags\n");
         return;
     }
 
@@ -190,6 +191,7 @@ static void ape_parse_tag(AVFormatContext *s)
     for (i=0; i<fields; i++)
         ape_tag_read_field(s);
 
+#if ENABLE_DEBUG
     av_log(NULL, AV_LOG_DEBUG, "\nAPE Tags:\n\n");
     av_log(NULL, AV_LOG_DEBUG, "title     = %s\n", s->title);
     av_log(NULL, AV_LOG_DEBUG, "author    = %s\n", s->author);
@@ -199,6 +201,7 @@ static void ape_parse_tag(AVFormatContext *s)
     av_log(NULL, AV_LOG_DEBUG, "year      = %d\n", s->year);
     av_log(NULL, AV_LOG_DEBUG, "track     = %d\n", s->track);
     av_log(NULL, AV_LOG_DEBUG, "genre     = %s\n", s->genre);
+#endif
 }
 
 static int ape_probe(AVProbeData * p)
@@ -211,6 +214,7 @@ static int ape_probe(AVProbeData * p)
 
 static void ape_dumpinfo(APEContext * ape_ctx)
 {
+#if ENABLE_DEBUG
     int i;
 
     av_log(NULL, AV_LOG_DEBUG, "Descriptor Block:\n\n");
@@ -260,11 +264,12 @@ static void ape_dumpinfo(APEContext * ape_ctx)
     av_log(NULL, AV_LOG_DEBUG, "junklength           = %d\n", ape_ctx->junklength);
     av_log(NULL, AV_LOG_DEBUG, "firstframe           = %d\n", ape_ctx->firstframe);
     av_log(NULL, AV_LOG_DEBUG, "totalsamples         = %d\n", ape_ctx->totalsamples);
+#endif
 }
 
 static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap)
 {
-    ByteIOContext *pb = &s->pb;
+    ByteIOContext *pb = s->pb;
     APEContext *ape = s->priv_data;
     AVStream *st;
     uint32_t tag;
@@ -450,12 +455,12 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
     APEContext *ape = s->priv_data;
     uint32_t extra_size = 8;
 
-    if (url_feof(&s->pb))
+    if (url_feof(s->pb))
         return AVERROR_IO;
     if (ape->currentframe > ape->totalframes)
         return AVERROR_IO;
 
-    url_fseek (&s->pb, ape->frames[ape->currentframe].pos, SEEK_SET);
+    url_fseek (s->pb, ape->frames[ape->currentframe].pos, SEEK_SET);
 
     /* Calculate how many blocks there are in this frame */
     if (ape->currentframe == (ape->totalframes - 1))
@@ -468,7 +473,7 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
 
     AV_WL32(pkt->data    , nblocks);
     AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip);
-    ret = get_buffer(&s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size);
+    ret = get_buffer(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size);
 
     pkt->pts = ape->frames[ape->currentframe].pts;
     pkt->stream_index = 0;
@@ -506,7 +511,7 @@ static int ape_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
 
 AVInputFormat ape_demuxer = {
     "ape",
-    "Monkey's Audio",
+    NULL_IF_CONFIG_SMALL("Monkey's Audio"),
     sizeof(APEContext),
     ape_probe,
     ape_read_header,