Skip to content

Commit

Permalink
Merge pull request #26 from chemag/main
Browse files Browse the repository at this point in the history
add STSS box
  • Loading branch information
macmade authored Oct 1, 2024
2 parents a48c9de + de98acc commit 250ee71
Show file tree
Hide file tree
Showing 4 changed files with 201 additions and 0 deletions.
1 change: 1 addition & 0 deletions ISOBMFF/include/ISOBMFF.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
#include <ISOBMFF/IPCO.hpp>
#include <ISOBMFF/ImageGrid.hpp>
#include <ISOBMFF/STSD.hpp>
#include <ISOBMFF/STSS.hpp>
#include <ISOBMFF/STTS.hpp>
#include <ISOBMFF/FRMA.hpp>
#include <ISOBMFF/SCHM.hpp>
Expand Down
69 changes: 69 additions & 0 deletions ISOBMFF/include/ISOBMFF/STSS.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2017 DigiDNA - www.digidna.net
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/

/*!
* @header STSS.hpp
* @copyright (c) 2017, DigiDNA - www.digidna.net
* @author Jean-David Gadina - www.digidna.net
*/

#ifndef ISOBMFF_STSS_HPP
#define ISOBMFF_STSS_HPP

#include <memory>
#include <algorithm>
#include <ISOBMFF/Macros.hpp>
#include <ISOBMFF/FullBox.hpp>
#include <string>

namespace ISOBMFF
{
class ISOBMFF_EXPORT STSS: public FullBox
{
public:

STSS();
STSS( const STSS & o );
STSS( STSS && o ) noexcept;
virtual ~STSS() override;

STSS & operator =( STSS o );

void ReadData( Parser & parser, BinaryStream & stream ) override;
std::vector< std::pair< std::string, std::string > > GetDisplayableProperties() const override;

size_t GetEntryCount() const;
uint32_t GetSampleNumber( size_t index ) const;

ISOBMFF_EXPORT friend void swap( STSS & o1, STSS & o2 );

private:

class IMPL;

std::unique_ptr< IMPL > impl;
};
}

#endif /* ISOBMFF_STSS_HPP */
2 changes: 2 additions & 0 deletions ISOBMFF/source/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include <ISOBMFF/PIXI.hpp>
#include <ISOBMFF/IPCO.hpp>
#include <ISOBMFF/STSD.hpp>
#include <ISOBMFF/STSS.hpp>
#include <ISOBMFF/STTS.hpp>
#include <ISOBMFF/FRMA.hpp>
#include <ISOBMFF/SCHM.hpp>
Expand Down Expand Up @@ -368,6 +369,7 @@ namespace ISOBMFF
this->RegisterBox( "pixi", [ = ]() -> std::shared_ptr< Box > { return std::make_shared< PIXI >(); } );
this->RegisterBox( "ipco", [ = ]() -> std::shared_ptr< Box > { return std::make_shared< IPCO >(); } );
this->RegisterBox( "stsd", [ = ]() -> std::shared_ptr< Box > { return std::make_shared< STSD >(); } );
this->RegisterBox( "stss", [ = ]() -> std::shared_ptr< Box > { return std::make_shared< STSS >(); } );
this->RegisterBox( "stts", [ = ]() -> std::shared_ptr< Box > { return std::make_shared< STTS >(); } );
this->RegisterBox( "frma", [ = ]() -> std::shared_ptr< Box > { return std::make_shared< FRMA >(); } );
this->RegisterBox( "schm", [ = ]() -> std::shared_ptr< Box > { return std::make_shared< SCHM >(); } );
Expand Down
129 changes: 129 additions & 0 deletions ISOBMFF/source/STSS.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2017 DigiDNA - www.digidna.net
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/

/*!
* @file STSS.cpp
* @copyright (c) 2017, DigiDNA - www.digidna.net
* @author Jean-David Gadina - www.digidna.net
*/

#include <ISOBMFF/STSS.hpp>
#include <ISOBMFF/Parser.hpp>
#include <cstdint>
#include <cstring>

namespace ISOBMFF
{
class STSS::IMPL
{
public:

IMPL();
IMPL( const IMPL & o );
~IMPL();

std::vector< uint32_t > _sample_number;
};

STSS::STSS():
FullBox( "stss" ),
impl( std::make_unique< IMPL >() )
{}

STSS::STSS( const STSS & o ):
FullBox( o ),
impl( std::make_unique< IMPL >( *( o.impl ) ) )
{}

STSS::STSS( STSS && o ) noexcept:
FullBox( std::move( o ) ),
impl( std::move( o.impl ) )
{
o.impl = nullptr;
}

STSS::~STSS()
{}

STSS & STSS::operator =( STSS o )
{
FullBox::operator=( o );
swap( *( this ), o );

return *( this );
}

void swap( STSS & o1, STSS & o2 )
{
using std::swap;

swap( static_cast< FullBox & >( o1 ), static_cast< FullBox & >( o2 ) );
swap( o1.impl, o2.impl );
}

void STSS::ReadData( Parser & parser, BinaryStream & stream )
{
FullBox::ReadData( parser, stream );

uint32_t entry_count = stream.ReadBigEndianUInt32();

for( uint32_t i = 0; i < entry_count; i++ )
{
this->impl->_sample_number.push_back( stream.ReadBigEndianUInt32() );
}
}

std::vector< std::pair< std::string, std::string > > STSS::GetDisplayableProperties() const
{
auto props( FullBox::GetDisplayableProperties() );

for( unsigned int index = 0; index < this->GetEntryCount(); index++ )
{
props.push_back( { "Sample Number", std::to_string( this->GetSampleNumber( index) ) } );
}

return props;
}

size_t STSS::GetEntryCount() const
{
return this->impl->_sample_number.size();
}

uint32_t STSS::GetSampleNumber( size_t index ) const
{
return this->impl->_sample_number[ index ];
}

STSS::IMPL::IMPL()
{}

STSS::IMPL::IMPL( const IMPL & o )
{
this->_sample_number = o._sample_number;
}

STSS::IMPL::~IMPL()
{}
}

0 comments on commit 250ee71

Please sign in to comment.