diff --git a/Source/C++/Core/Ap4.h b/Source/C++/Core/Ap4.h index dce9d97d..8ef4b9bf 100644 --- a/Source/C++/Core/Ap4.h +++ b/Source/C++/Core/Ap4.h @@ -316,6 +316,10 @@ #include "Ap4Dec3Atom.h" #include "Ap4Dac4Atom.h" #include "Ap4SidxAtom.h" +#include "Ap4ColrAtom.h" +#include "Ap4GamaAtom.h" +#include "Ap4PaspAtom.h" +#include "Ap4FielAtom.h" #include "Ap4AdtsParser.h" #include "Ap4Ac4Parser.h" #include "Ap4AvcParser.h" diff --git a/Source/C++/Core/Ap4Atom.h b/Source/C++/Core/Ap4Atom.h index 73d3a414..438c8da4 100644 --- a/Source/C++/Core/Ap4Atom.h +++ b/Source/C++/Core/Ap4Atom.h @@ -482,6 +482,15 @@ const AP4_Atom::Type AP4_ATOM_TYPE_HEV1 = AP4_ATOM_TYPE('h','e','v','1'); const AP4_Atom::Type AP4_ATOM_TYPE_HVC1 = AP4_ATOM_TYPE('h','v','c','1'); const AP4_Atom::Type AP4_ATOM_TYPE_DVHE = AP4_ATOM_TYPE('d','v','h','e'); const AP4_Atom::Type AP4_ATOM_TYPE_DVH1 = AP4_ATOM_TYPE('d','v','h','1'); +const AP4_Atom::Type AP4_ATOM_TYPE_AP4H = AP4_ATOM_TYPE('a','p','4','h'); +const AP4_Atom::Type AP4_ATOM_TYPE_AP4X = AP4_ATOM_TYPE('a','p','4','x'); +const AP4_Atom::Type AP4_ATOM_TYPE_APCH = AP4_ATOM_TYPE('a','p','c','h'); +const AP4_Atom::Type AP4_ATOM_TYPE_APCN = AP4_ATOM_TYPE('a','p','c','n'); +const AP4_Atom::Type AP4_ATOM_TYPE_APCS = AP4_ATOM_TYPE('a','p','c','s'); +const AP4_Atom::Type AP4_ATOM_TYPE_APCO = AP4_ATOM_TYPE('a','p','c','o'); +const AP4_Atom::Type AP4_ATOM_TYPE_JPEG = AP4_ATOM_TYPE('j','p','e','g'); +const AP4_Atom::Type AP4_ATOM_TYPE_AVDN = AP4_ATOM_TYPE('A','V','d','n'); +const AP4_Atom::Type AP4_ATOM_TYPE_AVDH = AP4_ATOM_TYPE('A','V','d','h'); const AP4_Atom::Type AP4_ATOM_TYPE_VP08 = AP4_ATOM_TYPE('v','p','0','8'); const AP4_Atom::Type AP4_ATOM_TYPE_VP09 = AP4_ATOM_TYPE('v','p','0','9'); const AP4_Atom::Type AP4_ATOM_TYPE_VP10 = AP4_ATOM_TYPE('v','p','1','0'); @@ -588,6 +597,10 @@ const AP4_Atom::Type AP4_ATOM_TYPE_SIDX = AP4_ATOM_TYPE('s','i','d','x'); const AP4_Atom::Type AP4_ATOM_TYPE_SSIX = AP4_ATOM_TYPE('s','s','i','x'); const AP4_Atom::Type AP4_ATOM_TYPE_SBGP = AP4_ATOM_TYPE('s','b','g','p'); const AP4_Atom::Type AP4_ATOM_TYPE_SGPD = AP4_ATOM_TYPE('s','g','p','d'); +const AP4_Atom::Type AP4_ATOM_TYPE_COLR = AP4_ATOM_TYPE('c','o','l','r'); +const AP4_Atom::Type AP4_ATOM_TYPE_GAMA = AP4_ATOM_TYPE('g','a','m','a'); +const AP4_Atom::Type AP4_ATOM_TYPE_PASP = AP4_ATOM_TYPE('p','a','s','p'); +const AP4_Atom::Type AP4_ATOM_TYPE_FIEL = AP4_ATOM_TYPE('f','i','e','l'); /*---------------------------------------------------------------------- | AP4_AtomListInspector diff --git a/Source/C++/Core/Ap4AtomFactory.cpp b/Source/C++/Core/Ap4AtomFactory.cpp index d689a78b..d780b90c 100644 --- a/Source/C++/Core/Ap4AtomFactory.cpp +++ b/Source/C++/Core/Ap4AtomFactory.cpp @@ -108,6 +108,10 @@ #include "Ap4SidxAtom.h" #include "Ap4SbgpAtom.h" #include "Ap4SgpdAtom.h" +#include "Ap4ColrAtom.h" +#include "Ap4GamaAtom.h" +#include "Ap4PaspAtom.h" +#include "Ap4FielAtom.h" /*---------------------------------------------------------------------- | AP4_AtomFactory::~AP4_AtomFactory @@ -352,6 +356,19 @@ AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream& stream, atom = new AP4_AudioSampleEntry(type, size_32, stream, *this); break; + // ProRes + case AP4_ATOM_TYPE_AP4H: + case AP4_ATOM_TYPE_AP4X: + case AP4_ATOM_TYPE_APCH: + case AP4_ATOM_TYPE_APCN: + case AP4_ATOM_TYPE_APCS: + case AP4_ATOM_TYPE_APCO: + // mjpeg + case AP4_ATOM_TYPE_JPEG: + // Avid DNxHD / DNxHR + case AP4_ATOM_TYPE_AVDN: + case AP4_ATOM_TYPE_AVDH: + // VP8/9/10 case AP4_ATOM_TYPE_VP08: case AP4_ATOM_TYPE_VP09: case AP4_ATOM_TYPE_VP10: @@ -777,6 +794,26 @@ AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream& stream, } break; + case AP4_ATOM_TYPE_COLR: + if (atom_is_large) return AP4_ERROR_INVALID_FORMAT; + atom = AP4_ColrAtom::Create(size_32, stream); + break; + + case AP4_ATOM_TYPE_GAMA: + if (atom_is_large) return AP4_ERROR_INVALID_FORMAT; + atom = AP4_GamaAtom::Create(size_32, stream); + break; + + case AP4_ATOM_TYPE_PASP: + if (atom_is_large) return AP4_ERROR_INVALID_FORMAT; + atom = AP4_PaspAtom::Create(size_32, stream); + break; + + case AP4_ATOM_TYPE_FIEL: + if (atom_is_large) return AP4_ERROR_INVALID_FORMAT; + atom = AP4_FielAtom::Create(size_32, stream); + break; + // track ref types case AP4_ATOM_TYPE_HINT: case AP4_ATOM_TYPE_CDSC: diff --git a/Source/C++/Core/Ap4ColrAtom.cpp b/Source/C++/Core/Ap4ColrAtom.cpp new file mode 100644 index 00000000..bdd6cb64 --- /dev/null +++ b/Source/C++/Core/Ap4ColrAtom.cpp @@ -0,0 +1,119 @@ +/***************************************************************** +| +| AP4 - colr Atoms +| +| Copyright 2002-2022 Axiomatic Systems, LLC +| +| +| This file is part of Bento4/AP4 (MP4 Atom Processing Library). +| +| Unless you have obtained Bento4 under a difference license, +| this version of Bento4 is Bento4|GPL. +| Bento4|GPL is free software; you can redistribute it and/or modify +| it under the terms of the GNU General Public License as published by +| the Free Software Foundation; either version 2, or (at your option) +| any later version. +| +| Bento4|GPL is distributed in the hope that it will be useful, +| but WITHOUT ANY WARRANTY; without even the implied warranty of +| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +| GNU General Public License for more details. +| +| You should have received a copy of the GNU General Public License +| along with Bento4|GPL; see the file COPYING. If not, write to the +| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA +| 02111-1307, USA. +| + ****************************************************************/ + +/*---------------------------------------------------------------------- +| includes ++---------------------------------------------------------------------*/ +#include "Ap4ColrAtom.h" +#include "Ap4Utils.h" + +/*---------------------------------------------------------------------- +| dynamic cast support ++---------------------------------------------------------------------*/ +AP4_DEFINE_DYNAMIC_CAST_ANCHOR(AP4_ColrAtom) + +/*---------------------------------------------------------------------- +| AP4_ColrAtom::Create ++---------------------------------------------------------------------*/ +AP4_ColrAtom* +AP4_ColrAtom::Create(AP4_Size size, AP4_ByteStream& stream) +{ + return new AP4_ColrAtom(size, stream); +} + +/*---------------------------------------------------------------------- +| AP4_ColrAtom::AP4_ColrAtom ++---------------------------------------------------------------------*/ +AP4_ColrAtom::AP4_ColrAtom(AP4_UI32 type, + AP4_UI16 primaries, + AP4_UI16 transfer_function, + AP4_UI16 matrix_index) : + AP4_Atom(AP4_ATOM_TYPE_COLR, AP4_ATOM_HEADER_SIZE + 10), + m_Type(type), + m_Primaries(primaries), + m_TransferFunction(transfer_function), + m_MatrixIndex(matrix_index) +{ +} + +/*---------------------------------------------------------------------- +| AP4_ColrAtom::AP4_ColrAtom ++---------------------------------------------------------------------*/ +AP4_ColrAtom::AP4_ColrAtom() : + AP4_Atom(AP4_ATOM_TYPE_COLR, AP4_ATOM_HEADER_SIZE + 10), + m_Type(AP4_COLR_TYPE_NCLC), + m_Primaries(AP4_COLR_PRIMARIES_BT709), + m_TransferFunction(AP4_COLR_TRANSFER_FUNCTION_BT709), + m_MatrixIndex(AP4_COLR_COLORSPACE_BT709) +{ +} + +/*---------------------------------------------------------------------- +| AP4_ColrAtom::AP4_ColrAtom ++---------------------------------------------------------------------*/ +AP4_ColrAtom::AP4_ColrAtom(AP4_UI32 size, + AP4_ByteStream& stream) : + AP4_Atom(AP4_ATOM_TYPE_COLR, size) +{ + stream.ReadUI32(m_Type); + stream.ReadUI16(m_Primaries); + stream.ReadUI16(m_TransferFunction); + stream.ReadUI16(m_MatrixIndex); +} + +/*---------------------------------------------------------------------- +| AP4_ColrAtom::InspectFields ++---------------------------------------------------------------------*/ +AP4_Result +AP4_ColrAtom::InspectFields(AP4_AtomInspector& inspector) +{ + char type[5]; + AP4_FormatFourChars(type, m_Type); + inspector.AddField("type", type); + inspector.AddField("primaries", m_Primaries); + inspector.AddField("transfer_function", m_TransferFunction); + inspector.AddField("matrix_index", m_MatrixIndex); + return AP4_SUCCESS; +} + +/*---------------------------------------------------------------------- +| AP4_ColrAtom::WriteFields ++---------------------------------------------------------------------*/ +AP4_Result +AP4_ColrAtom::WriteFields(AP4_ByteStream& stream) +{ + AP4_Result result; + result = stream.WriteUI32(m_Type); + if (AP4_FAILED(result)) return result; + result = stream.WriteUI16(m_Primaries); + if (AP4_FAILED(result)) return result; + result = stream.WriteUI16(m_TransferFunction); + if (AP4_FAILED(result)) return result; + result = stream.WriteUI16(m_MatrixIndex); + return result; +} diff --git a/Source/C++/Core/Ap4ColrAtom.h b/Source/C++/Core/Ap4ColrAtom.h new file mode 100644 index 00000000..31e81c70 --- /dev/null +++ b/Source/C++/Core/Ap4ColrAtom.h @@ -0,0 +1,136 @@ +/***************************************************************** +| +| AP4 - colr Atoms +| +| Copyright 2002-2022 Axiomatic Systems, LLC +| +| +| This file is part of Bento4/AP4 (MP4 Atom Processing Library). +| +| Unless you have obtained Bento4 under a difference license, +| this version of Bento4 is Bento4|GPL. +| Bento4|GPL is free software; you can redistribute it and/or modify +| it under the terms of the GNU General Public License as published by +| the Free Software Foundation; either version 2, or (at your option) +| any later version. +| +| Bento4|GPL is distributed in the hope that it will be useful, +| but WITHOUT ANY WARRANTY; without even the implied warranty of +| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +| GNU General Public License for more details. +| +| You should have received a copy of the GNU General Public License +| along with Bento4|GPL; see the file COPYING. If not, write to the +| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA +| 02111-1307, USA. +| +****************************************************************/ + +#ifndef _AP4_COLR_ATOM_H_ +#define _AP4_COLR_ATOM_H_ + +/*---------------------------------------------------------------------- +| includes ++---------------------------------------------------------------------*/ +#include "Ap4Atom.h" + +/*---------------------------------------------------------------------- +| constants ++---------------------------------------------------------------------*/ +const AP4_UI16 AP4_COLR_PRIMARIES_RESERVED0 = 0; +const AP4_UI16 AP4_COLR_PRIMARIES_BT709 = 1; +const AP4_UI16 AP4_COLR_PRIMARIES_UNSPECIFIED = 2; +const AP4_UI16 AP4_COLR_PRIMARIES_RESERVED = 3; +const AP4_UI16 AP4_COLR_PRIMARIES_BT470M = 4; +const AP4_UI16 AP4_COLR_PRIMARIES_BT470BG = 5; +const AP4_UI16 AP4_COLR_PRIMARIES_SMPTE170M = 6; +const AP4_UI16 AP4_COLR_PRIMARIES_SMPTE240M = 7; +const AP4_UI16 AP4_COLR_PRIMARIES_FILM = 8; +const AP4_UI16 AP4_COLR_PRIMARIES_BT2020 = 9; +const AP4_UI16 AP4_COLR_PRIMARIES_SMPTE428 = 10; +const AP4_UI16 AP4_COLR_PRIMARIES_XYZ = 10; +const AP4_UI16 AP4_COLR_PRIMARIES_SMPTE431 = 11; +const AP4_UI16 AP4_COLR_PRIMARIES_P3DCI = 11; +const AP4_UI16 AP4_COLR_PRIMARIES_SMPTE432 = 12; +const AP4_UI16 AP4_COLR_PRIMARIES_P3D65 = 12; + +const AP4_UI16 AP4_COLR_TRANSFER_FUNCTION_RESERVED0 = 0; +const AP4_UI16 AP4_COLR_TRANSFER_FUNCTION_BT709 = 1; +const AP4_UI16 AP4_COLR_TRANSFER_FUNCTION_UNSPECIFIED = 2; +const AP4_UI16 AP4_COLR_TRANSFER_FUNCTION_RESERVED = 3; +const AP4_UI16 AP4_COLR_TRANSFER_FUNCTION_GAMMA22 = 4; +const AP4_UI16 AP4_COLR_TRANSFER_FUNCTION_GAMMA28 = 5; +const AP4_UI16 AP4_COLR_TRANSFER_FUNCTION_SMPTE170M = 6; +const AP4_UI16 AP4_COLR_TRANSFER_FUNCTION_SMPTE240M = 7; +const AP4_UI16 AP4_COLR_TRANSFER_FUNCTION_LINEAR = 8; +const AP4_UI16 AP4_COLR_TRANSFER_FUNCTION_LOG = 9; +const AP4_UI16 AP4_COLR_TRANSFER_FUNCTION_LOG_SQRT = 10; +const AP4_UI16 AP4_COLR_TRANSFER_FUNCTION_IEC61966_2_4 = 11; +const AP4_UI16 AP4_COLR_TRANSFER_FUNCTION_BT1361_ECG = 12; +const AP4_UI16 AP4_COLR_TRANSFER_FUNCTION_IEC61966_2_1 = 13; +const AP4_UI16 AP4_COLR_TRANSFER_FUNCTION_BT2020_10 = 14; +const AP4_UI16 AP4_COLR_TRANSFER_FUNCTION_BT2020_12 = 15; +const AP4_UI16 AP4_COLR_TRANSFER_FUNCTION_SMPTE2084 = 16; +const AP4_UI16 AP4_COLR_TRANSFER_FUNCTION_ST2084 = 16; +const AP4_UI16 AP4_COLR_TRANSFER_FUNCTION_SMPTE428 = 17; +const AP4_UI16 AP4_COLR_TRANSFER_FUNCTION_ARIB_STD_B67 = 18; +const AP4_UI16 AP4_COLR_TRANSFER_FUNCTION_HLG = 18; + +const AP4_UI16 AP4_COLR_COLORSPACE_GBR = 0; +const AP4_UI16 AP4_COLR_COLORSPACE_BT709 = 1; +const AP4_UI16 AP4_COLR_COLORSPACE_UNSPECIFIED = 2; +const AP4_UI16 AP4_COLR_COLORSPACE_RESERVED = 3; +const AP4_UI16 AP4_COLR_COLORSPACE_FCC = 4; +const AP4_UI16 AP4_COLR_COLORSPACE_BT470BG = 5; +const AP4_UI16 AP4_COLR_COLORSPACE_SMPTE170M = 6; +const AP4_UI16 AP4_COLR_COLORSPACE_SMPTE240M = 7; +const AP4_UI16 AP4_COLR_COLORSPACE_YCOCG = 8; +const AP4_UI16 AP4_COLR_COLORSPACE_BT2020_NCL = 9; +const AP4_UI16 AP4_COLR_COLORSPACE_BT2020_CL = 10; +const AP4_UI16 AP4_COLR_COLORSPACE_SMPTE2085 = 11; +const AP4_UI16 AP4_COLR_COLORSPACE_CHROMA_DERIVED_NCL = 12; +const AP4_UI16 AP4_COLR_COLORSPACE_CHROMA_DERIVED_CL = 13; +const AP4_UI16 AP4_COLR_COLORSPACE_ICTCP = 14; + +const AP4_UI32 AP4_COLR_TYPE_NCLC = AP4_ATOM_TYPE('n','c','l','c'); + +/*---------------------------------------------------------------------- +| AP4_ColrAtom ++---------------------------------------------------------------------*/ +class AP4_ColrAtom : public AP4_Atom +{ +public: + AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_ColrAtom, AP4_Atom) + + // class methods + static AP4_ColrAtom* Create(AP4_Size size, AP4_ByteStream& stream); + + // constructors + AP4_ColrAtom(AP4_UI32 type, + AP4_UI16 primaries, + AP4_UI16 transfer_function, + AP4_UI16 matrix_index); + AP4_ColrAtom(); + + // methods + virtual AP4_Result InspectFields(AP4_AtomInspector& inspector); + virtual AP4_Result WriteFields(AP4_ByteStream& stream); + + // accessors + AP4_UI32 GetType() const { return m_Type; } + AP4_UI16 GetPrimaries() const { return m_Primaries; } + AP4_UI16 GetTransferFunction() const { return m_TransferFunction; } + AP4_UI16 GetMatrixIndex() const { return m_MatrixIndex; } + +private: + // methods + AP4_ColrAtom(AP4_UI32 size, AP4_ByteStream& stream); + + // members + AP4_UI32 m_Type; + AP4_UI16 m_Primaries; + AP4_UI16 m_TransferFunction; + AP4_UI16 m_MatrixIndex; +}; + +#endif // _AP4_COLR_ATOM_H_ diff --git a/Source/C++/Core/Ap4FielAtom.cpp b/Source/C++/Core/Ap4FielAtom.cpp new file mode 100644 index 00000000..7ae4d1e9 --- /dev/null +++ b/Source/C++/Core/Ap4FielAtom.cpp @@ -0,0 +1,102 @@ +/***************************************************************** +| +| AP4 - fiel Atoms +| +| Copyright 2002-2022 Axiomatic Systems, LLC +| +| +| This file is part of Bento4/AP4 (MP4 Atom Processing Library). +| +| Unless you have obtained Bento4 under a difference license, +| this version of Bento4 is Bento4|GPL. +| Bento4|GPL is free software; you can redistribute it and/or modify +| it under the terms of the GNU General Public License as published by +| the Free Software Foundation; either version 2, or (at your option) +| any later version. +| +| Bento4|GPL is distributed in the hope that it will be useful, +| but WITHOUT ANY WARRANTY; without even the implied warranty of +| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +| GNU General Public License for more details. +| +| You should have received a copy of the GNU General Public License +| along with Bento4|GPL; see the file COPYING. If not, write to the +| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA +| 02111-1307, USA. +| + ****************************************************************/ + +/*---------------------------------------------------------------------- +| includes ++---------------------------------------------------------------------*/ +#include "Ap4FielAtom.h" +#include "Ap4Utils.h" + +/*---------------------------------------------------------------------- +| dynamic cast support ++---------------------------------------------------------------------*/ +AP4_DEFINE_DYNAMIC_CAST_ANCHOR(AP4_FielAtom) + +/*---------------------------------------------------------------------- +| AP4_FielAtom::Create ++---------------------------------------------------------------------*/ +AP4_FielAtom* +AP4_FielAtom::Create(AP4_Size size, AP4_ByteStream& stream) +{ + return new AP4_FielAtom(size, stream); +} + +/*---------------------------------------------------------------------- +| AP4_FielAtom::AP4_FielAtom ++---------------------------------------------------------------------*/ +AP4_FielAtom::AP4_FielAtom(AP4_UI08 fields, AP4_UI08 detail) : + AP4_Atom(AP4_ATOM_TYPE_FIEL, AP4_ATOM_HEADER_SIZE + 2), + m_Fields(fields), + m_Detail(detail) +{ +} + +/*---------------------------------------------------------------------- +| AP4_FielAtom::AP4_FielAtom ++---------------------------------------------------------------------*/ +AP4_FielAtom::AP4_FielAtom() : + AP4_Atom(AP4_ATOM_TYPE_FIEL, AP4_ATOM_HEADER_SIZE + 2), + m_Fields(1), + m_Detail(0) +{ +} + +/*---------------------------------------------------------------------- +| AP4_FielAtom::AP4_FielAtom ++---------------------------------------------------------------------*/ +AP4_FielAtom::AP4_FielAtom(AP4_UI32 size, + AP4_ByteStream& stream) : + AP4_Atom(AP4_ATOM_TYPE_FIEL, size) +{ + stream.ReadUI08(m_Fields); + stream.ReadUI08(m_Detail); +} + +/*---------------------------------------------------------------------- +| AP4_FielAtom::InspectFields ++---------------------------------------------------------------------*/ +AP4_Result +AP4_FielAtom::InspectFields(AP4_AtomInspector& inspector) +{ + inspector.AddField("fields", m_Fields); + inspector.AddField("detail", m_Detail); + return AP4_SUCCESS; +} + +/*---------------------------------------------------------------------- +| AP4_FielAtom::WriteFields ++---------------------------------------------------------------------*/ +AP4_Result +AP4_FielAtom::WriteFields(AP4_ByteStream& stream) +{ + AP4_Result result; + result = stream.WriteUI08(m_Fields); + if (AP4_FAILED(result)) return result; + result = stream.WriteUI08(m_Detail); + return result; +} diff --git a/Source/C++/Core/Ap4FielAtom.h b/Source/C++/Core/Ap4FielAtom.h new file mode 100644 index 00000000..c636e870 --- /dev/null +++ b/Source/C++/Core/Ap4FielAtom.h @@ -0,0 +1,70 @@ +/***************************************************************** +| +| AP4 - fiel Atoms +| +| Copyright 2002-2022 Axiomatic Systems, LLC +| +| +| This file is part of Bento4/AP4 (MP4 Atom Processing Library). +| +| Unless you have obtained Bento4 under a difference license, +| this version of Bento4 is Bento4|GPL. +| Bento4|GPL is free software; you can redistribute it and/or modify +| it under the terms of the GNU General Public License as published by +| the Free Software Foundation; either version 2, or (at your option) +| any later version. +| +| Bento4|GPL is distributed in the hope that it will be useful, +| but WITHOUT ANY WARRANTY; without even the implied warranty of +| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +| GNU General Public License for more details. +| +| You should have received a copy of the GNU General Public License +| along with Bento4|GPL; see the file COPYING. If not, write to the +| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA +| 02111-1307, USA. +| +****************************************************************/ + +#ifndef _AP4_FIEL_ATOM_H_ +#define _AP4_FIEL_ATOM_H_ + +/*---------------------------------------------------------------------- +| includes ++---------------------------------------------------------------------*/ +#include "Ap4Atom.h" + +/*---------------------------------------------------------------------- +| AP4_FielAtom ++---------------------------------------------------------------------*/ +class AP4_FielAtom : public AP4_Atom +{ +public: + AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_FielAtom, AP4_Atom) + + // class methods + static AP4_FielAtom* Create(AP4_Size size, AP4_ByteStream& stream); + + // constructors + AP4_FielAtom(AP4_UI08 fields, AP4_UI08 detail); + + AP4_FielAtom(); + + // methods + virtual AP4_Result InspectFields(AP4_AtomInspector& inspector); + virtual AP4_Result WriteFields(AP4_ByteStream& stream); + + // accessors + AP4_UI08 GetFields() const { return m_Fields; } + AP4_UI08 GetDetail() const { return m_Detail; } + +private: + // methods + AP4_FielAtom(AP4_UI32 size, AP4_ByteStream& stream); + + // members + AP4_UI08 m_Fields; + AP4_UI08 m_Detail; +}; + +#endif // _AP4_FIEL_ATOM_H_ diff --git a/Source/C++/Core/Ap4GamaAtom.cpp b/Source/C++/Core/Ap4GamaAtom.cpp new file mode 100644 index 00000000..2cb66cf6 --- /dev/null +++ b/Source/C++/Core/Ap4GamaAtom.cpp @@ -0,0 +1,97 @@ +/***************************************************************** +| +| AP4 - gama Atoms +| +| Copyright 2002-2022 Axiomatic Systems, LLC +| +| +| This file is part of Bento4/AP4 (MP4 Atom Processing Library). +| +| Unless you have obtained Bento4 under a difference license, +| this version of Bento4 is Bento4|GPL. +| Bento4|GPL is free software; you can redistribute it and/or modify +| it under the terms of the GNU General Public License as published by +| the Free Software Foundation; either version 2, or (at your option) +| any later version. +| +| Bento4|GPL is distributed in the hope that it will be useful, +| but WITHOUT ANY WARRANTY; without even the implied warranty of +| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +| GNU General Public License for more details. +| +| You should have received a copy of the GNU General Public License +| along with Bento4|GPL; see the file COPYING. If not, write to the +| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA +| 02111-1307, USA. +| + ****************************************************************/ + +/*---------------------------------------------------------------------- +| includes ++---------------------------------------------------------------------*/ +#include "Ap4GamaAtom.h" +#include "Ap4Utils.h" + +/*---------------------------------------------------------------------- +| dynamic cast support ++---------------------------------------------------------------------*/ +AP4_DEFINE_DYNAMIC_CAST_ANCHOR(AP4_GamaAtom) + +/*---------------------------------------------------------------------- +| AP4_GamaAtom::Create ++---------------------------------------------------------------------*/ +AP4_GamaAtom* +AP4_GamaAtom::Create(AP4_Size size, AP4_ByteStream& stream) +{ + return new AP4_GamaAtom(size, stream); +} + +/*---------------------------------------------------------------------- +| AP4_GamaAtom::AP4_GamaAtom ++---------------------------------------------------------------------*/ +AP4_GamaAtom::AP4_GamaAtom(AP4_UI32 gamma) : + AP4_Atom(AP4_ATOM_TYPE_GAMA, AP4_ATOM_HEADER_SIZE + 4), + m_Gamma(gamma) +{ +} + +/*---------------------------------------------------------------------- +| AP4_GamaAtom::AP4_GamaAtom ++---------------------------------------------------------------------*/ +AP4_GamaAtom::AP4_GamaAtom() : + AP4_Atom(AP4_ATOM_TYPE_GAMA, AP4_ATOM_HEADER_SIZE + 4), + m_Gamma(1) +{ +} + +/*---------------------------------------------------------------------- +| AP4_GamaAtom::AP4_GamaAtom ++---------------------------------------------------------------------*/ +AP4_GamaAtom::AP4_GamaAtom(AP4_UI32 size, + AP4_ByteStream& stream) : + AP4_Atom(AP4_ATOM_TYPE_GAMA, size) +{ + stream.ReadUI32(m_Gamma); +} + +/*---------------------------------------------------------------------- +| AP4_GamaAtom::InspectFields ++---------------------------------------------------------------------*/ +AP4_Result +AP4_GamaAtom::InspectFields(AP4_AtomInspector& inspector) +{ + double gamma = ((double)(m_Gamma)) / (1 << 16); + inspector.AddFieldF("gamma", gamma); + return AP4_SUCCESS; +} + +/*---------------------------------------------------------------------- +| AP4_GamaAtom::WriteFields ++---------------------------------------------------------------------*/ +AP4_Result +AP4_GamaAtom::WriteFields(AP4_ByteStream& stream) +{ + AP4_Result result; + result = stream.WriteUI32(m_Gamma); + return result; +} diff --git a/Source/C++/Core/Ap4GamaAtom.h b/Source/C++/Core/Ap4GamaAtom.h new file mode 100644 index 00000000..5e69839b --- /dev/null +++ b/Source/C++/Core/Ap4GamaAtom.h @@ -0,0 +1,68 @@ +/***************************************************************** +| +| AP4 - gama Atoms +| +| Copyright 2002-2022 Axiomatic Systems, LLC +| +| +| This file is part of Bento4/AP4 (MP4 Atom Processing Library). +| +| Unless you have obtained Bento4 under a difference license, +| this version of Bento4 is Bento4|GPL. +| Bento4|GPL is free software; you can redistribute it and/or modify +| it under the terms of the GNU General Public License as published by +| the Free Software Foundation; either version 2, or (at your option) +| any later version. +| +| Bento4|GPL is distributed in the hope that it will be useful, +| but WITHOUT ANY WARRANTY; without even the implied warranty of +| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +| GNU General Public License for more details. +| +| You should have received a copy of the GNU General Public License +| along with Bento4|GPL; see the file COPYING. If not, write to the +| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA +| 02111-1307, USA. +| +****************************************************************/ + +#ifndef _AP4_GAMA_ATOM_H_ +#define _AP4_GAMA_ATOM_H_ + +/*---------------------------------------------------------------------- +| includes ++---------------------------------------------------------------------*/ +#include "Ap4Atom.h" + +/*---------------------------------------------------------------------- +| AP4_GamaAtom ++---------------------------------------------------------------------*/ +class AP4_GamaAtom : public AP4_Atom +{ +public: + AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_GamaAtom, AP4_Atom) + + // class methods + static AP4_GamaAtom* Create(AP4_Size size, AP4_ByteStream& stream); + + // constructors + AP4_GamaAtom(AP4_UI32 gamma); + + AP4_GamaAtom(); + + // methods + virtual AP4_Result InspectFields(AP4_AtomInspector& inspector); + virtual AP4_Result WriteFields(AP4_ByteStream& stream); + + // accessors + AP4_UI32 GetGamma() const { return m_Gamma; } + +private: + // methods + AP4_GamaAtom(AP4_UI32 size, AP4_ByteStream& stream); + + // members + AP4_UI32 m_Gamma; +}; + +#endif // _AP4_GAMA_ATOM_H_ diff --git a/Source/C++/Core/Ap4PaspAtom.cpp b/Source/C++/Core/Ap4PaspAtom.cpp new file mode 100644 index 00000000..dfd63818 --- /dev/null +++ b/Source/C++/Core/Ap4PaspAtom.cpp @@ -0,0 +1,102 @@ +/***************************************************************** +| +| AP4 - pasp Atoms +| +| Copyright 2002-2022 Axiomatic Systems, LLC +| +| +| This file is part of Bento4/AP4 (MP4 Atom Processing Library). +| +| Unless you have obtained Bento4 under a difference license, +| this version of Bento4 is Bento4|GPL. +| Bento4|GPL is free software; you can redistribute it and/or modify +| it under the terms of the GNU General Public License as published by +| the Free Software Foundation; either version 2, or (at your option) +| any later version. +| +| Bento4|GPL is distributed in the hope that it will be useful, +| but WITHOUT ANY WARRANTY; without even the implied warranty of +| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +| GNU General Public License for more details. +| +| You should have received a copy of the GNU General Public License +| along with Bento4|GPL; see the file COPYING. If not, write to the +| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA +| 02111-1307, USA. +| + ****************************************************************/ + +/*---------------------------------------------------------------------- +| includes ++---------------------------------------------------------------------*/ +#include "Ap4PaspAtom.h" +#include "Ap4Utils.h" + +/*---------------------------------------------------------------------- +| dynamic cast support ++---------------------------------------------------------------------*/ +AP4_DEFINE_DYNAMIC_CAST_ANCHOR(AP4_PaspAtom) + +/*---------------------------------------------------------------------- +| AP4_PaspAtom::Create ++---------------------------------------------------------------------*/ +AP4_PaspAtom* +AP4_PaspAtom::Create(AP4_Size size, AP4_ByteStream& stream) +{ + return new AP4_PaspAtom(size, stream); +} + +/*---------------------------------------------------------------------- +| AP4_PaspAtom::AP4_PaspAtom ++---------------------------------------------------------------------*/ +AP4_PaspAtom::AP4_PaspAtom(AP4_UI32 hspacing, AP4_UI32 vspacing) : + AP4_Atom(AP4_ATOM_TYPE_PASP, AP4_ATOM_HEADER_SIZE + 8), + m_HSpacing(hspacing), + m_VSpacing(vspacing) +{ +} + +/*---------------------------------------------------------------------- +| AP4_PaspAtom::AP4_PaspAtom ++---------------------------------------------------------------------*/ +AP4_PaspAtom::AP4_PaspAtom() : + AP4_Atom(AP4_ATOM_TYPE_PASP, AP4_ATOM_HEADER_SIZE + 8), + m_HSpacing(1), + m_VSpacing(1) +{ +} + +/*---------------------------------------------------------------------- +| AP4_PaspAtom::AP4_PaspAtom ++---------------------------------------------------------------------*/ +AP4_PaspAtom::AP4_PaspAtom(AP4_UI32 size, + AP4_ByteStream& stream) : + AP4_Atom(AP4_ATOM_TYPE_PASP, size) +{ + stream.ReadUI32(m_HSpacing); + stream.ReadUI32(m_VSpacing); +} + +/*---------------------------------------------------------------------- +| AP4_PaspAtom::InspectFields ++---------------------------------------------------------------------*/ +AP4_Result +AP4_PaspAtom::InspectFields(AP4_AtomInspector& inspector) +{ + inspector.AddField("hSpacing", m_HSpacing); + inspector.AddField("vSpacing", m_VSpacing); + return AP4_SUCCESS; +} + +/*---------------------------------------------------------------------- +| AP4_PaspAtom::WriteFields ++---------------------------------------------------------------------*/ +AP4_Result +AP4_PaspAtom::WriteFields(AP4_ByteStream& stream) +{ + AP4_Result result; + result = stream.WriteUI32(m_HSpacing); + if (AP4_FAILED(result)) return result; + result = stream.WriteUI32(m_VSpacing); + return result; +} diff --git a/Source/C++/Core/Ap4PaspAtom.h b/Source/C++/Core/Ap4PaspAtom.h new file mode 100644 index 00000000..d0d51dcb --- /dev/null +++ b/Source/C++/Core/Ap4PaspAtom.h @@ -0,0 +1,70 @@ +/***************************************************************** +| +| AP4 - pasp Atoms +| +| Copyright 2002-2022 Axiomatic Systems, LLC +| +| +| This file is part of Bento4/AP4 (MP4 Atom Processing Library). +| +| Unless you have obtained Bento4 under a difference license, +| this version of Bento4 is Bento4|GPL. +| Bento4|GPL is free software; you can redistribute it and/or modify +| it under the terms of the GNU General Public License as published by +| the Free Software Foundation; either version 2, or (at your option) +| any later version. +| +| Bento4|GPL is distributed in the hope that it will be useful, +| but WITHOUT ANY WARRANTY; without even the implied warranty of +| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +| GNU General Public License for more details. +| +| You should have received a copy of the GNU General Public License +| along with Bento4|GPL; see the file COPYING. If not, write to the +| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA +| 02111-1307, USA. +| +****************************************************************/ + +#ifndef _AP4_PASP_ATOM_H_ +#define _AP4_PASP_ATOM_H_ + +/*---------------------------------------------------------------------- +| includes ++---------------------------------------------------------------------*/ +#include "Ap4Atom.h" + +/*---------------------------------------------------------------------- +| AP4_PaspAtom ++---------------------------------------------------------------------*/ +class AP4_PaspAtom : public AP4_Atom +{ +public: + AP4_IMPLEMENT_DYNAMIC_CAST_D(AP4_PaspAtom, AP4_Atom) + + // class methods + static AP4_PaspAtom* Create(AP4_Size size, AP4_ByteStream& stream); + + // constructors + AP4_PaspAtom(AP4_UI32 hspacing, AP4_UI32 vspacing); + + AP4_PaspAtom(); + + // methods + virtual AP4_Result InspectFields(AP4_AtomInspector& inspector); + virtual AP4_Result WriteFields(AP4_ByteStream& stream); + + // accessors + AP4_UI32 GetHSpacing() const { return m_HSpacing; } + AP4_UI32 GetVSpacing() const { return m_VSpacing; } + +private: + // methods + AP4_PaspAtom(AP4_UI32 size, AP4_ByteStream& stream); + + // members + AP4_UI32 m_HSpacing; + AP4_UI32 m_VSpacing; +}; + +#endif // _AP4_PASP_ATOM_H_