OSDN Git Service

Change the fifo size from being statically tuned for a Mac Pro with 4 CPUs to dynamic...
[handbrake-jp/handbrake-jp-git.git] / contrib / patch-mpeg4ip.patch
1 diff -Naur mpeg4ip.orig/lib/mp4v2/Makefile.am mpeg4ip.patched/lib/mp4v2/Makefile.am
2 --- mpeg4ip.orig/lib/mp4v2/Makefile.am  2005-03-10 18:31:34.000000000 +0000
3 +++ mpeg4ip.patched/lib/mp4v2/Makefile.am       2007-03-21 17:55:46.000000000 +0000
4 @@ -21,6 +21,7 @@
5         atom_encv.cpp \
6         atom_free.cpp \
7         atom_ftyp.cpp \
8 +       atom_gmin.cpp \
9         atom_hdlr.cpp \
10         atom_hinf.cpp \
11         atom_hnti.cpp \
12 @@ -45,6 +46,7 @@
13         atom_stsc.cpp \
14         atom_stsd.cpp \
15         atom_stsz.cpp \
16 +       atom_text.cpp \
17         atom_tfhd.cpp \
18         atom_tkhd.cpp \
19         atom_treftype.cpp \
20 diff -Naur mpeg4ip.orig/lib/mp4v2/Makefile.in mpeg4ip.patched/lib/mp4v2/Makefile.in
21 --- mpeg4ip.orig/lib/mp4v2/Makefile.in  2005-05-18 23:03:05.000000000 +0100
22 +++ mpeg4ip.patched/lib/mp4v2/Makefile.in       2007-03-21 17:56:20.000000000 +0000
23 @@ -55,6 +55,7 @@
24  am_libmp4v2_la_OBJECTS = 3gp.lo atom_amr.lo atom_avc1.lo atom_avcC.lo \
25         atom_d263.lo atom_damr.lo atom_dref.lo atom_elst.lo \
26         atom_enca.lo atom_encv.lo atom_free.lo atom_ftyp.lo \
27 +       atom_gmin.lo atom_text.lo \
28         atom_hdlr.lo atom_hinf.lo atom_hnti.lo atom_href.lo \
29         atom_mdat.lo atom_mdhd.lo atom_meta.lo atom_mp4a.lo \
30         atom_mp4s.lo atom_mp4v.lo atom_mvhd.lo atom_root.lo \
31 @@ -82,6 +83,7 @@
32  @AMDEP_TRUE@   ./$(DEPDIR)/atom_encv.Plo \
33  @AMDEP_TRUE@   ./$(DEPDIR)/atom_free.Plo \
34  @AMDEP_TRUE@   ./$(DEPDIR)/atom_ftyp.Plo \
35 +@AMDEP_TRUE@   ./$(DEPDIR)/atom_gmin.Plo \
36  @AMDEP_TRUE@   ./$(DEPDIR)/atom_hdlr.Plo \
37  @AMDEP_TRUE@   ./$(DEPDIR)/atom_hinf.Plo \
38  @AMDEP_TRUE@   ./$(DEPDIR)/atom_hnti.Plo \
39 @@ -103,6 +105,7 @@
40  @AMDEP_TRUE@   ./$(DEPDIR)/atom_stsc.Plo \
41  @AMDEP_TRUE@   ./$(DEPDIR)/atom_stsd.Plo \
42  @AMDEP_TRUE@   ./$(DEPDIR)/atom_stsz.Plo \
43 +@AMDEP_TRUE@   ./$(DEPDIR)/atom_text.Plo \
44  @AMDEP_TRUE@   ./$(DEPDIR)/atom_tfhd.Plo \
45  @AMDEP_TRUE@   ./$(DEPDIR)/atom_tkhd.Plo \
46  @AMDEP_TRUE@   ./$(DEPDIR)/atom_treftype.Plo \
47 @@ -349,6 +352,7 @@
48         atom_encv.cpp \
49         atom_free.cpp \
50         atom_ftyp.cpp \
51 +       atom_gmin.cpp \
52         atom_hdlr.cpp \
53         atom_hinf.cpp \
54         atom_hnti.cpp \
55 @@ -373,6 +377,7 @@
56         atom_stsc.cpp \
57         atom_stsd.cpp \
58         atom_stsz.cpp \
59 +       atom_text.cpp \
60         atom_tfhd.cpp \
61         atom_tkhd.cpp \
62         atom_treftype.cpp \
63 @@ -501,6 +506,7 @@
64  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_encv.Plo@am__quote@
65  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_free.Plo@am__quote@
66  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_ftyp.Plo@am__quote@
67 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_gmin.Plo@am__quote@
68  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_hdlr.Plo@am__quote@
69  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_hinf.Plo@am__quote@
70  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_hnti.Plo@am__quote@
71 @@ -524,6 +530,7 @@
72  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_stsc.Plo@am__quote@
73  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_stsd.Plo@am__quote@
74  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_stsz.Plo@am__quote@
75 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_text.Plo@am__quote@
76  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_tfhd.Plo@am__quote@
77  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_tkhd.Plo@am__quote@
78  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_treftype.Plo@am__quote@
79 diff -Naur mpeg4ip.orig/lib/mp4v2/atom_gmin.cpp mpeg4ip.patched/lib/mp4v2/atom_gmin.cpp
80 --- mpeg4ip.orig/lib/mp4v2/atom_gmin.cpp        1970-01-01 01:00:00.000000000 +0100
81 +++ mpeg4ip.patched/lib/mp4v2/atom_gmin.cpp     2007-03-21 14:41:32.000000000 +0000
82 @@ -0,0 +1,51 @@
83 +/*
84 + * The contents of this file are subject to the Mozilla Public
85 + * License Version 1.1 (the "License"); you may not use this file
86 + * except in compliance with the License. You may obtain a copy of
87 + * the License at http://www.mozilla.org/MPL/
88 + * 
89 + * Software distributed under the License is distributed on an "AS
90 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
91 + * implied. See the License for the specific language governing
92 + * rights and limitations under the License.
93 + * 
94 + * The Original Code is MPEG4IP.
95 + * 
96 + * The Initial Developer of the Original Code is Cisco Systems Inc.
97 + * Portions created by Cisco Systems Inc. are
98 + * Copyright (C) Cisco Systems Inc. 2001.  All Rights Reserved.
99 + * 
100 + * Contributor(s): 
101 + *             Dave Mackie             dmackie@cisco.com
102 + */
103 +
104 +#include "mp4common.h"
105 +
106 +MP4GminAtom::MP4GminAtom() 
107 +       : MP4Atom("gmin") 
108 +{
109 +
110 +       AddVersionAndFlags(); /* 0, 1 */
111 +
112 +       AddProperty(new MP4Integer16Property("graphicsMode")); /* 2 */
113 +       AddProperty(new MP4Integer16Property("opColorRed")); /* 3 */
114 +       AddProperty(new MP4Integer16Property("opColorGreen")); /* 4 */
115 +       AddProperty(new MP4Integer16Property("opColorBlue")); /* 5 */
116 +       AddProperty(new MP4Integer16Property("balance")); /* 6 */
117 +       AddReserved("reserved", 2); /* 7 */
118 +
119 +}
120 +
121 +void MP4GminAtom::Generate()
122 +{
123 +
124 +       MP4Atom::Generate();
125 +
126 +       ((MP4Integer16Property*)m_pProperties[2])->SetValue(0x0040);
127 +       ((MP4Integer16Property*)m_pProperties[3])->SetValue(0x8000);
128 +       ((MP4Integer16Property*)m_pProperties[4])->SetValue(0x8000);
129 +       ((MP4Integer16Property*)m_pProperties[5])->SetValue(0x8000);
130 +       ((MP4Integer16Property*)m_pProperties[6])->SetValue(0x0000);
131 +
132 +}
133 +
134 diff -Naur mpeg4ip.orig/lib/mp4v2/atom_standard.cpp mpeg4ip.patched/lib/mp4v2/atom_standard.cpp
135 --- mpeg4ip.orig/lib/mp4v2/atom_standard.cpp    2004-12-14 21:35:35.000000000 +0000
136 +++ mpeg4ip.patched/lib/mp4v2/atom_standard.cpp 2007-03-21 23:14:04.000000000 +0000
137 @@ -138,6 +138,11 @@
138    /*
139     * g???
140     */
141 +  } else if (ATOMID(type) == ATOMID("gmhd")) { 
142 +    ExpectChildAtom("gmin", Required, OnlyOne);
143 +    ExpectChildAtom("tmcd", Optional, OnlyOne);
144 +    ExpectChildAtom("text", Optional, OnlyOne);
145 +
146    } else if (ATOMID(type) == ATOMID("gnre")) { // Apple iTunes 
147      ExpectChildAtom("data", Optional, OnlyOne);
148  
149 @@ -221,6 +226,7 @@
150      ExpectChildAtom("smhd", Optional, OnlyOne);
151      ExpectChildAtom("hmhd", Optional, OnlyOne);
152      ExpectChildAtom("nmhd", Optional, OnlyOne);
153 +    ExpectChildAtom("gmhd", Optional, OnlyOne);
154      ExpectChildAtom("dinf", Required, OnlyOne);
155      ExpectChildAtom("stbl", Required, OnlyOne);
156  
157 @@ -366,6 +372,7 @@
158      ExpectChildAtom("ipir", Optional, OnlyOne);
159      ExpectChildAtom("mpod", Optional, OnlyOne);
160      ExpectChildAtom("sync", Optional, OnlyOne);
161 +    ExpectChildAtom("chap", Optional, OnlyOne);
162  
163    } else if (ATOMID(type) == ATOMID("trex")) {
164      AddVersionAndFlags();      /* 0, 1 */
165 diff -Naur mpeg4ip.orig/lib/mp4v2/atom_stsd.cpp mpeg4ip.patched/lib/mp4v2/atom_stsd.cpp
166 --- mpeg4ip.orig/lib/mp4v2/atom_stsd.cpp        2004-07-13 22:07:50.000000000 +0100
167 +++ mpeg4ip.patched/lib/mp4v2/atom_stsd.cpp     2007-03-21 17:20:24.000000000 +0000
168 @@ -49,6 +49,7 @@
169         ExpectChildAtom("sawb", Optional, Many); // For AMR-WB
170         ExpectChildAtom("s263", Optional, Many); // For H.263
171         ExpectChildAtom("avc1", Optional, Many);
172 +       ExpectChildAtom("text", Optional, Many);
173  }
174  
175  void MP4StsdAtom::Read() 
176 diff -Naur mpeg4ip.orig/lib/mp4v2/atom_text.cpp mpeg4ip.patched/lib/mp4v2/atom_text.cpp
177 --- mpeg4ip.orig/lib/mp4v2/atom_text.cpp        1970-01-01 01:00:00.000000000 +0100
178 +++ mpeg4ip.patched/lib/mp4v2/atom_text.cpp     2007-03-22 00:35:53.000000000 +0000
179 @@ -0,0 +1,132 @@
180 +/*
181 + * The contents of this file are subject to the Mozilla Public
182 + * License Version 1.1 (the "License"); you may not use this file
183 + * except in compliance with the License. You may obtain a copy of
184 + * the License at http://www.mozilla.org/MPL/
185 + * 
186 + * Software distributed under the License is distributed on an "AS
187 + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
188 + * implied. See the License for the specific language governing
189 + * rights and limitations under the License.
190 + * 
191 + * The Original Code is MPEG4IP.
192 + * 
193 + * The Initial Developer of the Original Code is Cisco Systems Inc.
194 + * Portions created by Cisco Systems Inc. are
195 + * Copyright (C) Cisco Systems Inc. 2001.  All Rights Reserved.
196 + * 
197 + * Contributor(s): 
198 + *             Dave Mackie             dmackie@cisco.com
199 + */
200 +
201 +#include "mp4common.h"
202 +
203 +MP4TextAtom::MP4TextAtom() 
204 +       : MP4Atom("text") 
205 +{
206 +       // The atom type "text" is used in two complete unrelated ways
207 +       // i.e. it's real two atoms with the same name
208 +       // To handle that we need to postpone property creation until
209 +       // we know who our parent atom is (stsd or gmhd) which gives us
210 +       // the context info we need to know who we are
211 +}
212 +
213 +void MP4TextAtom::AddPropertiesStsdType()
214 +{
215 +
216 +       AddReserved("reserved1", 6); /* 0 */
217 +
218 +       AddProperty(new MP4Integer16Property("dataReferenceIndex"));/* 1 */
219 +
220 +       AddProperty(new MP4Integer32Property("displayFlags")); /* 2 */
221 +       AddProperty(new MP4Integer32Property("textJustification")); /* 3 */
222 +
223 +       AddProperty(new MP4Integer16Property("bgColorRed")); /* 4 */
224 +       AddProperty(new MP4Integer16Property("bgColorGreen")); /* 5 */
225 +       AddProperty(new MP4Integer16Property("bgColorBlue")); /* 6 */
226 +
227 +       AddProperty(new MP4Integer16Property("defTextBoxTop")); /* 7 */
228 +       AddProperty(new MP4Integer16Property("defTextBoxLeft")); /* 8 */
229 +       AddProperty(new MP4Integer16Property("defTextBoxBottom")); /* 9 */
230 +       AddProperty(new MP4Integer16Property("defTextBoxRight")); /* 10 */
231 +
232 +       AddReserved("reserved2", 8); /* 11 */
233 +
234 +       AddProperty(new MP4Integer16Property("fontNumber")); /* 12 */
235 +       AddProperty(new MP4Integer16Property("fontFace")); /* 13 */
236 +
237 +       AddReserved("reserved3", 1); /* 14 */
238 +       AddReserved("reserved4", 2); /* 15 */
239 +
240 +       AddProperty(new MP4Integer16Property("foreColorRed")); /* 16 */
241 +       AddProperty(new MP4Integer16Property("foreColorGreen")); /* 17 */
242 +       AddProperty(new MP4Integer16Property("foreColorBlue")); /* 18 */
243 +
244 +}
245 +
246 +void MP4TextAtom::AddPropertiesGmhdType()
247 +{
248 +
249 +       AddProperty(new MP4BytesProperty("textData", 36)); /* 0 */
250 +
251 +}
252 +
253 +
254 +void MP4TextAtom::Generate()
255 +{
256 +
257 +       if (!strcmp(m_pParentAtom->GetType(), "stsd")) {
258 +               AddPropertiesStsdType();
259 +               GenerateStsdType();
260 +       } else if (!strcmp(m_pParentAtom->GetType(), "gmhd")) {
261 +               AddPropertiesGmhdType();
262 +               GenerateGmhdType();
263 +       } else {
264 +               VERBOSE_WARNING(m_pFile->GetVerbosity(),
265 +                       printf("Warning: text atom in unexpected context, can not generate"));
266 +       }
267 +
268 +}
269 +
270 +void MP4TextAtom::GenerateStsdType() 
271 +{
272 +       // generate children
273 +       MP4Atom::Generate();
274 +
275 +       ((MP4Integer16Property*)m_pProperties[1])->SetValue(1);
276 +
277 +       ((MP4Integer32Property*)m_pProperties[2])->SetValue(1);
278 +       ((MP4Integer32Property*)m_pProperties[3])->SetValue(1);
279 +
280 +}
281 +
282 +void MP4TextAtom::GenerateGmhdType() 
283 +{
284 +       MP4Atom::Generate();
285 +
286 +       // property 0 has non-zero fixed values
287 +       static u_int8_t textData[36] = {
288 +               0x00, 0x01, 
289 +               0x00, 0x00,
290 +               0x00, 0x00,
291 +               0x00, 0x00,
292 +               0x00, 0x00, 
293 +               0x00, 0x00,
294 +               0x00, 0x00, 
295 +               0x00, 0x00,
296 +               0x00, 0x01, 
297 +               0x00, 0x00,
298 +               0x00, 0x00, 
299 +               0x00, 0x00,
300 +               0x00, 0x00, 
301 +               0x00, 0x00,
302 +               0x00, 0x00, 
303 +               0x00, 0x00,
304 +               0x40, 0x00, 
305 +               0x00, 0x00, 
306 +       };
307 +       ((MP4BytesProperty*)m_pProperties[0])->SetValue(textData, sizeof(textData));
308 +       
309 +}
310 +
311 +
312 diff -Naur mpeg4ip.orig/lib/mp4v2/atom_tkhd.cpp mpeg4ip.patched/lib/mp4v2/atom_tkhd.cpp
313 --- mpeg4ip.orig/lib/mp4v2/atom_tkhd.cpp        2003-11-19 23:46:11.000000000 +0000
314 +++ mpeg4ip.patched/lib/mp4v2/atom_tkhd.cpp     2007-03-22 00:42:40.000000000 +0000
315 @@ -61,7 +61,8 @@
316         pProp->SetFixed16Format();
317         AddProperty(pProp); /* 8 */
318  
319 -       AddReserved("reserved3", 38); /* 9 */
320 +       /* patched by maurj to enable us to set the matrix for anamorphic display */
321 +       AddProperty(new MP4BytesProperty("reserved3", 38)); /* 9 */
322  
323         pProp = new MP4Float32Property("width");
324         pProp->SetFixed32Format();
325 @@ -106,7 +107,8 @@
326         m_pProperties[9]->SetReadOnly(false);
327         ((MP4BytesProperty*)m_pProperties[9])->
328                 SetValue(reserved3, sizeof(reserved3));
329 -       m_pProperties[9]->SetReadOnly(true);
330 +       /* patched by maurj to enable us to set the matrix for anamorphic display */
331 +       /* m_pProperties[9]->SetReadOnly(true);*/
332  }
333  
334  void MP4TkhdAtom::Read() 
335 diff -Naur mpeg4ip.orig/lib/mp4v2/atoms.h mpeg4ip.patched/lib/mp4v2/atoms.h
336 --- mpeg4ip.orig/lib/mp4v2/atoms.h      2005-03-10 18:31:34.000000000 +0000
337 +++ mpeg4ip.patched/lib/mp4v2/atoms.h   2007-03-22 00:41:38.000000000 +0000
338 @@ -206,6 +206,12 @@
339         void Read();
340  };
341  
342 +class MP4GminAtom : public MP4Atom {
343 +public:
344 +       MP4GminAtom();
345 +       void Generate();
346 +};
347 +
348  class MP4HdlrAtom : public MP4Atom {
349  public:
350         MP4HdlrAtom();
351 @@ -327,6 +333,19 @@
352         void Write();
353  };
354  
355 +class MP4TextAtom : public MP4Atom {
356 +public:
357 +       MP4TextAtom();
358 +       void Generate();
359 +
360 +protected:
361 +       void AddPropertiesStsdType();
362 +       void AddPropertiesGmhdType();
363 +
364 +       void GenerateStsdType();
365 +       void GenerateGmhdType();
366 +};
367 +
368  class MP4TfhdAtom : public MP4Atom {
369  public:
370         MP4TfhdAtom();
371 diff -Naur mpeg4ip.orig/lib/mp4v2/libmp4v260.dsp mpeg4ip.patched/lib/mp4v2/libmp4v260.dsp
372 --- mpeg4ip.orig/lib/mp4v2/libmp4v260.dsp       2005-03-24 22:14:52.000000000 +0000
373 +++ mpeg4ip.patched/lib/mp4v2/libmp4v260.dsp    2007-03-21 17:28:47.000000000 +0000
374 @@ -134,6 +134,10 @@
375  # End Source File
376  # Begin Source File
377  
378 +SOURCE=.\atom_gmin.cpp
379 +# End Source File
380 +# Begin Source File
381 +
382  SOURCE=.\atom_hdlr.cpp
383  # End Source File
384  # Begin Source File
385 @@ -242,6 +246,10 @@
386  # End Source File
387  # Begin Source File
388  
389 +SOURCE=.\atom_text.cpp
390 +# End Source File
391 +# Begin Source File
392 +
393  SOURCE=.\atom_udta.cpp
394  # End Source File
395  # Begin Source File
396 diff -Naur mpeg4ip.orig/lib/mp4v2/libmp4v2_st60.dsp mpeg4ip.patched/lib/mp4v2/libmp4v2_st60.dsp
397 --- mpeg4ip.orig/lib/mp4v2/libmp4v2_st60.dsp    2005-03-24 22:14:52.000000000 +0000
398 +++ mpeg4ip.patched/lib/mp4v2/libmp4v2_st60.dsp 2007-03-21 17:29:12.000000000 +0000
399 @@ -133,6 +133,10 @@
400  # End Source File
401  # Begin Source File
402  
403 +SOURCE=.\atom_gmin.cpp
404 +# End Source File
405 +# Begin Source File
406 +
407  SOURCE=.\atom_hdlr.cpp
408  # End Source File
409  # Begin Source File
410 @@ -241,6 +245,10 @@
411  # End Source File
412  # Begin Source File
413  
414 +SOURCE=.\atom_text.cpp
415 +# End Source File
416 +# Begin Source File
417 +
418  SOURCE=.\atom_udta.cpp
419  # End Source File
420  # Begin Source File
421 diff -Naur mpeg4ip.orig/lib/mp4v2/mp4.cpp mpeg4ip.patched/lib/mp4v2/mp4.cpp
422 --- mpeg4ip.orig/lib/mp4v2/mp4.cpp      2005-03-30 19:41:58.000000000 +0100
423 +++ mpeg4ip.patched/lib/mp4v2/mp4.cpp   2007-03-21 23:40:06.000000000 +0000
424 @@ -939,6 +939,37 @@
425         return MP4_INVALID_TRACK_ID;
426  }
427  
428 +extern "C" MP4TrackId MP4AddTextTrack(
429 +       MP4FileHandle hFile, MP4TrackId refTrackId)
430 +{
431 +       if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
432 +               try {
433 +                       return ((MP4File*)hFile)->AddTextTrack(refTrackId);
434 +               }
435 +               catch (MP4Error* e) {
436 +                       PRINT_ERROR(e);
437 +                       delete e;
438 +               }
439 +       }
440 +       return MP4_INVALID_TRACK_ID;
441 +}
442 +
443 +extern "C" MP4TrackId MP4AddChapterTextTrack(
444 +       MP4FileHandle hFile, MP4TrackId refTrackId)
445 +{
446 +       if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
447 +               try {
448 +                       return ((MP4File*)hFile)->AddChapterTextTrack(refTrackId);
449 +               }
450 +               catch (MP4Error* e) {
451 +                       PRINT_ERROR(e);
452 +                       delete e;
453 +               }
454 +       }
455 +       return MP4_INVALID_TRACK_ID;
456 +}
457 +
458 +
459  extern "C" MP4TrackId MP4CloneTrack(
460         MP4FileHandle srcFile, 
461         MP4TrackId srcTrackId,
462 diff -Naur mpeg4ip.orig/lib/mp4v2/mp4.h mpeg4ip.patched/lib/mp4v2/mp4.h
463 --- mpeg4ip.orig/lib/mp4v2/mp4.h        2005-03-30 19:41:58.000000000 +0100
464 +++ mpeg4ip.patched/lib/mp4v2/mp4.h     2007-03-21 23:32:28.000000000 +0000
465 @@ -100,6 +100,7 @@
466  #define MP4_VIDEO_TRACK_TYPE   "vide"
467  #define MP4_HINT_TRACK_TYPE            "hint"
468  #define MP4_CNTL_TRACK_TYPE     "cntl"
469 +#define MP4_TEXT_TRACK_TYPE            "text"
470  /*
471   * This second set of track types should be created 
472   * via MP4AddSystemsTrack(type)
473 @@ -538,6 +539,14 @@
474         MP4FileHandle hFile, 
475         MP4TrackId refTrackId);
476  
477 +MP4TrackId MP4AddTextTrack(
478 +       MP4FileHandle hFile, 
479 +       MP4TrackId refTrackId);
480 +
481 +MP4TrackId MP4AddChapterTextTrack(
482 +       MP4FileHandle hFile, 
483 +       MP4TrackId refTrackId);
484 +
485  MP4TrackId MP4CloneTrack(
486         MP4FileHandle srcFile, 
487         MP4TrackId srcTrackId,
488 diff -Naur mpeg4ip.orig/lib/mp4v2/mp4atom.cpp mpeg4ip.patched/lib/mp4v2/mp4atom.cpp
489 --- mpeg4ip.orig/lib/mp4v2/mp4atom.cpp  2005-03-10 18:31:34.000000000 +0000
490 +++ mpeg4ip.patched/lib/mp4v2/mp4atom.cpp       2007-03-21 23:18:57.000000000 +0000
491 @@ -84,6 +84,13 @@
492         pAtom = new MP4SoundAtom("alaw");
493        }
494        break;
495 +
496 +    case 'c':
497 +      if (ATOMID(type) == ATOMID("chap")) {
498 +       pAtom = new MP4TrefTypeAtom(type);
499 +         }
500 +         break;
501 +
502      case 'd':
503        if (ATOMID(type) == ATOMID("d263")) {
504         pAtom = new MP4D263Atom();
505 @@ -113,6 +120,11 @@
506         pAtom = new MP4FtypAtom();
507        }
508        break;
509 +    case 'g':
510 +      if (ATOMID(type) == ATOMID("gmin")) {
511 +       pAtom = new MP4GminAtom();
512 +      }
513 +      break;
514      case 'h':
515        if (ATOMID(type) == ATOMID("hdlr")) {
516         pAtom = new MP4HdlrAtom();
517 @@ -200,7 +212,9 @@
518        }
519        break;
520      case 't':
521 -      if (ATOMID(type) == ATOMID("tkhd")) {
522 +      if (ATOMID(type) == ATOMID("text")) {
523 +       pAtom = new MP4TextAtom();
524 +      } else if (ATOMID(type) == ATOMID("tkhd")) {
525         pAtom = new MP4TkhdAtom();
526        } else if (ATOMID(type) == ATOMID("tfhd")) {
527         pAtom = new MP4TfhdAtom();
528 diff -Naur mpeg4ip.orig/lib/mp4v2/mp4file.cpp mpeg4ip.patched/lib/mp4v2/mp4file.cpp
529 --- mpeg4ip.orig/lib/mp4v2/mp4file.cpp  2005-03-30 19:41:58.000000000 +0100
530 +++ mpeg4ip.patched/lib/mp4v2/mp4file.cpp       2007-03-22 00:28:42.000000000 +0000
531 @@ -1869,6 +1869,59 @@
532         return trackId;
533  }
534  
535 +MP4TrackId MP4File::AddTextTrack(MP4TrackId refTrackId)
536 +{
537 +       // validate reference track id
538 +       FindTrackIndex(refTrackId);
539 +
540 +       MP4TrackId trackId = 
541 +               AddTrack(MP4_TEXT_TRACK_TYPE, GetTrackTimeScale(refTrackId));
542 +
543 +       InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "gmhd", 0);
544 +
545 +       AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "text");
546 +
547 +       // stsd is a unique beast in that it has a count of the number 
548 +       // of child atoms that needs to be incremented after we add the text atom
549 +       MP4Integer32Property* pStsdCountProperty;
550 +       FindIntegerProperty(
551 +               MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"),
552 +               (MP4Property**)&pStsdCountProperty);
553 +       pStsdCountProperty->IncrementValue();
554 +
555 +       return trackId;
556 +}
557 +
558 +MP4TrackId MP4File::AddChapterTextTrack(MP4TrackId refTrackId)
559 +{
560 +       // validate reference track id
561 +       FindTrackIndex(refTrackId);
562 +
563 +       MP4TrackId trackId = 
564 +               AddTrack(MP4_TEXT_TRACK_TYPE, GetTrackTimeScale(refTrackId));
565 +
566 +       InsertChildAtom(MakeTrackName(trackId, "mdia.minf"), "gmhd", 0);
567 +
568 +       AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd"), "text");
569 +
570 +       // stsd is a unique beast in that it has a count of the number 
571 +       // of child atoms that needs to be incremented after we add the text atom
572 +       MP4Integer32Property* pStsdCountProperty;
573 +       FindIntegerProperty(
574 +               MakeTrackName(trackId, "mdia.minf.stbl.stsd.entryCount"),
575 +               (MP4Property**)&pStsdCountProperty);
576 +       pStsdCountProperty->IncrementValue();
577 +
578 +       /* add the magic "text" atom to the generic media header */
579 +       AddChildAtom(MakeTrackName(trackId, "mdia.minf.gmhd"), "text");
580 +
581 +       AddDescendantAtoms(MakeTrackName(refTrackId, NULL), "tref.chap");
582 +
583 +       AddTrackReference(MakeTrackName(refTrackId, "tref.chap"), trackId);
584 +
585 +       return trackId;
586 +}
587 +
588  void MP4File::DeleteTrack(MP4TrackId trackId)
589  {
590         ProtectWriteOperation("MP4DeleteTrack");
591 diff -Naur mpeg4ip.orig/lib/mp4v2/mp4file.h mpeg4ip.patched/lib/mp4v2/mp4file.h
592 --- mpeg4ip.orig/lib/mp4v2/mp4file.h    2005-03-30 19:41:58.000000000 +0100
593 +++ mpeg4ip.patched/lib/mp4v2/mp4file.h 2007-03-21 23:33:12.000000000 +0000
594 @@ -296,6 +296,8 @@
595                                         const uint8_t *pPicture,
596                                         uint16_t pictureLen);
597         MP4TrackId AddHintTrack(MP4TrackId refTrackId);
598 +       MP4TrackId AddTextTrack(MP4TrackId refTrackId);
599 +       MP4TrackId AddChapterTextTrack(MP4TrackId refTrackId);
600  
601         MP4SampleId GetTrackNumberOfSamples(MP4TrackId trackId);
602  
603 diff -Naur mpeg4ip.orig/lib/mp4v2/atom_mp4a.cpp mpeg4ip.patched/lib/mp4v2/atom_mp4a.cpp
604 --- mpeg4ip.orig/lib/mp4v2/atom_mp4a.cpp        2007-04-26 01:21:22.000000000 -0600
605 +++ mpeg4ip.patched/lib/mp4v2/atom_mp4a.cpp     2007-04-26 01:43:08.000000000 -0600
606 @@ -29,7 +29,10 @@
607         AddProperty( /* 1 */
608                 new MP4Integer16Property("dataReferenceIndex"));
609  
610 -       AddReserved("reserved2", 16); /* 2 */
611 +       /* patched by saintdev to allow us to set correct audio information */
612 +//     AddReserved("reserved2", 16); /* 2 */
613 +       AddProperty( /* 2 */
614 +               new MP4BytesProperty("reserved2", 16));
615  
616         AddProperty( /* 3 */
617                 new MP4Integer16Property("timeScale"));
618 @@ -55,5 +58,6 @@
619         m_pProperties[2]->SetReadOnly(false);
620         ((MP4BytesProperty*)m_pProperties[2])->
621                 SetValue(reserved2, sizeof(reserved2));
622 -       m_pProperties[2]->SetReadOnly(true);
623 +       /* patched by saintdev to allow us to set correct audio information */
624 +//     m_pProperties[2]->SetReadOnly(true);
625  }