From: Andre Noll Date: Mon, 23 Aug 2021 19:12:27 +0000 (+0200) Subject: mp4: Simplify mp4_meta_update(). X-Git-Tag: v0.7.1~7^2~27 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=6cf3ea460106de7086a024f762a2231b0d73514a;p=paraslash.git mp4: Simplify mp4_meta_update(). Move duplicated common code out of the if/else branches and kill a pointless variable. --- diff --git a/mp4.c b/mp4.c index b2cc8e29..398a3dcf 100644 --- a/mp4.c +++ b/mp4.c @@ -999,24 +999,15 @@ int32_t mp4_meta_update(struct mp4 *f) mp4_close(f); return 0; } - /* copy moov atom to end of the file */ if (f->last_atom != ATOM_MOOV) { - char *free_data = "free"; - - /* rename old moov to free */ set_position(f, f->moov_offset + 4); - write_data(f, free_data, 4); - - set_position(f, f->file_size); - write_int32(f, new_moov_size + 8); - write_data(f, "moov", 4); - write_data(f, new_moov_data, new_moov_size); - } else { + write_data(f, "free", 4); /* rename old moov to free */ + set_position(f, f->file_size); /* write new moov atom at EOF */ + } else /* overwrite old moov atom */ set_position(f, f->moov_offset); - write_int32(f, new_moov_size + 8); - write_data(f, "moov", 4); - write_data(f, new_moov_data, new_moov_size); - } + write_int32(f, new_moov_size + 8); + write_data(f, "moov", 4); + write_data(f, new_moov_data, new_moov_size); free(new_moov_data); f->cb->truncate(f->cb->user_data); return 1;