summaryrefslogtreecommitdiff
path: root/libavformat/id3v2.h
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-05-19 11:43:48 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-05-25 06:56:57 +0200
commitf08853b284514820d42f81999f4adb09ff5d95b4 (patch)
tree4cef43e6f9b2bcc6cacd8a2d10b8c01c73615256 /libavformat/id3v2.h
parent1ebbb493cced1af3fc891618e2573c7bc5ed7e70 (diff)
avformat/id3v2: Avoid allocations for ID3v2ExtraMeta
Up until now, the ID3v2ExtraMeta structure (which is used when parsing ID3v2 tags containing attached pictures, chapters etc.) contained a pointer to separately allocated data that depended on the type of the tag. Yet the difference of the sizes of the largest and the smallest of these structures is fairly small, so that it is better to simply include a union of all the possible types of tag-dependent structures in ID3v2ExtraMeta. This commit implements this. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavformat/id3v2.h')
-rw-r--r--libavformat/id3v2.h17
1 files changed, 11 insertions, 6 deletions
diff --git a/libavformat/id3v2.h b/libavformat/id3v2.h
index 9de0bee374..3e6030c942 100644
--- a/libavformat/id3v2.h
+++ b/libavformat/id3v2.h
@@ -54,12 +54,6 @@ typedef struct ID3v2EncContext {
int len; ///< size of the tag written so far
} ID3v2EncContext;
-typedef struct ID3v2ExtraMeta {
- const char *tag;
- void *data;
- struct ID3v2ExtraMeta *next;
-} ID3v2ExtraMeta;
-
typedef struct ID3v2ExtraMetaGEOB {
uint32_t datasize;
uint8_t *mime_type;
@@ -87,6 +81,17 @@ typedef struct ID3v2ExtraMetaCHAP {
AVDictionary *meta;
} ID3v2ExtraMetaCHAP;
+typedef struct ID3v2ExtraMeta {
+ const char *tag;
+ struct ID3v2ExtraMeta *next;
+ union {
+ ID3v2ExtraMetaAPIC apic;
+ ID3v2ExtraMetaCHAP chap;
+ ID3v2ExtraMetaGEOB geob;
+ ID3v2ExtraMetaPRIV priv;
+ } data;
+} ID3v2ExtraMeta;
+
/**
* Detect ID3v2 Header.
* @param buf must be ID3v2_HEADER_SIZE byte long