From 6cf3ea460106de7086a024f762a2231b0d73514a Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 23 Aug 2021 21:12:27 +0200 Subject: [PATCH] mp4: Simplify mp4_meta_update(). Move duplicated common code out of the if/else branches and kill a pointless variable. --- mp4.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) 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; -- 2.39.5