Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhao Zhili <quinkblack@foxmail.com>2022-03-29 21:04:46 +0300
committerZhao Zhili <zhilizhao@tencent.com>2022-04-27 15:14:18 +0300
commitd114f064c6e9294d6cd0453a51cac584120e6799 (patch)
tree4227e218bdd4d48b49311b7c7fe7516ed363a001 /libavformat/mov.c
parent79286d3eb64b5ce56e30d88f2d34692adb3fcaf0 (diff)
avformat/mov: fix missing extra data updating
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. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Diffstat (limited to 'libavformat/mov.c')
-rw-r--r--libavformat/mov.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 26aeeaea0c..9fc6595507 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -8745,20 +8745,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;
}
}