From: Andre Noll Date: Sat, 14 Aug 2021 17:38:21 +0000 (+0200) Subject: mp4: Clean up membuffer_write_std_tag(). X-Git-Tag: v0.7.1~7^2~77 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=a23c7f2c797ac29ed76db5059b00e3b8e5e2042a;p=paraslash.git mp4: Clean up membuffer_write_std_tag(). Remove the check for the compilation flag since we never pass "cpil" to this function. Remove the flags variable whose value is now always one. Introduce a variable for the string length instead of calling strlen() three times, and unify the way comments are formatted. --- diff --git a/mp4.c b/mp4.c index 3167a132..9ea65d07 100644 --- a/mp4.c +++ b/mp4.c @@ -1206,24 +1206,19 @@ static unsigned membuffer_write_int32(struct membuffer *buf, uint32_t data) static void membuffer_write_std_tag(struct membuffer *buf, const char *name, const char *value) { - uint32_t flags = 1; - - /* special check for compilation flag */ - if (strcmp(name, "cpil") == 0) { - flags = 21; - } - - membuffer_write_int32(buf, - 8 /*atom header */ + 8 /*data atom header */ + - 8 /*flags + reserved */ + strlen(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 */ + strlen(value)); + membuffer_write_int32(buf, 8 /* data atom header */ + + 8 /* flags + reserved */ + + len); membuffer_write_atom_name(buf, "data"); - membuffer_write_int32(buf, flags); //flags - membuffer_write_int32(buf, 0); //reserved - membuffer_write(buf, value, strlen(value)); + membuffer_write_int32(buf, 1); /* flags */ + membuffer_write_int32(buf, 0); /* reserved */ + membuffer_write(buf, value, len); } static unsigned membuffer_error(const struct membuffer *buf)