Tawara  0.1.0
Public Member Functions | Friends | List of all members
tawara::SimpleBlock Class Reference

The SimpleBlock element, a simplified version of Blocks. More...

#include <tawara/simple_block.h>

Inheritance diagram for tawara::SimpleBlock:
Inheritance graph
[legend]
Collaboration diagram for tawara::SimpleBlock:
Collaboration graph
[legend]

Public Member Functions

 SimpleBlock (uint64_t track_number, int16_t timecode, LacingType lacing=LACING_NONE)
 Create a new SimpleBlock element. More...
 
bool keyframe () const
 Check if this block is a keyframe or not. More...
 
void keyframe (bool keyframe)
 Set if this block is a keyframe. More...
 
bool discardable () const
 Check if this block can be discarded during playback. More...
 
void discardable (bool discardable)
 Set if this block can be discarded during playback. More...
 
virtual uint64_t track_number () const
 The block's track number. More...
 
virtual void track_number (uint64_t track_number)
 Set the block's track number. More...
 
virtual int16_t timecode () const
 The timecode of this block. More...
 
virtual void timecode (int16_t timecode)
 Set the block's timecode. More...
 
virtual bool invisible () const
 If this block is invisible. More...
 
virtual void invisible (bool invisible)
 Set if this block is invisible. More...
 
virtual LacingType lacing () const
 Get the lacing type in use. More...
 
virtual void lacing (LacingType lacing)
 Set the lacing type in use. More...
 
virtual value_typeat (size_type pos)
 Get the frame at the given position, with bounds checking. More...
 
virtual value_type const & at (size_type pos) const
 Get the frame at the given position, with bounds checking. More...
 
virtual value_typeoperator[] (size_type pos)
 Get a reference to a frame. More...
 
virtual value_type const & operator[] (size_type pos) const
 Get a reference to a frame. More...
 
virtual iterator begin ()
 Get an iterator to the first frame. More...
 
virtual const_iterator begin () const
 Get an iterator to the first frame. More...
 
virtual iterator end ()
 Get an iterator to the position past the last frame. More...
 
virtual const_iterator end () const
 Get an iterator to the position past the last frame. More...
 
virtual reverse_iterator rbegin ()
 Get a reverse iterator to the last frame. More...
 
virtual const_reverse_iterator rbegin () const
 Get a reverse iterator to the last frame. More...
 
virtual reverse_iterator rend ()
 Get a reverse iterator to the position before the first frame. More...
 
virtual const_reverse_iterator rend () const
 Get a reverse iterator to the position before the first frame. More...
 
virtual bool empty () const
 Check if there are no frames. More...
 
virtual size_type count () const
 Get the number of frames. More...
 
virtual size_type max_count () const
 Get the maximum number of frames. More...
 
virtual void clear ()
 Remove all frames. More...
 
virtual void erase (iterator position)
 Erase the frame at the specified iterator. More...
 
virtual void erase (iterator first, iterator last)
 Erase a range of frames. More...
 
virtual void push_back (value_type const &value)
 Add a frame to this block. More...
 
virtual void resize (size_type count)
 Resizes the frames storage. More...
 
virtual void swap (SimpleBlock &other)
 Swaps the contents of this block with another. More...
 
- Public Member Functions inherited from tawara::BlockElement
 BlockElement (tawara::ids::ID id, uint64_t track_number, int16_t timecode, LacingType lacing=LACING_NONE)
 
- Public Member Functions inherited from tawara::Element
 Element (tawara::ids::ID id)
 Create a new Element. More...
 
virtual ~Element ()
 Destructor. More...
 
uint32_t id () const
 Get the element's ID. More...
 
std::streampos offset () const
 Get the element's offset in the byte stream. More...
 
virtual std::streamsize size () const
 Get the total size of the element. More...
 
virtual std::streamsize write (std::ostream &output)
 Element writing. More...
 
virtual std::streamsize read (std::istream &input)
 Element reading. More...
 
- Public Member Functions inherited from tawara::Block
 Block (uint64_t track_number, int16_t timecode, LacingType lacing=LACING_NONE)
 Constructor. More...
 
virtual ~Block ()=0
 Desctructor. More...
 
virtual void swap (Block &other)
 Swaps the contents of this block with another. More...
 

Friends

bool operator== (SimpleBlock const &lhs, SimpleBlock const &rhs)
 Equality operator. More...
 

Additional Inherited Members

- Public Types inherited from tawara::BlockElement
typedef boost::shared_ptr
< BlockElement
Ptr
 
- Public Types inherited from tawara::Block
enum  LacingType { LACING_NONE, LACING_EBML, LACING_FIXED }
 Lacing types. More...
 
typedef boost::shared_ptr< BlockPtr
 Pointer to a block. More...
 
typedef boost::shared_ptr
< Block const > 
ConstPtr
 Constant pointer to a block. More...
 
typedef std::vector< char > Frame
 The type of a single frame of data. More...
 
typedef boost::shared_ptr< FrameFramePtr
 A pointer to a frame of data. More...
 
typedef std::vector< FramePtr >
::value_type 
value_type
 The value type of this container. More...
 
typedef std::vector< FramePtr >
::size_type 
size_type
 The size type of this container. More...
 
typedef std::vector< FramePtr >
::reference 
reference
 The reference type. More...
 
typedef std::vector< FramePtr >
::const_reference 
const_reference
 The constant reference type. More...
 
typedef std::vector< FramePtr >
::iterator 
iterator
 The random access iterator type. More...
 
typedef std::vector< FramePtr >
::const_iterator 
const_iterator
 The constant random access iterator type. More...
 
typedef std::vector< FramePtr >
::reverse_iterator 
reverse_iterator
 The reversed random access iterator type. More...
 
typedef std::vector< FramePtr >
::const_reverse_iterator 
const_reverse_iterator
 The constant reversed random access iterator type. More...
 
- Protected Member Functions inherited from tawara::Element
std::streamsize write_id (std::ostream &output)
 Element ID writing. More...
 
virtual std::streamsize write_size (std::ostream &output)
 Element size writing. More...
 
- Protected Attributes inherited from tawara::Element
tawara::ids::ID id_
 
std::streampos offset_
 

Detailed Description

The SimpleBlock element, a simplified version of Blocks.

The SimpleBlock element is used to store a block of data without any extra information, such as reference frames or private codec data. The block is stored as a binary element, with the internal format of the binary data specified by the Simple Block format, which this element implementation interprets.

Definition at line 59 of file simple_block.h.

Constructor & Destructor Documentation

tawara::SimpleBlock::SimpleBlock ( uint64_t  track_number,
int16_t  timecode,
LacingType  lacing = LACING_NONE 
)

Create a new SimpleBlock element.

Parameters
[in]track_numberThe track number this block belongs to.
[in]timecodeThe timecode of this block.
[in]lacingThe type of lacing to use.

Member Function Documentation

virtual value_type& tawara::SimpleBlock::at ( size_type  pos)
inlinevirtual

Get the frame at the given position, with bounds checking.

Returns
A reference to the specified frame's data.
Exceptions
std::out_of_rangeif the position is invalid.

Implements tawara::Block.

Definition at line 161 of file simple_block.h.

virtual value_type const& tawara::SimpleBlock::at ( size_type  pos) const
inlinevirtual

Get the frame at the given position, with bounds checking.

Returns
A reference to the specified frame's data.
Exceptions
std::out_of_rangeif the position is invalid.

Implements tawara::Block.

Definition at line 168 of file simple_block.h.

virtual iterator tawara::SimpleBlock::begin ( )
inlinevirtual

Get an iterator to the first frame.

Implements tawara::Block.

Definition at line 189 of file simple_block.h.

virtual const_iterator tawara::SimpleBlock::begin ( ) const
inlinevirtual

Get an iterator to the first frame.

Implements tawara::Block.

Definition at line 191 of file simple_block.h.

virtual void tawara::SimpleBlock::clear ( )
inlinevirtual

Remove all frames.

Implements tawara::Block.

Definition at line 229 of file simple_block.h.

virtual size_type tawara::SimpleBlock::count ( ) const
inlinevirtual

Get the number of frames.

Implements tawara::Block.

Definition at line 218 of file simple_block.h.

bool tawara::SimpleBlock::discardable ( ) const
inline

Check if this block can be discarded during playback.

Definition at line 90 of file simple_block.h.

void tawara::SimpleBlock::discardable ( bool  discardable)
inline

Set if this block can be discarded during playback.

How this flag is used is codec-dependent.

Some frames of data can be discarded without affecting the decoding of subsequent frames. In simple codecs, which do not have a continuously-updating state, every frame may be considered discardable. For codecs that need to know which frames matter when dropping frames to keep up with timing requirements, this flag is important.

Definition at line 102 of file simple_block.h.

virtual bool tawara::SimpleBlock::empty ( ) const
inlinevirtual

Check if there are no frames.

Empty blocks cannot be written. If this returns true, an error will occur when write() is called.

Implements tawara::Block.

Definition at line 216 of file simple_block.h.

virtual iterator tawara::SimpleBlock::end ( )
inlinevirtual

Get an iterator to the position past the last frame.

Implements tawara::Block.

Definition at line 193 of file simple_block.h.

virtual const_iterator tawara::SimpleBlock::end ( ) const
inlinevirtual

Get an iterator to the position past the last frame.

Implements tawara::Block.

Definition at line 195 of file simple_block.h.

virtual void tawara::SimpleBlock::erase ( iterator  position)
inlinevirtual

Erase the frame at the specified iterator.

Parameters
[in]positionThe position to erase at.

Implements tawara::Block.

Definition at line 235 of file simple_block.h.

virtual void tawara::SimpleBlock::erase ( iterator  first,
iterator  last 
)
inlinevirtual

Erase a range of frames.

Parameters
[in]firstThe start of the range.
[in]lastThe end of the range.

Implements tawara::Block.

Definition at line 241 of file simple_block.h.

virtual bool tawara::SimpleBlock::invisible ( ) const
inlinevirtual

If this block is invisible.

Invisible blocks should be decoded by the codec (thus updating codec state) but not used for playback.

Implements tawara::Block.

Definition at line 136 of file simple_block.h.

virtual void tawara::SimpleBlock::invisible ( bool  invisible)
inlinevirtual

Set if this block is invisible.

Implements tawara::Block.

Definition at line 138 of file simple_block.h.

bool tawara::SimpleBlock::keyframe ( ) const
inline

Check if this block is a keyframe or not.

Definition at line 73 of file simple_block.h.

void tawara::SimpleBlock::keyframe ( bool  keyframe)
inline

Set if this block is a keyframe.

How this flag is used is codec-dependent.

Keyframe blocks are generally of high importance to the codec, as they provide a complete, independent frame of data that does not rely on other frames to be decoded. In some codecs they may allow the codec to completely re-initialise its state, which is useful if previous frames have been corrupted. In the simple codecs, which do not perform inter-frame encoding, keyframes are irrelevant and so every frame has equal status, making this flag irrelevant.

Definition at line 87 of file simple_block.h.

virtual LacingType tawara::SimpleBlock::lacing ( ) const
inlinevirtual

Get the lacing type in use.

The data in a block is typically a single frame, but sometimes multiple frames may be stored. This is called "lacing," and is usually used to reduce overhead when the size of the data itself is small. However, lacing also reduces seekability of the file, so laces should usually be kept small. A common number is up to three frames in a lace.

Implements tawara::Block.

Definition at line 150 of file simple_block.h.

virtual void tawara::SimpleBlock::lacing ( LacingType  lacing)
inlinevirtual

Set the lacing type in use.

Implements tawara::Block.

Definition at line 152 of file simple_block.h.

virtual size_type tawara::SimpleBlock::max_count ( ) const
inlinevirtual

Get the maximum number of frames.

If lacing is not enabled, this will always return 1.

If lacing is enabled, this will be the maximum number of frames that can be stored in a lace within a single block.

Implements tawara::Block.

Definition at line 226 of file simple_block.h.

virtual value_type& tawara::SimpleBlock::operator[] ( size_type  pos)
inlinevirtual

Get a reference to a frame.

No bounds checking is performed.

Returns
A reference to the binary data of a frame stored in this block.

Implements tawara::Block.

Definition at line 177 of file simple_block.h.

virtual value_type const& tawara::SimpleBlock::operator[] ( size_type  pos) const
inlinevirtual

Get a reference to a frame.

No bounds checking is performed.

Returns
A reference to the binary data of a frame stored in this block.

Implements tawara::Block.

Definition at line 185 of file simple_block.h.

virtual void tawara::SimpleBlock::push_back ( value_type const &  value)
inlinevirtual

Add a frame to this block.

When lacing is enabled, this will append an additional frame to the block to be stored.

When lacing is not enabled, the value of frame_count() must be zero or an error will occur.

Exceptions
MaxLaceSizeExceededif the new size is incompatible with the lacing type.
EmptyFrameif the frame data is empty.

Implements tawara::Block.

Definition at line 256 of file simple_block.h.

virtual reverse_iterator tawara::SimpleBlock::rbegin ( )
inlinevirtual

Get a reverse iterator to the last frame.

Implements tawara::Block.

Definition at line 197 of file simple_block.h.

virtual const_reverse_iterator tawara::SimpleBlock::rbegin ( ) const
inlinevirtual

Get a reverse iterator to the last frame.

Implements tawara::Block.

Definition at line 199 of file simple_block.h.

virtual reverse_iterator tawara::SimpleBlock::rend ( )
inlinevirtual

Get a reverse iterator to the position before the first frame.

Implements tawara::Block.

Definition at line 204 of file simple_block.h.

virtual const_reverse_iterator tawara::SimpleBlock::rend ( ) const
inlinevirtual

Get a reverse iterator to the position before the first frame.

Implements tawara::Block.

Definition at line 208 of file simple_block.h.

virtual void tawara::SimpleBlock::resize ( size_type  count)
inlinevirtual

Resizes the frames storage.

When lacing is not enabled, the new size must be 1 or an error will occur.

If the current size is less than the new size, additional empty frames will be added. These should be filled with data before calling write() or an error will occur.

If the current size is greater than the new size, frames past the new end will be dropped.

Exceptions
MaxLaceSizeExceededif the new size is incompatible with the lacing type.

Implements tawara::Block.

Definition at line 274 of file simple_block.h.

virtual void tawara::SimpleBlock::swap ( SimpleBlock other)
virtual

Swaps the contents of this block with another.

Parameters
[in]otherThe other block to swap with.
virtual int16_t tawara::SimpleBlock::timecode ( ) const
inlinevirtual

The timecode of this block.

Each block has a timecode relative to its containing cluster. It is measured in the units specified by the containing segment's TimecodeScale, and is a 16-bit signed integer.

Implements tawara::Block.

Definition at line 126 of file simple_block.h.

virtual void tawara::SimpleBlock::timecode ( int16_t  timecode)
inlinevirtual

Set the block's timecode.

Implements tawara::Block.

Definition at line 128 of file simple_block.h.

virtual uint64_t tawara::SimpleBlock::track_number ( ) const
inlinevirtual

The block's track number.

This property specifies the track that this block belongs to. The data stored in the block should be interpreted by the codec for its track.

Implements tawara::Block.

Definition at line 114 of file simple_block.h.

virtual void tawara::SimpleBlock::track_number ( uint64_t  track_number)
inlinevirtual

Set the block's track number.

Implements tawara::Block.

Definition at line 117 of file simple_block.h.

Friends And Related Function Documentation

bool operator== ( SimpleBlock const &  lhs,
SimpleBlock const &  rhs 
)
friend

Equality operator.


The documentation for this class was generated from the following file: