summaryrefslogtreecommitdiffstats
path: root/contrib/ffmpeg/A08-mov-audio-fallback.patch
blob: c8581aba64910e781da90ab27b32aa8ae2687f19 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
diff -ur libav-v11.3-0-g00abc00-orig/libavcodec/avcodec.h libav-v11.3-0-g00abc00/libavcodec/avcodec.h
--- libav-v11.3-0-g00abc00-orig/libavcodec/avcodec.h	2015-03-08 18:51:11.000000000 -0700
+++ libav-v11.3-0-g00abc00/libavcodec/avcodec.h	2015-11-05 08:29:24.381723633 -0800
@@ -917,6 +917,14 @@
      * Stereoscopic 3D information in form of the AVStereo3D struct.
      */
     AV_PKT_DATA_STEREO3D,
+
+    /**
+     * This side data contains an integer value representing the stream index
+     * of a "fallback" track.  A fallback track indicates an alternate
+     * track to use when the current track can not be decoded for some reason.
+     * e.g. no decoder available for codec.
+     */
+    AV_PKT_DATA_FALLBACK_TRACK,
 };
 
 typedef struct AVPacketSideData {
Only in libav-v11.3-0-g00abc00/libavcodec: avcodec.h.orig
diff -ur libav-v11.3-0-g00abc00-orig/libavformat/avformat.h libav-v11.3-0-g00abc00/libavformat/avformat.h
--- libav-v11.3-0-g00abc00-orig/libavformat/avformat.h	2015-03-08 18:51:11.000000000 -0700
+++ libav-v11.3-0-g00abc00/libavformat/avformat.h	2015-11-05 08:28:54.944222066 -0800
@@ -1361,6 +1361,16 @@
 AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c);
 
 /**
+ * Allocate new information from stream.
+ *
+ * @param stream stream
+ * @param type desired side information type
+ * @param size side information size
+ * @return pointer to fresh allocated data or NULL otherwise
+ */
+uint8_t *av_stream_new_side_data(AVStream *stream,
+                                 enum AVPacketSideDataType type, int size);
+/**
  * Get side information from stream.
  *
  * @param stream stream
Only in libav-v11.3-0-g00abc00/libavformat: avformat.h.orig
Only in libav-v11.3-0-g00abc00/libavformat: internal.h.orig
Only in libav-v11.3-0-g00abc00/libavformat: mov.c.orig
diff -ur libav-v11.3-0-g00abc00-orig/libavformat/movenc.c libav-v11.3-0-g00abc00/libavformat/movenc.c
--- libav-v11.3-0-g00abc00-orig/libavformat/movenc.c	2015-03-08 18:51:11.000000000 -0700
+++ libav-v11.3-0-g00abc00/libavformat/movenc.c	2015-11-05 08:28:54.949222151 -0800
@@ -2211,10 +2211,21 @@
             mov->tracks[i].tref_id  = mov->tracks[mov->chapter_track].track_id;
         }
     for (i = 0; i < mov->nb_streams; i++) {
-        if (mov->tracks[i].tag == MKTAG('r','t','p',' ')) {
-            mov->tracks[i].tref_tag = MKTAG('h','i','n','t');
-            mov->tracks[i].tref_id =
-                mov->tracks[mov->tracks[i].src_track].track_id;
+        MOVTrack *track = &mov->tracks[i];
+        if (track->tag == MKTAG('r','t','p',' ')) {
+            track->tref_tag = MKTAG('h','i','n','t');
+            track->tref_id = mov->tracks[track->src_track].track_id;
+        } else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) {
+            int * fallback, size;
+            fallback = (int*)av_stream_get_side_data(track->st,
+                                                     AV_PKT_DATA_FALLBACK_TRACK,
+                                                     &size);
+            if (fallback != NULL && size == sizeof(int)) {
+                if (*fallback >= 0 && *fallback < mov->nb_streams) {
+                    track->tref_tag = MKTAG('f','a','l','l');
+                    track->tref_id = mov->tracks[*fallback].track_id;
+                }
+            }
         }
     }
 
Only in libav-v11.3-0-g00abc00/libavformat: movenc.c.orig
Only in libav-v11.3-0-g00abc00/libavformat: replaygain.c.orig
diff -ur libav-v11.3-0-g00abc00-orig/libavformat/utils.c libav-v11.3-0-g00abc00/libavformat/utils.c
--- libav-v11.3-0-g00abc00-orig/libavformat/utils.c	2015-03-08 18:51:11.000000000 -0700
+++ libav-v11.3-0-g00abc00/libavformat/utils.c	2015-11-05 08:32:19.646709922 -0800
@@ -3126,3 +3126,41 @@
     }
     return NULL;
 }
+
+uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type,
+                                 int size)
+{
+    AVPacketSideData *sd, *tmp;
+    int i;
+    uint8_t *data = av_malloc(size);
+
+    if (!data)
+        return NULL;
+
+    for (i = 0; i < st->nb_side_data; i++) {
+        sd = &st->side_data[i];
+
+        if (sd->type == type) {
+            av_freep(&sd->data);
+            sd->data = data;
+            sd->size = size;
+            return sd->data;
+        }
+    }
+
+    tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp));
+    if (!tmp) {
+        av_freep(&data);
+        return NULL;
+    }
+
+    st->side_data = tmp;
+    st->nb_side_data++;
+
+    sd = &st->side_data[st->nb_side_data - 1];
+    sd->type = type;
+    sd->data = data;
+    sd->size = size;
+    return data;
+}
+
Only in libav-v11.3-0-g00abc00/libavformat: utils.c.orig