예제 #1
0
bool AtomAFRT::ReadData() {
		//FINEST("AFRT");
	if (!ReadUInt32(_timeScale)) {
		FATAL("Unable to read _timeScale");
		return false;
	}
		//FINEST("_timeScale: %"PRIu32, _timeScale);

	if (!ReadUInt8(_qualityEntryCount)) {
		FATAL("Unable to read _qualityEntryCount");
		return false;
	}
		//FINEST("_qualityEntryCount: %"PRIu8, _qualityEntryCount);

	for (uint8_t i = 0; i < _qualityEntryCount; i++) {
		string temp;
		if (!ReadNullTerminatedString(temp)) {
			FATAL("Unable to read QualitySegmentUrlModifiers");
			return false;
		}
		//FINEST("%"PRIu8": QualitySegmentUrlModifiers: %s", i, STR(temp));
		ADD_VECTOR_END(_qualitySegmentUrlModifiers, temp);
	}

	if (!ReadUInt32(_fragmentRunEntryCount)) {
		FATAL("Unable to read _fragmentRunEntryCount");
		return false;
	}
		//FINEST("_fragmentRunEntryCount: %"PRIu32, _fragmentRunEntryCount);

	for (uint32_t i = 0; i < _fragmentRunEntryCount; i++) {
		FRAGMENTRUNENTRY temp = {0, 0, 0, 0};
		if (!ReadUInt32(temp.firstFragment)) {
			FATAL("Unable to read FRAGMENTRUNENTRY.FirstFragment");
			return false;
		}
		if (!ReadUInt64(temp.firstFragmentTimestamp)) {
			FATAL("Unable to read FRAGMENTRUNENTRY.FirstFragmentTimestamp");
			return false;
		}
		if (!ReadUInt32(temp.fragmentDuration)) {
			FATAL("Unable to read FRAGMENTRUNENTRY.FragmentDuration");
			return false;
		}
		if (temp.fragmentDuration == 0) {
			if (!ReadUInt8(temp.discontinuityIndicator)) {
				FATAL("Unable to read FRAGMENTRUNENTRY.DiscontinuityIndicator");
				return false;
			}
		}
				//FINEST("%"PRIu32": FRAGMENTRUNENTRY.FirstFragment: %"PRIu32"; FRAGMENTRUNENTRY.FirstFragmentTimestamp: %"PRIu64"; FRAGMENTRUNENTRY.FragmentDuration: %"PRIu32"; FRAGMENTRUNENTRY.DiscontinuityIndicator: %"PRIu8,
				//		i, temp.firstFragment, temp.firstFragmentTimestamp, temp.fragmentDuration, temp.discontinuityIndicator);
		ADD_VECTOR_END(_fragmentRunEntryTable, temp);
	}

	return true;
}
예제 #2
0
void Font::Load(std::istream& file)
{
	const std::streamoff file_start = file.tellg();

	// Read header
	FourCC header_magic;
	u16 endian;
	u16 version;
	u32 filesize;
	u16 offset; // Offset to first section
	u16 section_count;

	file >> header_magic >> BE >> endian >> version
	     >> filesize >> offset >> section_count;

	// Bad header
	if (header_magic != BINARY_MAGIC_FONT || endian != 0xFEFF || version != 0x0104)
		return;

	// Seek to the first section
	file.seekg(file_start + offset, std::ios::beg);

	ReadSections(file, section_count, [&](FourCC magic, std::streamoff section_start)
	{
		// Glyph group
		if (magic == BINARY_MAGIC_GLYPH_GROUP)
		{
			u32 sheet_size;
			u16 glyphs_per_sheet;

			u16 set_count, sheet_count, cwdh_count, cmap_count;

			file >> BE >> sheet_size >> glyphs_per_sheet
			     >> set_count >> sheet_count >> cwdh_count >> cmap_count;

			std::vector<std::string> sets;

			ReadOffsetList<u16>(file, set_count, file_start, [&]
			{
				sets.push_back(ReadNullTerminatedString(file));
			});

			std::vector<u32> sheet_sizes;
			sheet_sizes.resize(sheet_count);
			if (sheet_count)
				ReadBEArray(file, &sheet_sizes[0], sheet_count);

			std::vector<u32> cwdh_sizes;
			cwdh_sizes.resize(cwdh_count);
			if (cwdh_count)
				ReadBEArray(file, &cwdh_sizes[0], cwdh_count);

			std::vector<u32> cmap_sizes;
			cmap_sizes.resize(cmap_count);
			if (cmap_count)
				ReadBEArray(file, &cmap_sizes[0], cmap_count);

			// Temporary
			// TODO: read bunch of bitsets
			file.seekg((sheet_count + cwdh_count + cmap_count) / 32, std::ios::cur);
		}
		else if (magic == BINARY_MAGIC_FONT_INFORMATION)	// font information