Skip to content

Instantly share code, notes, and snippets.

@usagi
Created March 24, 2017 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save usagi/600968cd3107e43f330d65f7fde3979c to your computer and use it in GitHub Desktop.
Save usagi/600968cd3107e43f330d65f7fde3979c to your computer and use it in GitHub Desktop.
struct frame_type final
{
size_t get_frame_size() const
{ return sizeof( frame_type ) - 1 + data_size; }
  
some_type1 some_header1;
some_type2 some_header2;
size_t data_size = 0;
array< uint8_t, 0 > data;
};
struct video_type final
{
size_t frames_size = 0;
array< frame_type, 0 > frames;
frame_type& operator[]( const size_t target_frame_number )
{
const auto current_frame_address =
reinterpret_cast< uint8_t* >( &frames[ 0 ] )
;
for
( size_t current_frame_number = 0
; current_frame_number < target_frame_number
; ++current_frame_number
)
{
const frame_type& current_frame =
current_frame_address +=
+ reinterpret_cast< const frame_type* >( current_frame_address )->get_frame_size()
;
}
return *current_frame;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment