]> git.tue.mpg.de Git - paraslash.git/commitdiff
mp4: Simplify mp4_meta_update().
authorAndre Noll <maan@tuebingen.mpg.de>
Mon, 23 Aug 2021 19:12:27 +0000 (21:12 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 30 May 2022 19:37:36 +0000 (21:37 +0200)
Move duplicated common code out of the if/else branches and kill a
pointless variable.

mp4.c

diff --git a/mp4.c b/mp4.c
index b2cc8e290faeaf254855000cb6259bc821b5f7eb..398a3dcf888472704429220b2d53549b0f157fbc 100644 (file)
--- 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;