From: Zhao Zhili <quinkblack@foxmail.com> To: ffmpeg-devel@ffmpeg.org Cc: Zhao Zhili <zhilizhao@tencent.com> Subject: [FFmpeg-devel] [PATCH 2/2] avformat/mov: fix encryption index in the case of multiple trun Date: Sun, 31 Jul 2022 01:14:12 +0800 Message-ID: <tencent_8D6615109766EFE7E4AABFD3061C424BBC06@qq.com> (raw) In-Reply-To: <20220730171412.600-1-quinkblack@foxmail.com> From: Zhao Zhili <zhilizhao@tencent.com> frag_stream_info->index_entry isn't the first sample/trun index. cenc.frag_index_entry_base failed to catch the case since current_index > 0. Fix ticket #9807. --- libavformat/isom.h | 3 ++- libavformat/mov.c | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/libavformat/isom.h b/libavformat/isom.h index f05c2d9c28..c6365f2f48 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -135,6 +135,8 @@ typedef struct MOVFragmentStreamInfo { int64_t first_tfra_pts; int64_t tfdt_dts; int64_t next_trun_dts; + // Index of the first sample/trun in the fragment. + int index_base; int index_entry; MOVEncryptionIndex *encryption_index; } MOVFragmentStreamInfo; @@ -253,7 +255,6 @@ typedef struct MOVStreamContext { struct { struct AVAESCTR* aes_ctr; struct AVAES *aes_ctx; - unsigned int frag_index_entry_base; unsigned int per_sample_iv_size; // Either 0, 8, or 16. AVEncryptionInfo *default_encrypted_sample; MOVEncryptionIndex *encryption_index; diff --git a/libavformat/mov.c b/libavformat/mov.c index ce12a9e4f1..23d9bb4af1 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1369,6 +1369,7 @@ static int update_frag_index(MOVContext *c, int64_t offset) frag_stream_info[i].tfdt_dts = AV_NOPTS_VALUE; frag_stream_info[i].next_trun_dts = AV_NOPTS_VALUE; frag_stream_info[i].first_tfra_pts = AV_NOPTS_VALUE; + frag_stream_info[i].index_base = -1; frag_stream_info[i].index_entry = -1; frag_stream_info[i].encryption_index = NULL; } @@ -5125,8 +5126,11 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom) sc->ctts_count = sti->nb_index_entries; // Record the index_entry position in frag_index of this fragment - if (frag_stream_info) + if (frag_stream_info) { frag_stream_info->index_entry = index_entry_pos; + if (frag_stream_info->index_base < 0) + frag_stream_info->index_base = index_entry_pos; + } if (index_entry_pos > 0) prev_dts = sti->index_entries[index_entry_pos-1].timestamp; @@ -7134,9 +7138,7 @@ static int cenc_filter(MOVContext *mov, AVStream* st, MOVStreamContext *sc, AVPa // Note this only supports encryption info in the first sample descriptor. if (mov->fragment.stsd_id == 1) { if (frag_stream_info->encryption_index) { - if (!current_index && frag_stream_info->index_entry) - sc->cenc.frag_index_entry_base = frag_stream_info->index_entry; - encrypted_index = current_index - (frag_stream_info->index_entry - sc->cenc.frag_index_entry_base); + encrypted_index = current_index - frag_stream_info->index_base; encryption_index = frag_stream_info->encryption_index; } else { encryption_index = sc->cenc.encryption_index; -- 2.34.1 _______________________________________________ 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".
parent reply other threads:[~2022-07-30 17:15 UTC|newest] Thread overview: expand[flat|nested] mbox.gz Atom feed [parent not found: <20220730171412.600-1-quinkblack@foxmail.com>]
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=tencent_8D6615109766EFE7E4AABFD3061C424BBC06@qq.com \ --to=quinkblack@foxmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=zhilizhao@tencent.com \ /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