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 187DA424EC for ; Tue, 29 Mar 2022 18:05:10 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 274C768B124; Tue, 29 Mar 2022 21:05:08 +0300 (EEST) Received: from out203-205-221-239.mail.qq.com (out203-205-221-239.mail.qq.com [203.205.221.239]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A9B4D68B008 for ; Tue, 29 Mar 2022 21:04:59 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1648577094; bh=cWlMVmBw1gXu/qvzMOAw/6V//69m0aCsZ18OWiMyBZA=; h=From:To:Cc:Subject:Date; b=YCQDfhWYVoEdnvOA3f3k7E+gjiSmSf25i0tCztCt+VGndqg+cfJ6QUFDPqhwygdC0 Ei3CIR+rIDgyD5y6cD/311AxBmByICWIlBkOFTGjhvEXzRkqZqAOKYqgwjAH059mqO ImqMvhc0VVYdveIGZLRujl48V6vTgAomiwrMgEwY= Received: from ZHILIZHAO-MB2.tencent.com ([119.123.72.193]) by newxmesmtplogicsvrsza8.qq.com (NewEsmtp) with SMTP id 134AEC28; Wed, 30 Mar 2022 02:04:52 +0800 X-QQ-mid: xmsmtpt1648577092t5oze3wor Message-ID: X-QQ-XMAILINFO: Nq7sfrZZD4JfNFZiUwz40vfS8tHr462+RblUag09M7TFLy9blgapOuOwKrFNfA qicTFU/TMOE+jN5DdGGcLjzajcpIVjp81SpCIe8R62yKH2XEaW9y//x8Hjxk0tvp7YVrljAYogli udTayrYtyadlEJPsiwJbnhKlUTQ6xmmmtn0PME/Fx50aTk/Rc7lKEyP4d+716T4Pk/4Hp5zGPslA 5N1EwLERWE2ikQxyFz6fWlvdT0WKT0Yce6jXCSMNwmFdfwBITPE2pgFx4XbYDoCYO6L4RpZoziA9 PAkxwKQCbEvpGJYkBP7vQT85+oiLFQp+drLbk5Cdgq6y5tVBhQSNFmwe5VyssIajEfERN9zdJZIF hx/JnEakKWMB6GRV5+oQmxsSpu8+LjwsLS4CnlrRBLGZ4jBcV8pkIyz7sSsfSIdneqsBuPg9atKP fipizJF7PXt/uFFkGVZdyxMloYHoGhF4Plgaw0u10YVXxKCyGTk9Pavw1SCmsRrm/8BPKaCgOf01 dQ5UVAvFgNTZgrXEkKpARH3wGXB4EFogo5M1aDRDmHw2snfiE4vZHITVS39eYg4C2HAhMO1jPN7s jBPvUYKjnHJwdLshorR8sPiTOoNt6Os0Ktpc+yjlwlc5xbDrDeC8cjaWFYnawpe1NNo8vbqvZehp tKDmee3Bldapdt5kAtOQYV7alLsll+ecqFgtPXQkbxGkc6yRcJQ95jXmvhcVe42KJTH+Yls7EO/H Sdm2cqA5e6epRMV5AXO/39U8Xn73H2OvE52hlOlgq7gKODneLuWZCXqqZB1+k+/T3+R2RavcoDR8 W9oU1EPDlI+2SR+bK+dMXLoP9ydFm3hluvuGaNnPQRlVv19HIluJLbRj6aJ/0OkFadbtSA9RgPU2 wtCTgq5kfUag4rH3lDWfQ9hMI3E8mWecraHsJAXNkJLaFHFKpRjljZ81E14XAjnoLOOz7AqaT9DN dW0yM1szQ= From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Wed, 30 Mar 2022 02:04:46 +0800 X-OQ-MSGID: <20220329180446.84184-1-quinkblack@foxmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/mov: fix missing extra data updating 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: The stsc_index is checked and updated for the next sample. If the next sample needs to update stsd_index and stsc_index, then only stsc_index is updated, which leads to a missing AV_PKT_DATA_NEW_EXTRADATA. For example, the sample in the second chunk needs to update both. entry[0] first_chunk = 1 samples_per_chunk = 3 sample_description_index = 1 entry[1] first_chunk = 2 samples_per_chunk = 1 sample_description_index = 2 entry[2] first_chunk = 3 samples_per_chunk = 8 sample_description_index = 2 The fix is simple: first check and update stsd_index for current sample, then check and update stsc_index for the next. --- libavformat/mov.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 6c847de164..c9d4f2ef43 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -8591,20 +8591,20 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) /* Multiple stsd handling. */ if (sc->stsc_data) { - /* Keep track of the stsc index for the given sample, then check - * if the stsd index is different from the last used one. */ + if (sc->stsc_data[sc->stsc_index].id > 0 && + sc->stsc_data[sc->stsc_index].id - 1 < sc->stsd_count && + sc->stsc_data[sc->stsc_index].id - 1 != sc->last_stsd_index) { + ret = mov_change_extradata(sc, pkt); + if (ret < 0) + return ret; + } + + /* Update the stsc index for the next sample */ sc->stsc_sample++; if (mov_stsc_index_valid(sc->stsc_index, sc->stsc_count) && mov_get_stsc_samples(sc, sc->stsc_index) == sc->stsc_sample) { sc->stsc_index++; sc->stsc_sample = 0; - /* Do not check indexes after a switch. */ - } else if (sc->stsc_data[sc->stsc_index].id > 0 && - sc->stsc_data[sc->stsc_index].id - 1 < sc->stsd_count && - sc->stsc_data[sc->stsc_index].id - 1 != sc->last_stsd_index) { - ret = mov_change_extradata(sc, pkt); - if (ret < 0) - return ret; } } -- 2.31.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".