diff mbox

[FFmpeg-devel,2/2] avformat/apetag: account for header size if present when returning the start position

Message ID 20170210175049.5660-2-jamrial@gmail.com
State Accepted
Commit 84d874a680ff647bc84de44967b638f246a8b832
Headers show

Commit Message

James Almer Feb. 10, 2017, 5:50 p.m. UTC
The size field in the header/footer accounts for the entire APE tag
structure except the 32 bytes from header, for compatibility with
APEv1.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/apetag.c | 6 +++++-
 libavformat/apetag.h | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

Comments

Paul B Mahol Feb. 10, 2017, 9:23 p.m. UTC | #1
On 2/10/17, James Almer <jamrial@gmail.com> wrote:
> The size field in the header/footer accounts for the entire APE tag
> structure except the 32 bytes from header, for compatibility with
> APEv1.
>
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavformat/apetag.c | 6 +++++-
>  libavformat/apetag.h | 1 +
>  2 files changed, 6 insertions(+), 1 deletion(-)
>

probably ok
James Almer Feb. 10, 2017, 9:36 p.m. UTC | #2
On 2/10/2017 6:23 PM, Paul B Mahol wrote:
> On 2/10/17, James Almer <jamrial@gmail.com> wrote:
>> The size field in the header/footer accounts for the entire APE tag
>> structure except the 32 bytes from header, for compatibility with
>> APEv1.
>>
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>>  libavformat/apetag.c | 6 +++++-
>>  libavformat/apetag.h | 1 +
>>  2 files changed, 6 insertions(+), 1 deletion(-)
>>
> 
> probably ok

Pushed.
diff mbox

Patch

diff --git a/libavformat/apetag.c b/libavformat/apetag.c
index a05b32d9e5..b23f8cdd1f 100644
--- a/libavformat/apetag.c
+++ b/libavformat/apetag.c
@@ -150,7 +150,6 @@  int64_t ff_ape_parse_tag(AVFormatContext *s)
         av_log(s, AV_LOG_ERROR, "Invalid tag size %"PRIu32".\n", tag_bytes);
         return 0;
     }
-    tag_start = file_size - tag_bytes - APE_TAG_FOOTER_BYTES;
 
     fields = avio_rl32(pb);    /* number of fields */
     if (fields > 65536) {
@@ -166,6 +165,11 @@  int64_t ff_ape_parse_tag(AVFormatContext *s)
 
     avio_seek(pb, file_size - tag_bytes, SEEK_SET);
 
+    if (val & APE_TAG_FLAG_CONTAINS_HEADER)
+        tag_bytes += APE_TAG_HEADER_BYTES;
+
+    tag_start = file_size - tag_bytes;
+
     for (i=0; i<fields; i++)
         if (ape_tag_read_field(s) < 0) break;
 
diff --git a/libavformat/apetag.h b/libavformat/apetag.h
index cf2a5f8ab4..49cd10eb01 100644
--- a/libavformat/apetag.h
+++ b/libavformat/apetag.h
@@ -28,6 +28,7 @@ 
 #define APE_TAG_PREAMBLE        "APETAGEX"
 #define APE_TAG_VERSION         2000
 #define APE_TAG_FOOTER_BYTES    32
+#define APE_TAG_HEADER_BYTES    32
 
 /**
  * Read and parse an APE tag