OSDN Git Service

Patches mpeg4ip to add some new features:
authorritsuka <ritsuka@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 19 Jan 2008 17:14:34 +0000 (17:14 +0000)
committerritsuka <ritsuka@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 19 Jan 2008 17:14:34 +0000 (17:14 +0000)
- pasp atom;
- layer and alternate_group property in tkhd atom.

git-svn-id: svn://localhost/HandBrake/trunk@1213 b64f7644-9d1e-0410-96f1-a4d463321fa5

contrib/Jamfile
contrib/patch-mpeg4ip-faac.patch [deleted file]
contrib/patch-mpeg4ip-no_compressor_name.patch [deleted file]
contrib/patch-mpeg4ip.patch

index f230219..f6648c2 100644 (file)
@@ -221,7 +221,7 @@ if $(OS) != CYGWIN
         cd `dirname $(>)` && CONTRIB=`pwd` &&
         rm -rf mpeg4ip && (gzip -dc mpeg4ip.tar.gz | tar xf - ) && 
         cd mpeg4ip &&
-        $(PATCH) -p1 < ../patch-mpeg4ip.patch  && $(PATCH) -p0 < ../patch-mpeg4ip-no_compressor_name.patch && $(PATCH) -p1 < ../patch-mpeg4ip-faac.patch &&
+        $(PATCH) -p1 < ../patch-mpeg4ip.patch &&
         ./bootstrap --cache-file=$CONTRIB/config.cache --disable-mp3lame --disable-faac --disable-x264 --disable-server --disable-player &&
         $(MAKE) -C lib/mp4v2 libmp4v2.la && cp lib/mp4v2/.libs/libmp4v2.a $CONTRIB/lib &&
         cp mpeg4ip_config.h include/mpeg4ip.h include/mpeg4ip_version.h \
@@ -236,7 +236,7 @@ else
         cd `dirname $(>)` && CONTRIB=`pwd` &&
         rm -rf mpeg4ip && (gzip -dc mpeg4ip.tar.gz | tar xf - ) && 
         cd mpeg4ip &&
-        $(PATCH) -p1 < ../patch-mpeg4ip.patch && $(PATCH) -p0 < ../patch-mpeg4ip-no_compressor_name.patch && $(PATCH) -p1 < ../patch_mpeg4ip_cygwin.patch &&
+        $(PATCH) -p1 < ../patch-mpeg4ip.patch && $(PATCH) -p1 < ../patch_mpeg4ip_cygwin.patch &&
         ./bootstrap --cache-file=$CONTRIB/config.cache --disable-mp3lame --disable-faac --disable-x264 --disable-server --disable-player &&
         $(MAKE) -C lib/mp4v2 libmp4v2.la && cp lib/mp4v2/.libs/libmp4v2.a $CONTRIB/lib &&
         cp mpeg4ip_config.h include/mpeg4ip.h include/mpeg4ip_version.h \
diff --git a/contrib/patch-mpeg4ip-faac.patch b/contrib/patch-mpeg4ip-faac.patch
deleted file mode 100644 (file)
index d8c46d6..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-diff -ruN mpeg4ip/bootstrap mpeg4ip.work/bootstrap
---- mpeg4ip/bootstrap  2005-10-13 14:09:41.000000000 -0600
-+++ mpeg4ip.work/bootstrap     2007-02-13 16:03:30.236971291 -0700
-@@ -47,9 +47,9 @@
- #
- if test $target_system = "Linux"; then
-     have_faac=no
--    if which faac >/dev/null 2>/dev/null; then
--      have_faac=yes
--    fi
-+#    if which faac >/dev/null 2>/dev/null; then
-+#     have_faac=yes
-+#    fi
-     if test $have_faac = "yes"; then
-       # we have lame and faac - see if faac is built with mp4 support
diff --git a/contrib/patch-mpeg4ip-no_compressor_name.patch b/contrib/patch-mpeg4ip-no_compressor_name.patch
deleted file mode 100644 (file)
index 652711c..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
---- lib/mp4v2/atom_avc1.cpp.bak.cpp    2004-07-13 17:07:50.000000000 -0400
-+++ lib/mp4v2/atom_avc1.cpp    2007-11-19 13:44:21.000000000 -0500
-@@ -41,7 +41,7 @@
-       MP4StringProperty* pProp = 
-               new MP4StringProperty("compressorName");
-       pProp->SetFixedLength(32);
--      pProp->SetValue("AVC Coding");
-+      pProp->SetValue("");
-       AddProperty(pProp); /* 6 */
-       AddReserved("reserved4", 4); /* 7 */
index 8a5462c..75f8bbf 100644 (file)
@@ -1,6 +1,22 @@
-diff -Naur mpeg4ip.orig/lib/mp4v2/Makefile.am mpeg4ip.patched/lib/mp4v2/Makefile.am
---- mpeg4ip.orig/lib/mp4v2/Makefile.am 2005-03-10 18:31:34.000000000 +0000
-+++ mpeg4ip.patched/lib/mp4v2/Makefile.am      2007-03-21 17:55:46.000000000 +0000
+diff -Naur mpeg4ip/bootstrap mpeg4ip-patched/bootstrap
+--- mpeg4ip/bootstrap  2005-10-13 16:09:41.000000000 -0400
++++ mpeg4ip-patched/bootstrap  2008-01-17 12:05:42.000000000 -0500
+@@ -47,9 +47,9 @@
+ #
+ if test $target_system = "Linux"; then
+     have_faac=no
+-    if which faac >/dev/null 2>/dev/null; then
+-      have_faac=yes
+-    fi
++#    if which faac >/dev/null 2>/dev/null; then
++#     have_faac=yes
++#    fi
+     if test $have_faac = "yes"; then
+       # we have lame and faac - see if faac is built with mp4 support
+diff -Naur mpeg4ip/lib/mp4v2/Makefile.am mpeg4ip-patched/lib/mp4v2/Makefile.am
+--- mpeg4ip/lib/mp4v2/Makefile.am      2005-03-10 13:31:34.000000000 -0500
++++ mpeg4ip-patched/lib/mp4v2/Makefile.am      2008-01-17 12:09:56.000000000 -0500
 @@ -21,6 +21,7 @@
        atom_encv.cpp \
        atom_free.cpp \
@@ -9,7 +25,15 @@ diff -Naur mpeg4ip.orig/lib/mp4v2/Makefile.am mpeg4ip.patched/lib/mp4v2/Makefile
        atom_hdlr.cpp \
        atom_hinf.cpp \
        atom_hnti.cpp \
-@@ -45,6 +46,7 @@
+@@ -32,6 +33,7 @@
+       atom_mp4s.cpp \
+       atom_mp4v.cpp \
+       atom_mvhd.cpp \
++      atom_pasp.cpp \
+       atom_root.cpp \
+       atom_rtp.cpp \
+       atom_s263.cpp \
+@@ -45,6 +47,7 @@
        atom_stsc.cpp \
        atom_stsd.cpp \
        atom_stsz.cpp \
@@ -17,9 +41,9 @@ diff -Naur mpeg4ip.orig/lib/mp4v2/Makefile.am mpeg4ip.patched/lib/mp4v2/Makefile
        atom_tfhd.cpp \
        atom_tkhd.cpp \
        atom_treftype.cpp \
-diff -Naur mpeg4ip.orig/lib/mp4v2/Makefile.in mpeg4ip.patched/lib/mp4v2/Makefile.in
---- mpeg4ip.orig/lib/mp4v2/Makefile.in 2005-05-18 23:03:05.000000000 +0100
-+++ mpeg4ip.patched/lib/mp4v2/Makefile.in      2007-03-21 17:56:20.000000000 +0000
+diff -Naur mpeg4ip/lib/mp4v2/Makefile.in mpeg4ip-patched/lib/mp4v2/Makefile.in
+--- mpeg4ip/lib/mp4v2/Makefile.in      2005-05-18 18:03:05.000000000 -0400
++++ mpeg4ip-patched/lib/mp4v2/Makefile.in      2008-01-17 12:04:09.000000000 -0500
 @@ -55,6 +55,7 @@
  am_libmp4v2_la_OBJECTS = 3gp.lo atom_amr.lo atom_avc1.lo atom_avcC.lo \
        atom_d263.lo atom_damr.lo atom_dref.lo atom_elst.lo \
@@ -76,9 +100,21 @@ diff -Naur mpeg4ip.orig/lib/mp4v2/Makefile.in mpeg4ip.patched/lib/mp4v2/Makefile
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_tfhd.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_tkhd.Plo@am__quote@
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_treftype.Plo@am__quote@
-diff -Naur mpeg4ip.orig/lib/mp4v2/atom_gmin.cpp mpeg4ip.patched/lib/mp4v2/atom_gmin.cpp
---- mpeg4ip.orig/lib/mp4v2/atom_gmin.cpp       1970-01-01 01:00:00.000000000 +0100
-+++ mpeg4ip.patched/lib/mp4v2/atom_gmin.cpp    2007-03-21 14:41:32.000000000 +0000
+diff -Naur mpeg4ip/lib/mp4v2/atom_avc1.cpp mpeg4ip-patched/lib/mp4v2/atom_avc1.cpp
+--- mpeg4ip/lib/mp4v2/atom_avc1.cpp    2004-07-13 17:07:50.000000000 -0400
++++ mpeg4ip-patched/lib/mp4v2/atom_avc1.cpp    2008-01-17 12:07:00.000000000 -0500
+@@ -41,7 +41,7 @@
+       MP4StringProperty* pProp = 
+               new MP4StringProperty("compressorName");
+       pProp->SetFixedLength(32);
+-      pProp->SetValue("AVC Coding");
++      pProp->SetValue("");
+       AddProperty(pProp); /* 6 */
+       AddReserved("reserved4", 4); /* 7 */
+diff -Naur mpeg4ip/lib/mp4v2/atom_gmin.cpp mpeg4ip-patched/lib/mp4v2/atom_gmin.cpp
+--- mpeg4ip/lib/mp4v2/atom_gmin.cpp    1969-12-31 19:00:00.000000000 -0500
++++ mpeg4ip-patched/lib/mp4v2/atom_gmin.cpp    2008-01-17 12:04:09.000000000 -0500
 @@ -0,0 +1,51 @@
 +/*
 + * The contents of this file are subject to the Mozilla Public
@@ -131,9 +167,32 @@ diff -Naur mpeg4ip.orig/lib/mp4v2/atom_gmin.cpp mpeg4ip.patched/lib/mp4v2/atom_g
 +
 +}
 +
-diff -Naur mpeg4ip.orig/lib/mp4v2/atom_standard.cpp mpeg4ip.patched/lib/mp4v2/atom_standard.cpp
---- mpeg4ip.orig/lib/mp4v2/atom_standard.cpp   2004-12-14 21:35:35.000000000 +0000
-+++ mpeg4ip.patched/lib/mp4v2/atom_standard.cpp        2007-03-21 23:14:04.000000000 +0000
+diff -Naur mpeg4ip/lib/mp4v2/atom_mp4a.cpp mpeg4ip-patched/lib/mp4v2/atom_mp4a.cpp
+--- mpeg4ip/lib/mp4v2/atom_mp4a.cpp    2001-10-02 17:15:39.000000000 -0400
++++ mpeg4ip-patched/lib/mp4v2/atom_mp4a.cpp    2008-01-17 12:04:09.000000000 -0500
+@@ -29,7 +29,10 @@
+       AddProperty( /* 1 */
+               new MP4Integer16Property("dataReferenceIndex"));
+-      AddReserved("reserved2", 16); /* 2 */
++      /* patched by saintdev to allow us to set correct audio information */
++//    AddReserved("reserved2", 16); /* 2 */
++      AddProperty( /* 2 */
++              new MP4BytesProperty("reserved2", 16));
+       AddProperty( /* 3 */
+               new MP4Integer16Property("timeScale"));
+@@ -55,5 +58,6 @@
+       m_pProperties[2]->SetReadOnly(false);
+       ((MP4BytesProperty*)m_pProperties[2])->
+               SetValue(reserved2, sizeof(reserved2));
+-      m_pProperties[2]->SetReadOnly(true);
++      /* patched by saintdev to allow us to set correct audio information */
++//    m_pProperties[2]->SetReadOnly(true);
+ }
+diff -Naur mpeg4ip/lib/mp4v2/atom_standard.cpp mpeg4ip-patched/lib/mp4v2/atom_standard.cpp
+--- mpeg4ip/lib/mp4v2/atom_standard.cpp        2004-12-14 16:35:35.000000000 -0500
++++ mpeg4ip-patched/lib/mp4v2/atom_standard.cpp        2008-01-17 12:04:09.000000000 -0500
 @@ -138,6 +138,11 @@
    /*
     * g???
@@ -162,20 +221,21 @@ diff -Naur mpeg4ip.orig/lib/mp4v2/atom_standard.cpp mpeg4ip.patched/lib/mp4v2/at
  
    } else if (ATOMID(type) == ATOMID("trex")) {
      AddVersionAndFlags();     /* 0, 1 */
-diff -Naur mpeg4ip.orig/lib/mp4v2/atom_stsd.cpp mpeg4ip.patched/lib/mp4v2/atom_stsd.cpp
---- mpeg4ip.orig/lib/mp4v2/atom_stsd.cpp       2004-07-13 22:07:50.000000000 +0100
-+++ mpeg4ip.patched/lib/mp4v2/atom_stsd.cpp    2007-03-21 17:20:24.000000000 +0000
-@@ -49,6 +49,7 @@
+diff -Naur mpeg4ip/lib/mp4v2/atom_stsd.cpp mpeg4ip-patched/lib/mp4v2/atom_stsd.cpp
+--- mpeg4ip/lib/mp4v2/atom_stsd.cpp    2004-07-13 17:07:50.000000000 -0400
++++ mpeg4ip-patched/lib/mp4v2/atom_stsd.cpp    2008-01-17 12:07:00.000000000 -0500
+@@ -49,6 +49,8 @@
        ExpectChildAtom("sawb", Optional, Many); // For AMR-WB
        ExpectChildAtom("s263", Optional, Many); // For H.263
        ExpectChildAtom("avc1", Optional, Many);
 +      ExpectChildAtom("text", Optional, Many);
++      ExpectChildAtom("pasp", Optional, Many);
  }
  
  void MP4StsdAtom::Read() 
-diff -Naur mpeg4ip.orig/lib/mp4v2/atom_text.cpp mpeg4ip.patched/lib/mp4v2/atom_text.cpp
---- mpeg4ip.orig/lib/mp4v2/atom_text.cpp       1970-01-01 01:00:00.000000000 +0100
-+++ mpeg4ip.patched/lib/mp4v2/atom_text.cpp    2007-03-22 00:35:53.000000000 +0000
+diff -Naur mpeg4ip/lib/mp4v2/atom_text.cpp mpeg4ip-patched/lib/mp4v2/atom_text.cpp
+--- mpeg4ip/lib/mp4v2/atom_text.cpp    1969-12-31 19:00:00.000000000 -0500
++++ mpeg4ip-patched/lib/mp4v2/atom_text.cpp    2008-01-17 12:04:09.000000000 -0500
 @@ -0,0 +1,132 @@
 +/*
 + * The contents of this file are subject to the Mozilla Public
@@ -309,32 +369,63 @@ diff -Naur mpeg4ip.orig/lib/mp4v2/atom_text.cpp mpeg4ip.patched/lib/mp4v2/atom_t
 +}
 +
 +
-diff -Naur mpeg4ip.orig/lib/mp4v2/atom_tkhd.cpp mpeg4ip.patched/lib/mp4v2/atom_tkhd.cpp
---- mpeg4ip.orig/lib/mp4v2/atom_tkhd.cpp       2003-11-19 23:46:11.000000000 +0000
-+++ mpeg4ip.patched/lib/mp4v2/atom_tkhd.cpp    2007-03-22 00:42:40.000000000 +0000
-@@ -61,7 +61,8 @@
+diff -Naur mpeg4ip/lib/mp4v2/atom_tkhd.cpp mpeg4ip-patched/lib/mp4v2/atom_tkhd.cpp
+--- mpeg4ip/lib/mp4v2/atom_tkhd.cpp    2003-11-20 00:46:11.000000000 +0100
++++ mpeg4ip/lib/mp4v2/atom_tkhd.cpp    2008-01-19 12:41:13.000000000 +0100
+@@ -53,23 +53,29 @@
+                       new MP4Integer32Property("duration"));
+       }
+-      AddReserved("reserved2", 12); /* 7 */
+-
++      AddReserved("reserved2", 8); /* 7 */
++      
++      AddProperty( /* 8 */
++                      new MP4Integer16Property("layer"));
++      AddProperty( /* 9 */
++                      new MP4Integer16Property("alternate_group"));
++      
+       MP4Float32Property* pProp;
+       pProp = new MP4Float32Property("volume");
        pProp->SetFixed16Format();
-       AddProperty(pProp); /* 8 */
+-      AddProperty(pProp); /* 8 */
++      AddProperty(pProp); /* 10 */
  
 -      AddReserved("reserved3", 38); /* 9 */
 +      /* patched by maurj to enable us to set the matrix for anamorphic display */
-+      AddProperty(new MP4BytesProperty("reserved3", 38)); /* 9 */
++      AddProperty(new MP4BytesProperty("reserved3", 38)); /* 11 */
  
        pProp = new MP4Float32Property("width");
        pProp->SetFixed32Format();
-@@ -106,7 +107,8 @@
-       m_pProperties[9]->SetReadOnly(false);
-       ((MP4BytesProperty*)m_pProperties[9])->
+-      AddProperty(pProp); /* 10 */
++      AddProperty(pProp); /* 12 */
+       pProp = new MP4Float32Property("height");
+       pProp->SetFixed32Format();
+-      AddProperty(pProp); /* 11 */
++      AddProperty(pProp); /* 13 */
+ }
+ void MP4TkhdAtom::Generate() 
+@@ -103,10 +109,11 @@
+               0x00, 0x00, 0x00, 0x00, 
+               0x40, 0x00, 0x00, 0x00, 
+       };
+-      m_pProperties[9]->SetReadOnly(false);
+-      ((MP4BytesProperty*)m_pProperties[9])->
++      m_pProperties[11]->SetReadOnly(false);
++      ((MP4BytesProperty*)m_pProperties[11])->
                SetValue(reserved3, sizeof(reserved3));
 -      m_pProperties[9]->SetReadOnly(true);
 +      /* patched by maurj to enable us to set the matrix for anamorphic display */
 +      /* m_pProperties[9]->SetReadOnly(true);*/
  }
  
- void MP4TkhdAtom::Read() 
-diff -Naur mpeg4ip.orig/lib/mp4v2/atoms.h mpeg4ip.patched/lib/mp4v2/atoms.h
---- mpeg4ip.orig/lib/mp4v2/atoms.h     2005-03-10 18:31:34.000000000 +0000
-+++ mpeg4ip.patched/lib/mp4v2/atoms.h  2007-03-22 00:41:38.000000000 +0000
+ void MP4TkhdAtom::Read()
+diff -Naur mpeg4ip/lib/mp4v2/atoms.h mpeg4ip-patched/lib/mp4v2/atoms.h
+--- mpeg4ip/lib/mp4v2/atoms.h  2005-03-10 13:31:34.000000000 -0500
++++ mpeg4ip-patched/lib/mp4v2/atoms.h  2008-01-17 12:07:00.000000000 -0500
 @@ -206,6 +206,12 @@
        void Read();
  };
@@ -368,9 +459,20 @@ diff -Naur mpeg4ip.orig/lib/mp4v2/atoms.h mpeg4ip.patched/lib/mp4v2/atoms.h
  class MP4TfhdAtom : public MP4Atom {
  public:
        MP4TfhdAtom();
-diff -Naur mpeg4ip.orig/lib/mp4v2/libmp4v260.dsp mpeg4ip.patched/lib/mp4v2/libmp4v260.dsp
---- mpeg4ip.orig/lib/mp4v2/libmp4v260.dsp      2005-03-24 22:14:52.000000000 +0000
-+++ mpeg4ip.patched/lib/mp4v2/libmp4v260.dsp   2007-03-21 17:28:47.000000000 +0000
+@@ -374,4 +393,10 @@
+   void Generate(void);
+ };
++class MP4PaspAtom : public MP4Atom {
++ public:
++    MP4PaspAtom();
++    void Generate();
++};
++
+ #endif /* __MP4_ATOMS_INCLUDED__ */
+diff -Naur mpeg4ip/lib/mp4v2/libmp4v260.dsp mpeg4ip-patched/lib/mp4v2/libmp4v260.dsp
+--- mpeg4ip/lib/mp4v2/libmp4v260.dsp   2005-03-24 17:14:52.000000000 -0500
++++ mpeg4ip-patched/lib/mp4v2/libmp4v260.dsp   2008-01-17 12:07:00.000000000 -0500
 @@ -134,6 +134,10 @@
  # End Source File
  # Begin Source File
@@ -382,7 +484,18 @@ diff -Naur mpeg4ip.orig/lib/mp4v2/libmp4v260.dsp mpeg4ip.patched/lib/mp4v2/libmp
  SOURCE=.\atom_hdlr.cpp
  # End Source File
  # Begin Source File
-@@ -242,6 +246,10 @@
+@@ -178,6 +182,10 @@
+ # End Source File
+ # Begin Source File
++SOURCE=.\atom_pasp.cpp
++# End Source File
++# Begin Source File
++
+ SOURCE=.\atom_root.cpp
+ # End Source File
+ # Begin Source File
+@@ -242,6 +250,10 @@
  # End Source File
  # Begin Source File
  
@@ -393,9 +506,9 @@ diff -Naur mpeg4ip.orig/lib/mp4v2/libmp4v260.dsp mpeg4ip.patched/lib/mp4v2/libmp
  SOURCE=.\atom_udta.cpp
  # End Source File
  # Begin Source File
-diff -Naur mpeg4ip.orig/lib/mp4v2/libmp4v2_st60.dsp mpeg4ip.patched/lib/mp4v2/libmp4v2_st60.dsp
---- mpeg4ip.orig/lib/mp4v2/libmp4v2_st60.dsp   2005-03-24 22:14:52.000000000 +0000
-+++ mpeg4ip.patched/lib/mp4v2/libmp4v2_st60.dsp        2007-03-21 17:29:12.000000000 +0000
+diff -Naur mpeg4ip/lib/mp4v2/libmp4v2_st60.dsp mpeg4ip-patched/lib/mp4v2/libmp4v2_st60.dsp
+--- mpeg4ip/lib/mp4v2/libmp4v2_st60.dsp        2005-03-24 17:14:52.000000000 -0500
++++ mpeg4ip-patched/lib/mp4v2/libmp4v2_st60.dsp        2008-01-17 12:04:09.000000000 -0500
 @@ -133,6 +133,10 @@
  # End Source File
  # Begin Source File
@@ -418,10 +531,10 @@ diff -Naur mpeg4ip.orig/lib/mp4v2/libmp4v2_st60.dsp mpeg4ip.patched/lib/mp4v2/li
  SOURCE=.\atom_udta.cpp
  # End Source File
  # Begin Source File
-diff -Naur mpeg4ip.orig/lib/mp4v2/mp4.cpp mpeg4ip.patched/lib/mp4v2/mp4.cpp
---- mpeg4ip.orig/lib/mp4v2/mp4.cpp     2005-03-30 19:41:58.000000000 +0100
-+++ mpeg4ip.patched/lib/mp4v2/mp4.cpp  2007-03-21 23:40:06.000000000 +0000
-@@ -939,6 +939,37 @@
+diff -Naur mpeg4ip/lib/mp4v2/mp4.cpp mpeg4ip-patched/lib/mp4v2/mp4.cpp
+--- mpeg4ip/lib/mp4v2/mp4.cpp  2005-03-30 13:41:58.000000000 -0500
++++ mpeg4ip-patched/lib/mp4v2/mp4.cpp  2008-01-17 12:07:00.000000000 -0500
+@@ -939,6 +939,52 @@
        return MP4_INVALID_TRACK_ID;
  }
  
@@ -455,13 +568,28 @@ diff -Naur mpeg4ip.orig/lib/mp4v2/mp4.cpp mpeg4ip.patched/lib/mp4v2/mp4.cpp
 +      return MP4_INVALID_TRACK_ID;
 +}
 +
++extern "C" MP4TrackId MP4AddPixelAspectRatio(
++      MP4FileHandle hFile, MP4TrackId refTrackId, u_int32_t hSpacing, u_int32_t vSpacing)
++{
++      if (MP4_IS_VALID_FILE_HANDLE(hFile)) {
++              try {
++                      return ((MP4File*)hFile)->AddPixelAspectRatio(refTrackId, hSpacing, vSpacing);
++              }
++              catch (MP4Error* e) {
++                      PRINT_ERROR(e);
++                      delete e;
++              }
++      }
++      return MP4_INVALID_TRACK_ID;
++}
++
 +
  extern "C" MP4TrackId MP4CloneTrack(
        MP4FileHandle srcFile, 
        MP4TrackId srcTrackId,
-diff -Naur mpeg4ip.orig/lib/mp4v2/mp4.h mpeg4ip.patched/lib/mp4v2/mp4.h
---- mpeg4ip.orig/lib/mp4v2/mp4.h       2005-03-30 19:41:58.000000000 +0100
-+++ mpeg4ip.patched/lib/mp4v2/mp4.h    2007-03-21 23:32:28.000000000 +0000
+diff -Naur mpeg4ip/lib/mp4v2/mp4.h mpeg4ip-patched/lib/mp4v2/mp4.h
+--- mpeg4ip/lib/mp4v2/mp4.h    2005-03-30 13:41:58.000000000 -0500
++++ mpeg4ip-patched/lib/mp4v2/mp4.h    2008-01-17 12:07:00.000000000 -0500
 @@ -100,6 +100,7 @@
  #define MP4_VIDEO_TRACK_TYPE  "vide"
  #define MP4_HINT_TRACK_TYPE           "hint"
@@ -470,7 +598,7 @@ diff -Naur mpeg4ip.orig/lib/mp4v2/mp4.h mpeg4ip.patched/lib/mp4v2/mp4.h
  /*
   * This second set of track types should be created 
   * via MP4AddSystemsTrack(type)
-@@ -538,6 +539,14 @@
+@@ -538,6 +539,20 @@
        MP4FileHandle hFile, 
        MP4TrackId refTrackId);
  
@@ -482,12 +610,18 @@ diff -Naur mpeg4ip.orig/lib/mp4v2/mp4.h mpeg4ip.patched/lib/mp4v2/mp4.h
 +      MP4FileHandle hFile, 
 +      MP4TrackId refTrackId);
 +
++MP4TrackId MP4AddPixelAspectRatio(
++      MP4FileHandle hFile, 
++      MP4TrackId refTrackId,
++    u_int32_t hSpacing,
++    u_int32_t vSpacing);
++
  MP4TrackId MP4CloneTrack(
        MP4FileHandle srcFile, 
        MP4TrackId srcTrackId,
-diff -Naur mpeg4ip.orig/lib/mp4v2/mp4atom.cpp mpeg4ip.patched/lib/mp4v2/mp4atom.cpp
---- mpeg4ip.orig/lib/mp4v2/mp4atom.cpp 2005-03-10 18:31:34.000000000 +0000
-+++ mpeg4ip.patched/lib/mp4v2/mp4atom.cpp      2007-03-21 23:18:57.000000000 +0000
+diff -Naur mpeg4ip/lib/mp4v2/mp4atom.cpp mpeg4ip-patched/lib/mp4v2/mp4atom.cpp
+--- mpeg4ip/lib/mp4v2/mp4atom.cpp      2005-03-10 13:31:34.000000000 -0500
++++ mpeg4ip-patched/lib/mp4v2/mp4atom.cpp      2008-01-17 12:11:40.000000000 -0500
 @@ -84,6 +84,13 @@
        pAtom = new MP4SoundAtom("alaw");
        }
@@ -525,10 +659,23 @@ diff -Naur mpeg4ip.orig/lib/mp4v2/mp4atom.cpp mpeg4ip.patched/lib/mp4v2/mp4atom.
        pAtom = new MP4TkhdAtom();
        } else if (ATOMID(type) == ATOMID("tfhd")) {
        pAtom = new MP4TfhdAtom();
-diff -Naur mpeg4ip.orig/lib/mp4v2/mp4file.cpp mpeg4ip.patched/lib/mp4v2/mp4file.cpp
---- mpeg4ip.orig/lib/mp4v2/mp4file.cpp 2005-03-30 19:41:58.000000000 +0100
-+++ mpeg4ip.patched/lib/mp4v2/mp4file.cpp      2007-03-22 00:28:42.000000000 +0000
-@@ -1869,6 +1869,59 @@
+@@ -238,6 +252,12 @@
+       pAtom = new MP4SmiAtom();
+       }
+       break;
++     case 'p':
++         if (ATOMID(type) == ATOMID("pasp")) {
++      pAtom = new MP4PaspAtom();
++       }
++       break;
++    
+     }
+   }
+diff -Naur mpeg4ip/lib/mp4v2/mp4file.cpp mpeg4ip-patched/lib/mp4v2/mp4file.cpp
+--- mpeg4ip/lib/mp4v2/mp4file.cpp      2005-03-30 13:41:58.000000000 -0500
++++ mpeg4ip-patched/lib/mp4v2/mp4file.cpp      2008-01-17 12:07:00.000000000 -0500
+@@ -1869,6 +1869,81 @@
        return trackId;
  }
  
@@ -585,41 +732,124 @@ diff -Naur mpeg4ip.orig/lib/mp4v2/mp4file.cpp mpeg4ip.patched/lib/mp4v2/mp4file.
 +      return trackId;
 +}
 +
++MP4TrackId MP4File::AddPixelAspectRatio(MP4TrackId trackId, u_int32_t hSpacing, u_int32_t vSpacing)
++{
++      // validate reference track id
++  (void)FindTrackIndex(trackId);
++    const char *format = GetTrackMediaDataName (trackId);
++    
++    if (!strcasecmp(format, "avc1"))
++    {
++           (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.avc1"), "pasp");
++            SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.avc1.pasp.hSpacing", hSpacing);
++            SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.avc1.pasp.vSpacing", vSpacing);
++    }
++    else if (!strcasecmp(format, "mp4v"))
++    {
++           (void)AddChildAtom(MakeTrackName(trackId, "mdia.minf.stbl.stsd.mp4v"), "pasp");
++            SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.mp4v.pasp.hSpacing", hSpacing);
++            SetTrackIntegerProperty(trackId, "mdia.minf.stbl.stsd.mp4v.pasp.vSpacing", vSpacing);
++    }
++
++      return trackId;
++}
++
  void MP4File::DeleteTrack(MP4TrackId trackId)
  {
        ProtectWriteOperation("MP4DeleteTrack");
-diff -Naur mpeg4ip.orig/lib/mp4v2/mp4file.h mpeg4ip.patched/lib/mp4v2/mp4file.h
---- mpeg4ip.orig/lib/mp4v2/mp4file.h   2005-03-30 19:41:58.000000000 +0100
-+++ mpeg4ip.patched/lib/mp4v2/mp4file.h        2007-03-21 23:33:12.000000000 +0000
-@@ -296,6 +296,8 @@
+diff -Naur mpeg4ip/lib/mp4v2/mp4file.h mpeg4ip-patched/lib/mp4v2/mp4file.h
+--- mpeg4ip/lib/mp4v2/mp4file.h        2005-03-30 13:41:58.000000000 -0500
++++ mpeg4ip-patched/lib/mp4v2/mp4file.h        2008-01-17 12:07:00.000000000 -0500
+@@ -296,6 +296,10 @@
                                        const uint8_t *pPicture,
                                        uint16_t pictureLen);
        MP4TrackId AddHintTrack(MP4TrackId refTrackId);
 +      MP4TrackId AddTextTrack(MP4TrackId refTrackId);
 +      MP4TrackId AddChapterTextTrack(MP4TrackId refTrackId);
++
++      MP4TrackId AddPixelAspectRatio(MP4TrackId trackId, u_int32_t hSpacing, u_int32_t vSpacing);
  
        MP4SampleId GetTrackNumberOfSamples(MP4TrackId trackId);
  
-diff -Naur mpeg4ip.orig/lib/mp4v2/atom_mp4a.cpp mpeg4ip.patched/lib/mp4v2/atom_mp4a.cpp
---- mpeg4ip.orig/lib/mp4v2/atom_mp4a.cpp        2007-04-26 01:21:22.000000000 -0600
-+++ mpeg4ip.patched/lib/mp4v2/atom_mp4a.cpp     2007-04-26 01:43:08.000000000 -0600
-@@ -29,7 +29,10 @@
-       AddProperty( /* 1 */
-               new MP4Integer16Property("dataReferenceIndex"));
--      AddReserved("reserved2", 16); /* 2 */
-+      /* patched by saintdev to allow us to set correct audio information */
-+//    AddReserved("reserved2", 16); /* 2 */
-+      AddProperty( /* 2 */
-+              new MP4BytesProperty("reserved2", 16));
-       AddProperty( /* 3 */
-               new MP4Integer16Property("timeScale"));
-@@ -55,5 +58,6 @@
-       m_pProperties[2]->SetReadOnly(false);
-       ((MP4BytesProperty*)m_pProperties[2])->
-               SetValue(reserved2, sizeof(reserved2));
--      m_pProperties[2]->SetReadOnly(true);
-+      /* patched by saintdev to allow us to set correct audio information */
-+//    m_pProperties[2]->SetReadOnly(true);
- }
+diff -Naur mpeg4ip/lib/mp4v2/atom_pasp.cpp mpeg4ip-patched/lib/mp4v2/atom_pasp.cpp
+--- mpeg4ip/lib/mp4v2/atom_pasp.cpp    1969-12-31 19:00:00.000000000 -0500
++++ mpeg4ip-patched/lib/mp4v2/atom_pasp.cpp    2008-01-17 12:07:00.000000000 -0500
+@@ -0,0 +1,42 @@
++/*
++ * The contents of this file are subject to the Mozilla Public
++ * License Version 1.1 (the "License"); you may not use this file
++ * except in compliance with the License. You may obtain a copy of
++ * the License at http://www.mozilla.org/MPL/
++ * 
++ * Software distributed under the License is distributed on an "AS
++ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
++ * implied. See the License for the specific language governing
++ * rights and limitations under the License.
++ * 
++ * The Original Code is MPEG4IP.
++ * 
++ * Contributer has declined to give copyright information, and gives
++ * it freely to the world.
++ * 
++ * Contributor(s): 
++ */
++
++#include "mp4common.h"
++
++MP4PaspAtom::MP4PaspAtom() 
++      : MP4Atom("pasp") 
++{
++
++      AddProperty( /* 0 */
++        new MP4Integer32Property("hSpacing"));
++
++      AddProperty( /* 1 */
++        new MP4Integer32Property("vSpacing")); 
++
++}
++
++void MP4PaspAtom::Generate()
++{
++
++      MP4Atom::Generate();
++
++      ((MP4Integer32Property*)m_pProperties[0])->SetValue(1);
++      ((MP4Integer32Property*)m_pProperties[1])->SetValue(1);
++
++}
+diff -Naur mpeg4ip-patched/lib/mp4v2/Makefile.in mpeg4ip/lib/mp4v2/Makefile.in
+--- mpeg4ip-patched/lib/mp4v2/Makefile.in      2008-01-17 12:04:09.000000000 -0500
++++ mpeg4ip/lib/mp4v2/Makefile.in      2008-01-17 13:20:50.000000000 -0500
+@@ -58,7 +58,7 @@
+       atom_gmin.lo atom_text.lo \
+       atom_hdlr.lo atom_hinf.lo atom_hnti.lo atom_href.lo \
+       atom_mdat.lo atom_mdhd.lo atom_meta.lo atom_mp4a.lo \
+-      atom_mp4s.lo atom_mp4v.lo atom_mvhd.lo atom_root.lo \
++      atom_mp4s.lo atom_mp4v.lo atom_mvhd.lo atom_pasp.lo atom_root.lo \
+       atom_rtp.lo atom_s263.lo atom_sdp.lo atom_smi.lo atom_sound.lo \
+       atom_standard.lo atom_stbl.lo atom_stdp.lo atom_stsc.lo \
+       atom_stsd.lo atom_stsz.lo atom_tfhd.lo atom_tkhd.lo \
+@@ -96,6 +96,7 @@
+ @AMDEP_TRUE@  ./$(DEPDIR)/atom_mp4v.Plo \
+ @AMDEP_TRUE@  ./$(DEPDIR)/atom_mvhd.Plo \
+ @AMDEP_TRUE@  ./$(DEPDIR)/atom_root.Plo ./$(DEPDIR)/atom_rtp.Plo \
++@AMDEP_TRUE@  ./$(DEPDIR)/atom_pasp.Plo \
+ @AMDEP_TRUE@  ./$(DEPDIR)/atom_s263.Plo ./$(DEPDIR)/atom_sdp.Plo \
+ @AMDEP_TRUE@  ./$(DEPDIR)/atom_smi.Plo \
+ @AMDEP_TRUE@  ./$(DEPDIR)/atom_sound.Plo \
+@@ -364,6 +365,7 @@
+       atom_mp4s.cpp \
+       atom_mp4v.cpp \
+       atom_mvhd.cpp \
++      atom_pasp.cpp \
+       atom_root.cpp \
+       atom_rtp.cpp \
+       atom_s263.cpp \
+@@ -518,6 +520,7 @@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_mp4s.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_mp4v.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_mvhd.Plo@am__quote@
++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_pasp.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_root.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_rtp.Plo@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom_s263.Plo@am__quote@