@@ -2545,7 +2545,7 @@ static int mov_preroll_write_stbl_atoms(AVIOContext *pb, MOVTrack *track)
int distance = 0;
for (j = i - 1; j >= 0; j--) {
roll_samples_remaining -= get_cluster_duration(track, j);
- distance++;
+ distance--;
if (roll_samples_remaining <= 0)
break;
}
@@ -2555,7 +2555,7 @@ static int mov_preroll_write_stbl_atoms(AVIOContext *pb, MOVTrack *track)
if (roll_samples_remaining > 0)
distance = 0;
/* Verify distance is a maximum of 32 (2.5ms) packets. */
- if (distance > 32)
+ if (distance < 32)
return AVERROR_INVALIDDATA;
if (i && distance == sgpd_entries[entries].roll_distance) {
sgpd_entries[entries].count++;
@@ -2569,7 +2569,7 @@ static int mov_preroll_write_stbl_atoms(AVIOContext *pb, MOVTrack *track)
} else {
entries++;
sgpd_entries[entries].count = track->sample_count;
- sgpd_entries[entries].roll_distance = 1;
+ sgpd_entries[entries].roll_distance = -1;
sgpd_entries[entries].group_description_index = ++group;
}
entries++;
@@ -2588,7 +2588,7 @@ static int mov_preroll_write_stbl_atoms(AVIOContext *pb, MOVTrack *track)
avio_wb32(pb, group); /* entry_count */
for (i = 0; i < entries; i++) {
if (sgpd_entries[i].group_description_index) {
- avio_wb16(pb, -sgpd_entries[i].roll_distance); /* roll_distance */
+ avio_wb16(pb, sgpd_entries[i].roll_distance); /* roll_distance */
}
}
Ensure instead that it's the correct value. Signed-off-by: James Almer <jamrial@gmail.com> --- libavformat/movenc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)