diff mbox series

[FFmpeg-devel] avformat/mov: stop ignoring subtitle packets durations

Message ID 20220221113025.421154-1-onemda@gmail.com
State New
Headers show
Series [FFmpeg-devel] avformat/mov: stop ignoring subtitle packets durations | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_aarch64_jetson success Make finished
andriy/make_fate_aarch64_jetson success Make fate finished
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished

Commit Message

Paul B Mahol Feb. 21, 2022, 11:30 a.m. UTC
Fixes #7855

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavformat/mov.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 5e26267810..d980996086 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4359,7 +4359,8 @@  static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     av_freep(&sc->chunk_offsets);
     av_freep(&sc->sample_sizes);
     av_freep(&sc->keyframes);
-    av_freep(&sc->stts_data);
+    if (st->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE)
+        av_freep(&sc->stts_data);
     av_freep(&sc->stps_data);
     av_freep(&sc->elst_data);
     av_freep(&sc->rap_group);
@@ -8323,6 +8324,11 @@  static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
     pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? AV_PKT_FLAG_KEY : 0;
     pkt->pos = sample->pos;
 
+    if (sc->stts_data && st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+        if (sc->current_index <= sc->stts_count && sc->current_index > 0)
+            pkt->duration = sc->stts_data[sc->current_index - 1].duration;
+    }
+
     /* Multiple stsd handling. */
     if (sc->stsc_data) {
         /* Keep track of the stsc index for the given sample, then check