|
| 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 | +} |
0 commit comments