diff --git a/libavformat/isom.h b/libavformat/isom.h index cd70c0305a..f5d03b20eb 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -103,7 +103,8 @@ typedef struct MOVStreamContext { unsigned *stps_data; ///< partial sync sample for mpeg-2 open gop int ctts_index; int ctts_sample; - unsigned int sample_size; + unsigned int sample_size; ///< may contain value calculated from stsd or value from stsz atom + unsigned int alt_sample_size; ///< always contains sample size from stsz atom unsigned int sample_count; int *sample_sizes; unsigned int keyframe_count; diff --git a/libavformat/mov.c b/libavformat/mov.c index 372005c75f..4541a6ec18 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1644,6 +1644,7 @@ static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom) sample_size = avio_rb32(pb); if (!sc->sample_size) /* do not overwrite value computed in stsd */ sc->sample_size = sample_size; + sc->alt_sample_size = sample_size; field_size = 32; } else { sample_size = 0; @@ -1874,7 +1875,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st) } if (keyframe) distance = 0; - sample_size = sc->sample_size > 0 ? sc->sample_size : sc->sample_sizes[current_sample]; + sample_size = sc->alt_sample_size > 0 ? sc->alt_sample_size : sc->sample_sizes[current_sample]; if (sc->pseudo_stream_id == -1 || sc->stsc_data[stsc_index].id - 1 == sc->pseudo_stream_id) { AVIndexEntry *e = &st->index_entries[st->nb_index_entries++];