]> git.tue.mpg.de Git - paraslash.git/commitdiff
mp4: Merge membuffer_write_std_tag() into create_ilst().
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 21 Aug 2021 17:28:52 +0000 (19:28 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 30 May 2022 19:37:36 +0000 (21:37 +0200)
The former is short and is only called by the latter.

mp4.c

diff --git a/mp4.c b/mp4.c
index 91b5195675dd5b9325972fb6cfb561f499f9a82f..653e0f409560f75b476fcfa5a910639bfd7f98ec 100644 (file)
--- a/mp4.c
+++ b/mp4.c
@@ -1116,24 +1116,6 @@ static void membuffer_write_int32(struct membuffer *buf, uint32_t data)
        membuffer_write(buf, temp, 4);
 }
 
-static void membuffer_write_std_tag(struct membuffer *buf, const char *name,
-               const char *value)
-{
-       uint32_t len = strlen(value);
-       membuffer_write_int32(buf, 8 /* atom header */
-               + 8 /* data atom header */
-               + 8 /* flags + reserved */
-               + len);
-       membuffer_write_atom_name(buf, name);
-       membuffer_write_int32(buf, 8 /* data atom header */
-               + 8 /* flags + reserved */
-               + len);
-       membuffer_write_atom_name(buf, "data");
-       membuffer_write_int32(buf, 1);  /* flags */
-       membuffer_write_int32(buf, 0);  /* reserved */
-       membuffer_write(buf, value, len);
-}
-
 static unsigned membuffer_get_size(const struct membuffer *buf)
 {
        return buf->written;
@@ -1153,7 +1135,9 @@ static void *create_ilst(const struct mp4_metadata *meta, uint32_t *out_size)
 
        for (n = 0; n < meta->count; n++) {
                struct mp4_tag *tag = meta->tags + n;
+               unsigned len = strlen(tag->value);
                const char *atom_name;
+
                if (!strcasecmp(tag->item, "title"))
                        atom_name = "\xA9" "nam";
                else if (!strcasecmp(tag->item, "artist"))
@@ -1166,7 +1150,18 @@ static void *create_ilst(const struct mp4_metadata *meta, uint32_t *out_size)
                        atom_name = "\xA9" "cmt";
                else
                        assert(false);
-               membuffer_write_std_tag(buf, atom_name, tag->value);
+               membuffer_write_int32(buf, 8 /* atom header */
+                       + 8 /* data atom header */
+                       + 8 /* flags + reserved */
+                       + len);
+               membuffer_write_atom_name(buf, atom_name);
+               membuffer_write_int32(buf, 8 /* data atom header */
+                       + 8 /* flags + reserved */
+                       + len);
+               membuffer_write_atom_name(buf, "data");
+               membuffer_write_int32(buf, 1);  /* flags */
+               membuffer_write_int32(buf, 0);  /* reserved */
+               membuffer_write(buf, tag->value, len);
        }
        *out_size = membuffer_get_size(buf);
        return membuffer_detach(buf);