From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 65652407B5 for ; Sat, 30 Jul 2022 17:15:48 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7BCB168BA5B; Sat, 30 Jul 2022 20:15:38 +0300 (EEST) Received: from out162-62-57-210.mail.qq.com (out162-62-57-210.mail.qq.com [162.62.57.210]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 218CE68B8B3 for ; Sat, 30 Jul 2022 20:15:30 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1659201328; bh=eEU0u+HPW6SP8oxEwoPYW+u94h2F2M+L75oljb0n950=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UkHh/OtTuitvZC5YvJlPlv+04ISk2jRIsdbzsjl0+h1QZFSNxkYrI014xslQWNdhW UzaVyWW4Lfd2RMKmc5fSeKvsGfde26KhPvVIfWMs3ybndQRUfxBrgdms5QjCsBoSB+ 2Y+uV6soeb92ebg9GasNv+6IzuzNuBEMmRMkE6qI= Received: from black.localdomain ([113.116.29.125]) by newxmesmtplogicsvrszc10.qq.com (NewEsmtp) with SMTP id 39003A85; Sun, 31 Jul 2022 01:14:16 +0800 X-QQ-mid: xmsmtpt1659201257t0g3sgwdr Message-ID: X-QQ-XMAILINFO: M0PjjqbLT90w5K6yXZBuviwqzEfDHM3RDAE+V6oBmOsK97ZWLWT4wS2X41k9Hr 1pYNFYJ74T3Zfp2XkmKBIstvVFC8PlxpaoEoHX58TfEIp7PcE7ER4szfOZ4g7X/nTi+YPSnHXG8+ ICeZ/TAVdQ10fAeToGtO/Tzcq7SueZeFEgoaxyrFERpNbE6swH2g3GXwfRYxgEHQMV66cjKO9+KU +8ACSyQ8I7ETODIUhzBD55yfltGrI4OW+Zn9QAM1NmOlDZM+b7dqGMelVcHSBCgEWrJ6pVJqeJxw SR6BJsuNvmxbitrkyQDKo5ON1bQeYwmQqqVtm9fMTZURIMN1upIYkGPibZzFqJlP2U1Yd8Qy7TG9 Q0yvITOmMKvqFNOXYEGYvr4I07ljOemhqMHkoAVn5xChAOk3IuJP5fusKFUjTQjBrLb3ZzPbPe56 cENHLVx8eHC4nvKh3+wXqAb/zl4G3hnuRM/CLCT4tmLDErzFPGInt/X51SdveT7SNmK73s8Tdeu5 RxjQEadw/49gehVeBGJUoOrxa+oKoxjq+yNpGTcqRyvwwKWtnWG/nPqdAbuNYZbvli/NO25uOKwY tdsk5rn0cfvvBBwM862iCFGoUNyAuxjlNJYdrK05tgGF1W/CO2QdvRC+BoXigDsrRNQM9u8mDjj2 WMbs/GuLKyvL2oLmkMbQQlYGLZy3wGeemzLHeSRS7nco0V9eLaMY95UkVEqcIC/KY5J0HDCPnjUl RmSj+w4Trbg1Se+ssU3qQ65wq3vwgt0K7BAIQZbGXgaqwS+jkXGRPPsewmxMdYmnrxZNo/2hk5N6 lzOhc7ZFXFs3Gu0CFwEpPMyOrb0bBcu0NNAe3Ceawa59eHuHtRrGLW06VTCLqNkZjwJK450kDBSe SoTEmy6EaAgJZqvn+l9kUj9UiFnxJIvO6JCoti8jKa/IVaVTVXUJGS0QW2ngVQBT9hm0nRiSbx From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Sun, 31 Jul 2022 01:14:12 +0800 X-OQ-MSGID: <20220730171412.600-2-quinkblack@foxmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220730171412.600-1-quinkblack@foxmail.com> References: <20220730171412.600-1-quinkblack@foxmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avformat/mov: fix encryption index in the case of multiple trun X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Zhao Zhili Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Zhao Zhili 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".