OSDN Git Service

import 0.9.3
[handbrake-jp/handbrake-jp.git] / contrib / patch-mpeg4ip-colr.patch
1 diff -Nur -x Makefile -x config.log -x config.status -x libtool -x '*.Plo' -x '*.lo' ../handbrake/contrib/mpeg4ip/lib/mp4v2/Makefile.am mpeg4ip/lib/mp4v2/Makefile.am
2 --- ../handbrake/contrib/mpeg4ip/lib/mp4v2/Makefile.am  2008-06-13 11:22:55.000000000 -0700
3 +++ mpeg4ip/lib/mp4v2/Makefile.am       2008-06-17 16:21:54.000000000 -0700
4 @@ -14,6 +14,7 @@
5         atom_amr.cpp \
6         atom_avc1.cpp \
7         atom_avcC.cpp \
8 +       atom_colr.cpp \
9         atom_d263.cpp \
10         atom_damr.cpp \
11         atom_dref.cpp \
12 diff -Nur -x Makefile -x config.log -x config.status -x libtool -x '*.Plo' -x '*.lo' ../handbrake/contrib/mpeg4ip/lib/mp4v2/Makefile.in mpeg4ip/lib/mp4v2/Makefile.in
13 --- ../handbrake/contrib/mpeg4ip/lib/mp4v2/Makefile.in  2008-06-13 11:22:55.000000000 -0700
14 +++ mpeg4ip/lib/mp4v2/Makefile.in       2008-06-17 16:21:54.000000000 -0700
15 @@ -53,7 +53,7 @@
16  LTLIBRARIES = $(lib_LTLIBRARIES)
17  libmp4v2_la_LIBADD =
18  am_libmp4v2_la_OBJECTS = 3gp.lo atom_amr.lo atom_avc1.lo atom_avcC.lo \
19 -       atom_d263.lo atom_damr.lo atom_dref.lo atom_elst.lo \
20 +       atom_colr.lo atom_d263.lo atom_damr.lo atom_dref.lo atom_elst.lo \
21         atom_enca.lo atom_encv.lo atom_free.lo atom_ftyp.lo \
22         atom_gmin.lo atom_text.lo atom_ac3.lo \
23         atom_hdlr.lo atom_hinf.lo atom_hnti.lo atom_href.lo \
24 @@ -76,6 +76,7 @@
25  @AMDEP_TRUE@   ./$(DEPDIR)/atom_ac3.Plo \
26  @AMDEP_TRUE@   ./$(DEPDIR)/atom_avc1.Plo \
27  @AMDEP_TRUE@   ./$(DEPDIR)/atom_avcC.Plo \
28 +@AMDEP_TRUE@   ./$(DEPDIR)/atom_colr.Plo \
29  @AMDEP_TRUE@   ./$(DEPDIR)/atom_d263.Plo \
30  @AMDEP_TRUE@   ./$(DEPDIR)/atom_damr.Plo \
31  @AMDEP_TRUE@   ./$(DEPDIR)/atom_dref.Plo \
32 @@ -347,6 +348,7 @@
33         atom_amr.cpp \
34         atom_avc1.cpp \
35         atom_avcC.cpp \
36 +       atom_colr.cpp \
37         atom_d263.cpp \
38         atom_damr.cpp \
39         atom_dref.cpp \
40 @@ -503,6 +505,7 @@
41  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_amr.Plo@am__quote@
42  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_avc1.Plo@am__quote@
43  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_avcC.Plo@am__quote@
44 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_colr.Plo@am__quote@
45  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_d263.Plo@am__quote@
46  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_damr.Plo@am__quote@
47  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_dref.Plo@am__quote@
48 diff -Nur -x Makefile -x config.log -x config.status -x libtool -x '*.Plo' -x '*.lo' ../handbrake/contrib/mpeg4ip/lib/mp4v2/atom_colr.cpp mpeg4ip/lib/mp4v2/atom_colr.cpp
49 --- ../handbrake/contrib/mpeg4ip/lib/mp4v2/atom_colr.cpp        1969-12-31 16:00:00.000000000 -0800
50 +++ mpeg4ip/lib/mp4v2/atom_colr.cpp     2008-06-18 13:51:37.000000000 -0700
51 @@ -0,0 +1,45 @@
52 +/*
53 + * The contents of this file are subject to the Mozilla Public
54 + * License Version 1.1 (the "License"); you may not use this file
55 + * except in compliance with the License. You may obtain a copy of
56 + * the License at http://www.mozilla.org/MPL/
57 + * 
58 + * Software distributed under the License is distributed on an "AS
59 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
60 + * implied. See the License for the specific language governing
61 + * rights and limitations under the License.
62 + * 
63 + * The Original Code is MPEG4IP.
64 + * 
65 + * Contributer has declined to give copyright information, and gives
66 + * it freely to the world.
67 + * 
68 + * Contributor(s): 
69 + */
70 +
71 +#include "mp4common.h"
72 +
73 +MP4ColrAtom::MP4ColrAtom() 
74 +       : MP4Atom("colr") 
75 +{
76 +    MP4StringProperty* cpt = new MP4StringProperty("colorParameterType");
77 +    cpt->SetFixedLength(4);
78 +    AddProperty(cpt); /* 0 */
79 +
80 +       AddProperty( /* 1 */ new MP4Integer16Property("primariesIndex"));
81 +
82 +       AddProperty( /* 2 */ new MP4Integer16Property("transferFunctionIndex")); 
83 +
84 +       AddProperty( /* 3 */ new MP4Integer16Property("matrixIndex")); 
85 +}
86 +
87 +void MP4ColrAtom::Generate()
88 +{
89 +       MP4Atom::Generate();
90 +
91 +       ((MP4StringProperty*)m_pProperties[0])->SetValue("nclc");
92 +    // default to ITU BT.709 values
93 +       ((MP4Integer16Property*)m_pProperties[1])->SetValue(1);
94 +       ((MP4Integer16Property*)m_pProperties[2])->SetValue(1);
95 +       ((MP4Integer16Property*)m_pProperties[3])->SetValue(1);
96 +}
97 diff -Nur -x Makefile -x config.log -x config.status -x libtool -x '*.Plo' -x '*.lo' ../handbrake/contrib/mpeg4ip/lib/mp4v2/atom_stsd.cpp mpeg4ip/lib/mp4v2/atom_stsd.cpp
98 --- ../handbrake/contrib/mpeg4ip/lib/mp4v2/atom_stsd.cpp        2008-06-13 11:22:55.000000000 -0700
99 +++ mpeg4ip/lib/mp4v2/atom_stsd.cpp     2008-06-17 16:21:54.000000000 -0700
100 @@ -52,6 +52,7 @@
101         ExpectChildAtom("text", Optional, Many);
102         ExpectChildAtom("pasp", Optional, Many);
103         ExpectChildAtom("ac-3", Optional, Many);
104 +       ExpectChildAtom("colr", Optional, Many);
105  }
106  
107  void MP4StsdAtom::Read() 
108 diff -Nur -x Makefile -x config.log -x config.status -x libtool -x '*.Plo' -x '*.lo' ../handbrake/contrib/mpeg4ip/lib/mp4v2/atoms.h mpeg4ip/lib/mp4v2/atoms.h
109 --- ../handbrake/contrib/mpeg4ip/lib/mp4v2/atoms.h      2008-06-13 11:22:55.000000000 -0700
110 +++ mpeg4ip/lib/mp4v2/atoms.h   2008-06-17 16:21:54.000000000 -0700
111 @@ -406,4 +406,10 @@
112      void Generate();
113  };
114  
115 +class MP4ColrAtom : public MP4Atom {
116 + public:
117 +    MP4ColrAtom();
118 +    void Generate();
119 +};
120 +
121  #endif /* __MP4_ATOMS_INCLUDED__ */
122 diff -Nur -x Makefile -x config.log -x config.status -x libtool -x '*.Plo' -x '*.lo' ../handbrake/contrib/mpeg4ip/lib/mp4v2/mp4.cpp mpeg4ip/lib/mp4v2/mp4.cpp
123 --- ../handbrake/contrib/mpeg4ip/lib/mp4v2/mp4.cpp      2008-06-13 11:22:55.000000000 -0700
124 +++ mpeg4ip/lib/mp4v2/mp4.cpp   2008-06-17 16:21:54.000000000 -0700
125 @@ -1003,6 +1003,21 @@
126         return MP4_INVALID_TRACK_ID;
127  }
128  
129 +extern "C" MP4TrackId MP4AddColr(
130 +       MP4FileHandle hFile, MP4TrackId refTrackId, u_int16_t pri, u_int16_t tran, u_int16_t mat)
131 +{
132 +       if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
133 +               try {
134 +                       return ((MP4File*)hFile)->AddColr(refTrackId, pri, tran, mat);
135 +               }
136 +               catch (MP4Error* e) {
137 +                       PRINT_ERROR(e);
138 +                       delete e;
139 +               }
140 +       }
141 +       return MP4_INVALID_TRACK_ID;
142 +}
143 +
144  
145  extern "C" MP4TrackId MP4CloneTrack(
146         MP4FileHandle srcFile, 
147 diff -Nur -x Makefile -x config.log -x config.status -x libtool -x '*.Plo' -x '*.lo' ../handbrake/contrib/mpeg4ip/lib/mp4v2/mp4.h mpeg4ip/lib/mp4v2/mp4.h
148 --- ../handbrake/contrib/mpeg4ip/lib/mp4v2/mp4.h        2008-06-13 11:22:55.000000000 -0700
149 +++ mpeg4ip/lib/mp4v2/mp4.h     2008-06-18 14:03:17.000000000 -0700
150 @@ -559,6 +559,13 @@
151      u_int32_t hSpacing,
152      u_int32_t vSpacing);
153  
154 +MP4TrackId MP4AddColr(
155 +       MP4FileHandle hFile, 
156 +       MP4TrackId refTrackId,
157 +    u_int16_t primary,
158 +    u_int16_t transfer,
159 +    u_int16_t matrix);
160 +
161  MP4TrackId MP4CloneTrack(
162         MP4FileHandle srcFile, 
163         MP4TrackId srcTrackId,
164 diff -Nur -x Makefile -x config.log -x config.status -x libtool -x '*.Plo' -x '*.lo' ../handbrake/contrib/mpeg4ip/lib/mp4v2/mp4atom.cpp mpeg4ip/lib/mp4v2/mp4atom.cpp
165 --- ../handbrake/contrib/mpeg4ip/lib/mp4v2/mp4atom.cpp  2008-06-13 11:22:55.000000000 -0700
166 +++ mpeg4ip/lib/mp4v2/mp4atom.cpp       2008-06-17 16:21:54.000000000 -0700
167 @@ -90,6 +90,8 @@
168      case 'c':
169        if (ATOMID(type) == ATOMID("chap")) {
170         pAtom = new MP4TrefTypeAtom(type);
171 +      } else if (ATOMID(type) == ATOMID("colr")) {
172 +       pAtom = new MP4ColrAtom();
173           }
174           break;
175  
176 diff -Nur -x Makefile -x config.log -x config.status -x libtool -x '*.Plo' -x '*.lo' ../handbrake/contrib/mpeg4ip/lib/mp4v2/mp4file.cpp mpeg4ip/lib/mp4v2/mp4file.cpp
177 --- ../handbrake/contrib/mpeg4ip/lib/mp4v2/mp4file.cpp  2008-06-13 11:22:55.000000000 -0700
178 +++ mpeg4ip/lib/mp4v2/mp4file.cpp       2008-06-17 16:21:54.000000000 -0700
179 @@ -2000,6 +2000,33 @@
180         return trackId;
181  }
182  
183 +MP4TrackId MP4File::AddColr(MP4TrackId trackId,
184 +                            u_int16_t primariesIndex,
185 +                            u_int16_t transferFunctionIndex,
186 +                            u_int16_t matrixIndex)
187 +{
188 +       // validate reference track id
189 +  (void)FindTrackIndex(trackId);
190 +    const char *format = GetTrackMediaDataName (trackId);
191 +    
192 +    if (!strcasecmp(format, "avc1"))
193 +    {
194 +        AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.avc1"), "colr");
195 +        SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.avc1.colr.primariesIndex", primariesIndex);
196 +        SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.avc1.colr.transferFunctionIndex", transferFunctionIndex);
197 +        SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.avc1.colr.matrixIndex", matrixIndex);
198 +    }
199 +    else if (!strcasecmp(format, "mp4v"))
200 +    {
201 +        AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.mp4v"), "colr");
202 +        SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.mp4v.colr.primariesIndex", primariesIndex);
203 +        SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.mp4v.colr.transferFunctionIndex", transferFunctionIndex);
204 +        SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.mp4v.colr.matrixIndex", matrixIndex);
205 +    }
206 +
207 +       return trackId;
208 +}
209 +
210  void MP4File::DeleteTrack(MP4TrackId trackId)
211  {
212         ProtectWriteOperation("MP4DeleteTrack");
213 diff -Nur -x Makefile -x config.log -x config.status -x libtool -x '*.Plo' -x '*.lo' ../handbrake/contrib/mpeg4ip/lib/mp4v2/mp4file.h mpeg4ip/lib/mp4v2/mp4file.h
214 --- ../handbrake/contrib/mpeg4ip/lib/mp4v2/mp4file.h    2008-06-13 11:22:55.000000000 -0700
215 +++ mpeg4ip/lib/mp4v2/mp4file.h 2008-06-17 16:21:54.000000000 -0700
216 @@ -305,6 +305,7 @@
217         MP4TrackId AddChapterTextTrack(MP4TrackId refTrackId);
218  
219         MP4TrackId AddPixelAspectRatio(MP4TrackId trackId, u_int32_t hSpacing, u_int32_t vSpacing);
220 +       MP4TrackId AddColr(MP4TrackId trackId, u_int16_t pri, u_int16_t tran, u_int16_t mat);
221  
222         MP4SampleId GetTrackNumberOfSamples(MP4TrackId trackId);
223