Skip to content

Commit

Permalink
Add vp09 atom support
Browse files Browse the repository at this point in the history
  • Loading branch information
dchengTSC committed Jan 15, 2025
1 parent 2191f92 commit 0f59bbf
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ set(SOURCE_FILES
src/atom_uuid.cpp
src/atom_video.cpp
src/atom_vmhd.cpp
src/atom_vp09.cpp
src/cmeta.cpp
src/descriptors.cpp
src/enum.tcc
Expand Down
81 changes: 81 additions & 0 deletions src/atom_vp09.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* 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.
*
* The Initial Developer of the Original Code is Cisco Systems Inc.
* Portions created by Cisco Systems Inc. are
* Copyright (C) Cisco Systems Inc. 2004. All Rights Reserved.
*
* Contributor(s):
*/

#include "src/impl.h"

namespace mp4v2 {
namespace impl {

///////////////////////////////////////////////////////////////////////////////

MP4Vp09Atom::MP4Vp09Atom(MP4File &file)
: MP4Atom(file, "vp09")
{
AddReserved(*this, "reserved1", 6);
AddProperty(new MP4Integer16Property(*this, "dataReferenceIndex"));
AddReserved(*this, "reserved2", 16); // version, revision level, vendor, temporal quality, spatial quality
AddProperty(new MP4Integer16Property(*this, "width"));
AddProperty(new MP4Integer16Property(*this, "height"));
AddReserved(*this, "reserved3", 14); // horiz and vert resolution, datasize and framecount

MP4StringProperty* pProp = new MP4StringProperty(*this, "compressorName");
pProp->SetFixedLength(32);
pProp->SetCountedFormat(true);
pProp->SetValue("vp09 Coding");
AddProperty(pProp);

AddReserved(*this, "reserved4", 4); // depth and color table ID

ExpectChildAtom("vpcC", Required, OnlyOne);
ExpectChildAtom("btrt", Optional, OnlyOne);
ExpectChildAtom("colr", Optional, OnlyOne);
ExpectChildAtom("pasp", Optional, OnlyOne);
}

void MP4Vp09Atom::Generate()
{
MP4Atom::Generate();

((MP4Integer16Property*)m_pProperties[1])->SetValue(1);

// property reserved3 has non-zero fixed values
static uint8_t reserved3[14] = {
0x00, 0x48, 0x00, 0x00,
0x00, 0x48, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x01,
};
m_pProperties[5]->SetReadOnly(false);
((MP4BytesProperty*)m_pProperties[5])->SetValue(reserved3, sizeof(reserved3));
m_pProperties[5]->SetReadOnly(true);

// property reserved4 has non-zero fixed values
static uint8_t reserved4[4] = {
0x00, 0x18, 0xFF, 0xFF,
};
m_pProperties[7]->SetReadOnly(false);
((MP4BytesProperty*)m_pProperties[7])->SetValue(reserved4, sizeof(reserved4));
m_pProperties[7]->SetReadOnly(true);
}

///////////////////////////////////////////////////////////////////////////////

}
} // namespace mp4v2::impl
10 changes: 10 additions & 0 deletions src/atoms.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,16 @@ class MP4VmhdAtom : public MP4Atom {
MP4VmhdAtom &operator= ( const MP4VmhdAtom &src );
};

class MP4Vp09Atom : public MP4Atom {
public:
MP4Vp09Atom(MP4File &file);
void Generate();
private:
MP4Vp09Atom();
MP4Vp09Atom( const MP4Vp09Atom &src );
MP4Vp09Atom &operator= ( const MP4Vp09Atom &src );
};

class MP4HrefAtom : public MP4Atom {
public:
MP4HrefAtom(MP4File &file);
Expand Down
2 changes: 2 additions & 0 deletions src/mp4atom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,8 @@ MP4Atom::factory( MP4File &file, MP4Atom* parent, const char* type )
case 'v':
if( ATOMID(type) == ATOMID("vmhd") )
return new MP4VmhdAtom(file);
if( ATOMID(type) == ATOMID("vp09") )
return new MP4Vp09Atom(file);
break;

case 'y':
Expand Down

0 comments on commit 0f59bbf

Please sign in to comment.