summaryrefslogtreecommitdiffstats
path: root/contrib/ffmpeg/old/A12-mov-initial_padding.patch
blob: 61ca8190743b62055292f67252ba4e71642c9e72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
From 70deb2f2c99677e91b8a404882d9bb0db1791efa Mon Sep 17 00:00:00 2001
From: John Stebbins <stebbins@jetheaddev.com>
Date: Tue, 21 Feb 2017 10:46:02 -0700
Subject: [PATCH] mov: extract audio initial_padding from edit list

---
 libavformat/mov.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 1657647..a080216 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3806,13 +3806,24 @@ static int mov_read_header(AVFormatContext *s)
         MOVStreamContext *sc = st->priv_data;
 
         switch (st->codecpar->codec_type) {
-        case AVMEDIA_TYPE_AUDIO:
+        case AVMEDIA_TYPE_AUDIO: {
+            int64_t skip_samples;
             err = ff_replaygain_export(st, s->metadata);
             if (err < 0) {
                 mov_read_close(s);
                 return err;
             }
+            skip_samples = av_rescale(sc->time_offset_skip,
+                                      st->codecpar->sample_rate,
+                                      sc->time_scale);
+            /* If the number of skipped samples specified in the edit list
+             * is in a range that looks like an initial_padding, set
+             * initial_padding to tell decoders to drop the samples */
+            if (skip_samples > 0 && skip_samples <= 3840) {
+                st->codecpar->initial_padding = skip_samples;
+            }
             break;
+        }
         case AVMEDIA_TYPE_VIDEO:
             if (sc->display_matrix) {
                 err = av_stream_add_side_data(st, AV_PKT_DATA_DISPLAYMATRIX,
-- 
2.9.3