From: Andre Noll Date: Sat, 21 Aug 2021 17:28:52 +0000 (+0200) Subject: mp4: Merge membuffer_write_std_tag() into create_ilst(). X-Git-Tag: v0.7.1~7^2~37 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=12c165a1282e3b2e80c2247e14cdfcea9fd0cf4c;p=paraslash.git mp4: Merge membuffer_write_std_tag() into create_ilst(). The former is short and is only called by the latter. --- diff --git a/mp4.c b/mp4.c index 91b51956..653e0f40 100644 --- 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);