From: CesarATV <cesaratvgit@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: CesarATV <cesaratvgit@gmail.com> Subject: [FFmpeg-devel] [PATCH] qt-faststart: update co64 chunk offsets when converting stco to co64 Date: Wed, 21 May 2025 16:00:26 +0200 Message-ID: <20250521140026.40891-1-cesaratvgit@gmail.com> (raw) Before this patch, when qt-faststart converted stco atoms to co64, it did so without updating the chunk offsets of pre-existing co64 atoms, resulting in corrupted tracks. This patch ensures that existing co64 chunk offsets are correctly adjusted when such a conversion occurs. Signed-off-by: CesarATV <cesaratvgit@gmail.com> --- tools/qt-faststart.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/qt-faststart.c b/tools/qt-faststart.c index 46950a5cf4..3c3b0890a8 100644 --- a/tools/qt-faststart.c +++ b/tools/qt-faststart.c @@ -218,7 +218,7 @@ static int update_stco_offsets(update_chunk_offsets_context_t *context, atom_t * return 0; } -static int update_co64_offsets(update_chunk_offsets_context_t *context, atom_t *atom) +static int update_co64_offsets(uint64_t offset_increment, atom_t *atom) { uint64_t current_offset; uint32_t offset_count; @@ -241,7 +241,7 @@ static int update_co64_offsets(update_chunk_offsets_context_t *context, atom_t * pos < end; pos += 8) { current_offset = BE_64(pos); - current_offset += context->moov_atom_size; + current_offset += offset_increment; AV_WB64(pos, current_offset); } @@ -258,7 +258,7 @@ static int update_chunk_offsets_callback(void *ctx, atom_t *atom) return update_stco_offsets(context, atom); case CO64_ATOM: - return update_co64_offsets(context, atom); + return update_co64_offsets(context->moov_atom_size, atom); case MOOV_ATOM: case TRAK_ATOM: @@ -359,6 +359,10 @@ static int upgrade_stco_callback(void *ctx, atom_t *atom) set_atom_size(start_pos, atom->header_size, context->dest - start_pos); break; + case CO64_ATOM: + update_co64_offsets(context->new_moov_size - context->original_moov_size, atom); + /* fallthrough */ + default: copy_size = atom->header_size + atom->size; memcpy(context->dest, atom->data - atom->header_size, copy_size); -- 2.43.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
reply other threads:[~2025-05-21 14:00 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20250521140026.40891-1-cesaratvgit@gmail.com \ --to=cesaratvgit@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git