Skip to content

Commit 8d0900e

Browse files
authored
Merge pull request #27 from chemag/main
add HVC1 box
2 parents 59bb0f9 + 7a876f2 commit 8d0900e

File tree

4 files changed

+366
-0
lines changed

4 files changed

+366
-0
lines changed

ISOBMFF/include/ISOBMFF.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
#include <ISOBMFF/STTS.hpp>
7777
#include <ISOBMFF/FRMA.hpp>
7878
#include <ISOBMFF/SCHM.hpp>
79+
#include <ISOBMFF/HVC1.hpp>
7980

8081
#ifdef _WIN32
8182
#include <ISOBMFF/WIN32.hpp>

ISOBMFF/include/ISOBMFF/HVC1.hpp

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*******************************************************************************
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2017 DigiDNA - www.digidna.net
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
******************************************************************************/
24+
25+
/*!
26+
* @header HVC1.hpp
27+
* @copyright (c) 2017, DigiDNA - www.digidna.net
28+
* @author Jean-David Gadina - www.digidna.net
29+
*/
30+
31+
#ifndef ISOBMFF_HVC1_HPP
32+
#define ISOBMFF_HVC1_HPP
33+
34+
#include <memory>
35+
#include <algorithm>
36+
#include <ISOBMFF/Macros.hpp>
37+
#include <ISOBMFF/FullBox.hpp>
38+
#include <ISOBMFF/Container.hpp>
39+
#include <cstdint>
40+
41+
namespace ISOBMFF
42+
{
43+
class ISOBMFF_EXPORT HVC1: public FullBox, public Container
44+
{
45+
public:
46+
47+
HVC1();
48+
HVC1( const HVC1 & o );
49+
HVC1( HVC1 && o ) noexcept;
50+
virtual ~HVC1() override;
51+
52+
HVC1 & operator =( HVC1 o );
53+
54+
void ReadData( Parser & parser, BinaryStream & stream ) override;
55+
void WriteDescription( std::ostream & os, std::size_t indentLevel ) const override;
56+
57+
std::vector< std::pair< std::string, std::string > > GetDisplayableProperties() const override;
58+
59+
uint16_t GetDataReferenceIndex() const;
60+
uint16_t GetWidth() const;
61+
uint16_t GetHeight() const;
62+
uint32_t GetHorizResolution() const;
63+
uint32_t GetVertResolution() const;
64+
uint16_t GetFrameCount() const;
65+
std::string GetCompressorName() const;
66+
uint16_t GetDepth() const;
67+
68+
void SetDataReferenceIndex( uint16_t value );
69+
void SetWidth( uint16_t value );
70+
void SetHeight( uint16_t value );
71+
void SetHorizResolution( uint32_t value );
72+
void SetVertResolution( uint32_t value );
73+
void SetFrameCount( uint16_t value );
74+
void SetCompressorName( std::string value );
75+
void SetDepth( uint16_t value );
76+
77+
void AddBox( std::shared_ptr< Box > box ) override;
78+
std::vector< std::shared_ptr< Box > > GetBoxes() const override;
79+
80+
ISOBMFF_EXPORT friend void swap( HVC1 & o1, HVC1 & o2 );
81+
82+
private:
83+
84+
class IMPL;
85+
86+
std::unique_ptr< IMPL > impl;
87+
};
88+
}
89+
90+
#endif /* ISOBMFF_HVC1_HPP */

ISOBMFF/source/HVC1.cpp

Lines changed: 273 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
1+
/*******************************************************************************
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2017 DigiDNA - www.digidna.net
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
******************************************************************************/
24+
25+
/*!
26+
* @file HVC1.cpp
27+
* @copyright (c) 2017, DigiDNA - www.digidna.net
28+
* @author Jean-David Gadina - www.digidna.net
29+
*/
30+
31+
#include <ISOBMFF/HVC1.hpp>
32+
#include <ISOBMFF/ContainerBox.hpp>
33+
34+
namespace ISOBMFF
35+
{
36+
class HVC1::IMPL
37+
{
38+
public:
39+
40+
IMPL();
41+
IMPL( const IMPL & o );
42+
~IMPL();
43+
44+
uint16_t _data_reference_index;
45+
uint16_t _width;
46+
uint16_t _height;
47+
uint32_t _horizresolution;
48+
uint32_t _vertresolution;
49+
uint16_t _frame_count;
50+
std::string _compressorname;
51+
uint16_t _depth;
52+
53+
std::vector< std::shared_ptr< Box > > _boxes;
54+
};
55+
56+
HVC1::HVC1():
57+
FullBox( "hvc1" ),
58+
impl( std::make_unique< IMPL >() )
59+
{}
60+
61+
HVC1::HVC1( const HVC1 & o ):
62+
FullBox( o ),
63+
impl( std::make_unique< IMPL >( *( o.impl ) ) )
64+
{}
65+
66+
HVC1::HVC1( HVC1 && o ) noexcept:
67+
FullBox( std::move( o ) ),
68+
impl( std::move( o.impl ) )
69+
{
70+
o.impl = nullptr;
71+
}
72+
73+
HVC1::~HVC1()
74+
{}
75+
76+
HVC1 & HVC1::operator =( HVC1 o )
77+
{
78+
FullBox::operator=( o );
79+
swap( *( this ), o );
80+
81+
return *( this );
82+
}
83+
84+
void swap( HVC1 & o1, HVC1 & o2 )
85+
{
86+
using std::swap;
87+
88+
swap( static_cast< FullBox & >( o1 ), static_cast< FullBox & >( o2 ) );
89+
swap( o1.impl, o2.impl );
90+
}
91+
92+
void HVC1::ReadData( Parser & parser, BinaryStream & stream )
93+
{
94+
ContainerBox container( "????" );
95+
96+
// SampleEntry
97+
// reserved[]
98+
stream.ReadUInt8();
99+
stream.ReadUInt8();
100+
stream.ReadUInt8();
101+
stream.ReadUInt8();
102+
stream.ReadUInt8();
103+
stream.ReadUInt8();
104+
// data_reference_index
105+
this->SetDataReferenceIndex( stream.ReadBigEndianUInt16() );
106+
// VisualSampleEntry
107+
// pre_defined1
108+
stream.ReadBigEndianUInt16();
109+
// reserved1
110+
stream.ReadBigEndianUInt16();
111+
// pre_defined2
112+
stream.ReadBigEndianUInt32();
113+
stream.ReadBigEndianUInt32();
114+
stream.ReadBigEndianUInt32();
115+
this->SetWidth( stream.ReadBigEndianUInt16() );
116+
this->SetHeight( stream.ReadBigEndianUInt16() );
117+
this->SetHorizResolution( stream.ReadBigEndianUInt32() );
118+
this->SetVertResolution( stream.ReadBigEndianUInt32() );
119+
// reserved2
120+
stream.ReadBigEndianUInt32();
121+
this->SetFrameCount( stream.ReadBigEndianUInt16() );
122+
this->SetCompressorName( stream.ReadString(32) );
123+
this->SetDepth( stream.ReadBigEndianUInt16() );
124+
// pre_defined3
125+
stream.ReadBigEndianUInt16();
126+
127+
container.ReadData( parser, stream );
128+
129+
this->impl->_boxes = container.GetBoxes();
130+
}
131+
132+
std::vector< std::pair< std::string, std::string > > HVC1::GetDisplayableProperties() const
133+
{
134+
auto props( FullBox::GetDisplayableProperties() );
135+
136+
props.push_back( { "Data Reference Index", std::to_string( this->GetDataReferenceIndex() ) } );
137+
props.push_back( { "Width", std::to_string( this->GetWidth() ) } );
138+
props.push_back( { "Height", std::to_string( this->GetHeight() ) } );
139+
props.push_back( { "Horizontal Resolution", std::to_string( this->GetHorizResolution() ) } );
140+
props.push_back( { "Vertical Resolution", std::to_string( this->GetVertResolution() ) } );
141+
props.push_back( { "Frame Count", std::to_string( this->GetFrameCount() ) } );
142+
props.push_back( { "Compressor Name", this->GetCompressorName() } );
143+
props.push_back( { "Depth", std::to_string( this->GetDepth() ) } );
144+
145+
return props;
146+
}
147+
148+
void HVC1::WriteDescription( std::ostream & os, std::size_t indentLevel ) const
149+
{
150+
FullBox::WriteDescription( os, indentLevel );
151+
Container::WriteBoxes( os, indentLevel );
152+
}
153+
154+
uint16_t HVC1::GetDataReferenceIndex() const
155+
{
156+
return this->impl->_data_reference_index;
157+
}
158+
159+
uint16_t HVC1::GetWidth() const
160+
{
161+
return this->impl->_width;
162+
}
163+
164+
uint16_t HVC1::GetHeight() const
165+
{
166+
return this->impl->_height;
167+
}
168+
169+
uint32_t HVC1::GetHorizResolution() const
170+
{
171+
return this->impl->_horizresolution;
172+
}
173+
174+
uint32_t HVC1::GetVertResolution() const
175+
{
176+
return this->impl->_vertresolution;
177+
}
178+
179+
uint16_t HVC1::GetFrameCount() const
180+
{
181+
return this->impl->_frame_count;
182+
}
183+
184+
std::string HVC1::GetCompressorName() const
185+
{
186+
return this->impl->_compressorname;
187+
}
188+
189+
uint16_t HVC1::GetDepth() const
190+
{
191+
return this->impl->_depth;
192+
}
193+
194+
195+
void HVC1::SetDataReferenceIndex( uint16_t value )
196+
{
197+
this->impl->_data_reference_index = value;
198+
}
199+
200+
void HVC1::SetWidth( uint16_t value )
201+
{
202+
this->impl->_width = value;
203+
}
204+
205+
void HVC1::SetHeight( uint16_t value )
206+
{
207+
this->impl->_height = value;
208+
}
209+
210+
void HVC1::SetHorizResolution( uint32_t value )
211+
{
212+
this->impl->_horizresolution = value;
213+
}
214+
215+
void HVC1::SetVertResolution( uint32_t value )
216+
{
217+
this->impl->_vertresolution = value;
218+
}
219+
220+
void HVC1::SetFrameCount( uint16_t value )
221+
{
222+
this->impl->_frame_count = value;
223+
}
224+
225+
void HVC1::SetCompressorName( std::string value )
226+
{
227+
this->impl->_compressorname = value;
228+
}
229+
230+
void HVC1::SetDepth( uint16_t value )
231+
{
232+
this->impl->_depth = value;
233+
}
234+
235+
void HVC1::AddBox( std::shared_ptr< Box > box )
236+
{
237+
if( box != nullptr )
238+
{
239+
this->impl->_boxes.push_back( box );
240+
}
241+
}
242+
243+
std::vector< std::shared_ptr< Box > > HVC1::GetBoxes() const
244+
{
245+
return this->impl->_boxes;
246+
}
247+
248+
HVC1::IMPL::IMPL():
249+
_data_reference_index( 0 ),
250+
_width( 0 ),
251+
_height( 0 ),
252+
_horizresolution( 0 ),
253+
_vertresolution( 0 ),
254+
_frame_count( 0 ),
255+
_compressorname( "" ),
256+
_depth( 0 )
257+
{}
258+
259+
HVC1::IMPL::IMPL( const IMPL & o ):
260+
_data_reference_index( o._data_reference_index ),
261+
_width( o._width ),
262+
_height( o._height ),
263+
_horizresolution( o._horizresolution ),
264+
_vertresolution( o._vertresolution ),
265+
_frame_count( o._frame_count ),
266+
_compressorname( o._compressorname ),
267+
_depth( o._depth ),
268+
_boxes( o._boxes )
269+
{}
270+
271+
HVC1::IMPL::~IMPL()
272+
{}
273+
}

ISOBMFF/source/Parser.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#include <ISOBMFF/STTS.hpp>
6262
#include <ISOBMFF/FRMA.hpp>
6363
#include <ISOBMFF/SCHM.hpp>
64+
#include <ISOBMFF/HVC1.hpp>
6465
#include <map>
6566
#include <stdexcept>
6667
#include <cstring>
@@ -373,5 +374,6 @@ namespace ISOBMFF
373374
this->RegisterBox( "stts", [ = ]() -> std::shared_ptr< Box > { return std::make_shared< STTS >(); } );
374375
this->RegisterBox( "frma", [ = ]() -> std::shared_ptr< Box > { return std::make_shared< FRMA >(); } );
375376
this->RegisterBox( "schm", [ = ]() -> std::shared_ptr< Box > { return std::make_shared< SCHM >(); } );
377+
this->RegisterBox( "hvc1", [ = ]() -> std::shared_ptr< Box > { return std::make_shared< HVC1 >(); } );
376378
}
377379
}

0 commit comments

Comments
 (0)