Exemplo n.º 1
0
unsigned short Reader::ReadUnsignedShortOrDie(void) {
  unsigned short s;
  if (! ReadUnsignedShort(&s)) {
    fprintf(stderr, "Couldn't read unsigned short; file %s byte pos %lli "
	    "file_size %lli\n", filename_.c_str(), byte_pos_, file_size_);
    exit(-1);
  }
  return s;
}
Exemplo n.º 2
0
static void	ProcessStsdAtom( char* atomData, qtmovie_t* qtmovie )
{	
	unsigned int entrySize;
	unsigned int numEntries = ReadUnsignedInt( &atomData[ 4 ] );

	// According to original source, we only expect one entry in sample description atom
	if ( numEntries != 1 )
		return;
	
	// The size of the entry is...?
	entrySize = ReadUnsignedInt( &atomData[ 8 ] );
	qtmovie->res->format = ReadUnsignedInt( &atomData[ 12 ] );

	if ( qtmovie->res->format == MAKE_ATOM_NAME( 'a', 'l', 'a', 'c' ) )
	{
		g_IsAppleLossless = 1;

		qtmovie->res->num_channels	= ReadUnsignedShort( &atomData[ 32 ] );
		qtmovie->res->sample_size	= ReadUnsignedShort( &atomData[ 34 ] );
		qtmovie->res->sample_rate	= ReadUnsignedShort( &atomData[ 40 ] );

		// 36 is the bytes for prior to codec data for this entry.
		// 12 is the additional size of our atom header (the 3 uint writes)
		// 8 is for padding, as the original code is a bit paranoid..
		qtmovie->res->codecdata_len = ( entrySize - 36 ) + 12 + 8;
		qtmovie->res->codecdata = malloc( qtmovie->res->codecdata_len );
		memset( qtmovie->res->codecdata, 0, qtmovie->res->codecdata_len );
		
		( ( unsigned int* )qtmovie->res->codecdata )[0] = 0x0c000000;
		( ( unsigned int* )qtmovie->res->codecdata )[1] = MAKE_ATOM_NAME( 'a', 'm', 'r', 'f' );
		( ( unsigned int* )qtmovie->res->codecdata )[2] = MAKE_ATOM_NAME( 'c', 'a', 'l', 'a' );
		memcpy( ( ( char* )qtmovie->res->codecdata ) + 12, &atomData[ 44 ], qtmovie->res->codecdata_len - 8 );
	}
	else
	{
		// Not an apple lossless file.. not interested.
		g_StopParsing = 1;
	}
}