--- lib/mp4v2/Makefile.am 18 Sep 2007 20:51:59 -0000 1.32 +++ lib/mp4v2/Makefile.am 12 Nov 2007 18:29:31 -0000 @@ -33,6 +33,7 @@ atom_mp4v.cpp \ atom_mvhd.cpp \ atom_ohdr.cpp \ + atom_pasp.cpp \ atom_root.cpp \ atom_rtp.cpp \ atom_s263.cpp \ --- lib/mp4v2/atom_avc1.cpp 17 Aug 2004 21:36:55 -0000 1.1 +++ lib/mp4v2/atom_avc1.cpp 12 Nov 2007 18:29:32 -0000 @@ -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 */ --- lib/mp4v2/atom_stsd.cpp 29 Mar 2007 18:52:14 -0000 1.7 +++ lib/mp4v2/atom_stsd.cpp 12 Nov 2007 18:29:32 -0000 @@ -51,6 +51,7 @@ ExpectChildAtom("avc1", Optional, Many); ExpectChildAtom("alac", Optional, Many); ExpectChildAtom("text", Optional, Many); + ExpectChildAtom("pasp", Optional, Many); } void MP4StsdAtom::Read() --- lib/mp4v2/atoms.h 18 Sep 2007 20:51:59 -0000 1.21 +++ lib/mp4v2/atoms.h 12 Nov 2007 18:29:32 -0000 @@ -405,4 +405,10 @@ void Generate(void); }; +class MP4PaspAtom : public MP4Atom { + public: + MP4PaspAtom(); + void Generate(); +}; + #endif /* __MP4_ATOMS_INCLUDED__ */ --- lib/mp4v2/libmp4v260.dsp 29 Mar 2007 18:52:14 -0000 1.17 +++ lib/mp4v2/libmp4v260.dsp 12 Nov 2007 18:29:32 -0000 @@ -182,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 --- lib/mp4v2/mp4.cpp 28 Sep 2007 20:45:11 -0000 1.63 +++ lib/mp4v2/mp4.cpp 12 Nov 2007 18:29:35 -0000 @@ -1130,6 +1130,21 @@ 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, --- lib/mp4v2/mp4.h 28 Sep 2007 20:45:11 -0000 1.65 +++ lib/mp4v2/mp4.h 12 Nov 2007 18:29:36 -0000 @@ -601,6 +601,12 @@ MP4FileHandle hFile, MP4TrackId refTrackId); +MP4TrackId MP4AddPixelAspectRatio( + MP4FileHandle hFile, + MP4TrackId refTrackId, + u_int32_t hSpacing, + u_int32_t vSpacing); + MP4TrackId MP4CloneTrack( MP4FileHandle srcFile, MP4TrackId srcTrackId, --- lib/mp4v2/mp4atom.cpp 30 Apr 2007 20:29:28 -0000 1.36 +++ lib/mp4v2/mp4atom.cpp 12 Nov 2007 18:29:37 -0000 @@ -263,6 +263,11 @@ pAtom = new MP4SmiAtom(); } break; + case 'p': + if (ATOMID(type) == ATOMID("pasp")) { + pAtom = new MP4PaspAtom(); + } + break; case 0251: static const char name[5]={0251,'n', 'a', 'm', '\0'}; static const char cmt[5]={0251,'c', 'm', 't', '\0'}; --- lib/mp4v2/mp4file.cpp 28 Sep 2007 20:45:11 -0000 1.66 +++ lib/mp4v2/mp4file.cpp 12 Nov 2007 18:29:39 -0000 @@ -2168,6 +2168,28 @@ 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"); --- lib/mp4v2/mp4file.h 28 Sep 2007 20:45:11 -0000 1.61 +++ lib/mp4v2/mp4file.h 12 Nov 2007 18:29:40 -0000 @@ -312,6 +312,8 @@ MP4TrackId AddTextTrack(MP4TrackId refTrackId); MP4TrackId AddChapterTextTrack(MP4TrackId refTrackId); + MP4TrackId AddPixelAspectRatio(MP4TrackId trackId, u_int32_t hSpacing, u_int32_t vSpacing); + MP4SampleId GetTrackNumberOfSamples(MP4TrackId trackId); const char* GetTrackType(MP4TrackId trackId); --- lib/mp4v2/mp4v2/atom_pasp.cpp 2007-11-12 19:34:54.000000000 +0100 +++ lib/mp4v2/mp4v2/atom_pasp.cpp 2007-11-12 19:35:06.000000000 +0100 @@ -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); + +}