void Binary::construct(std::string n, BinaryFormat f){ if (f == BinaryFormat_undefined){ f = detectFormat(n); } format = f; EPAXOut << "File " << n << " is a " << getFormatName() << " file" << ENDL; EPAXAssert(format != BinaryFormat_undefined, "Cannot determine format of " << n << ". Try specifying it manually."); switch (format){ case BinaryFormat_Elf32: binary = new Elf::ElfBinary32(n); break; case BinaryFormat_Elf64: binary = new Elf::ElfBinary64(n); break; case BinaryFormat_MachO32: binary = new MachO::MachOBinary32(n); break; case BinaryFormat_MachO64: binary = new MachO::MachOBinary64(n); break; default: EPAXDie("Unimplemented binary format " << getFormatName() << " given."); } EPAXOut << "Program entry point at vaddr " << HEX(binary->getStartAddr()) << ENDL; lineinfo = new LineInformation(binary); binary->describe(); //EPAXAssert(binary->isARM(), "This binary contains non-ARM code... bailing"); }
//----------------------------------------------------------------------- String PixelUtil::getBNFExpressionOfPixelFormats(bool accessibleOnly) { // Collect format names sorted by length, it's required by BNF compiler // that similar tokens need longer ones comes first. typedef multimap<String::size_type, String>::type FormatNameMap; FormatNameMap formatNames; for (size_t i = 0; i < PF_COUNT; ++i) { PixelFormat pf = static_cast<PixelFormat>(i); if (!accessibleOnly || isAccessible(pf)) { String formatName = getFormatName(pf); formatNames.insert(std::make_pair(formatName.length(), formatName)); } } // Populate the BNF expression in reverse order String result; // Note: Stupid M$ VC7.1 can't dealing operator!= with FormatNameMap::const_reverse_iterator. for (FormatNameMap::reverse_iterator j = formatNames.rbegin(); j != formatNames.rend(); ++j) { if (!result.empty()) result += " | "; result += "'" + j->second + "'"; } return result; }
std::string getFormatShortString (const VkFormat format) { const std::string fullName = getFormatName(format); DE_ASSERT(de::beginsWith(fullName, "VK_FORMAT_")); return de::toLower(fullName.substr(10)); }
bool FileProperties::isRawFormat() const { if(getNbStreams() != 1) return false; // the format name should be the same as the codec name if(getFormatName() == getStreamProperties().at(0)->getCodecName()) return true; return false; }
LONG MIDIFormat::dispatchMessage(USHORT usMsg, LONG lParam1, LONG lParam2) { switch (usMsg) { case MMIOM_GETFORMATINFO: return getFormatInfo((PMMFORMATINFO)lParam1); case MMIOM_GETFORMATNAME: return getFormatName((PSZ)lParam1, lParam2); case MMIOM_IDENTIFYFILE: return identifyFile((PSZ)lParam1, (HMMIO)lParam2); default: return defaultResponse(); } }
AudioFormatWriter* LAMEEncoderAudioFormat::createWriterFor (OutputStream* streamToWriteTo, double sampleRateToUse, unsigned int numberOfChannels, int bitsPerSample, const StringPairArray& metadataValues, int qualityOptionIndex) { if (streamToWriteTo == nullptr) return nullptr; int vbr = 4; int cbr = 0; const String qual (getQualityOptions() [qualityOptionIndex]); if (qual.contains ("VBR")) vbr = qual.retainCharacters ("0123456789").getIntValue(); else cbr = qual.getIntValue(); return new Writer (streamToWriteTo, getFormatName(), lameApp, vbr, cbr, sampleRateToUse, numberOfChannels, bitsPerSample, metadataValues); }
//----------------------------------------------------------------------- void PixelUtil::packColour(const float r, const float g, const float b, const float a, const PixelFormat pf, void* dest) { // Catch-it-all here const PixelFormatDescription &des = getDescriptionFor(pf); if(des.flags & PFF_NATIVEENDIAN) { // Do the packing //std::cerr << dest << " " << r << " " << g << " " << b << " " << a << std::endl; const unsigned int value = ((Bitwise::floatToFixed(r, des.rbits)<<des.rshift) & des.rmask) | ((Bitwise::floatToFixed(g, des.gbits)<<des.gshift) & des.gmask) | ((Bitwise::floatToFixed(b, des.bbits)<<des.bshift) & des.bmask) | ((Bitwise::floatToFixed(a, des.abits)<<des.ashift) & des.amask); // And write to memory Bitwise::intWrite(dest, des.elemBytes, value); } else { switch(pf) { case PF_FLOAT32_R: ((float*)dest)[0] = r; break; case PF_FLOAT32_GR: ((float*)dest)[0] = g; ((float*)dest)[1] = r; break; case PF_FLOAT32_RGB: ((float*)dest)[0] = r; ((float*)dest)[1] = g; ((float*)dest)[2] = b; break; case PF_FLOAT32_RGBA: ((float*)dest)[0] = r; ((float*)dest)[1] = g; ((float*)dest)[2] = b; ((float*)dest)[3] = a; break; case PF_FLOAT16_R: ((uint16*)dest)[0] = Bitwise::floatToHalf(r); break; case PF_FLOAT16_GR: ((uint16*)dest)[0] = Bitwise::floatToHalf(g); ((uint16*)dest)[1] = Bitwise::floatToHalf(r); break; case PF_FLOAT16_RGB: ((uint16*)dest)[0] = Bitwise::floatToHalf(r); ((uint16*)dest)[1] = Bitwise::floatToHalf(g); ((uint16*)dest)[2] = Bitwise::floatToHalf(b); break; case PF_FLOAT16_RGBA: ((uint16*)dest)[0] = Bitwise::floatToHalf(r); ((uint16*)dest)[1] = Bitwise::floatToHalf(g); ((uint16*)dest)[2] = Bitwise::floatToHalf(b); ((uint16*)dest)[3] = Bitwise::floatToHalf(a); break; case PF_SHORT_RGB: ((uint16*)dest)[0] = (uint16)Bitwise::floatToFixed(r, 16); ((uint16*)dest)[1] = (uint16)Bitwise::floatToFixed(g, 16); ((uint16*)dest)[2] = (uint16)Bitwise::floatToFixed(b, 16); break; case PF_SHORT_RGBA: ((uint16*)dest)[0] = (uint16)Bitwise::floatToFixed(r, 16); ((uint16*)dest)[1] = (uint16)Bitwise::floatToFixed(g, 16); ((uint16*)dest)[2] = (uint16)Bitwise::floatToFixed(b, 16); ((uint16*)dest)[3] = (uint16)Bitwise::floatToFixed(a, 16); break; case PF_BYTE_LA: ((uint8*)dest)[0] = (uint8)Bitwise::floatToFixed(r, 8); ((uint8*)dest)[1] = (uint8)Bitwise::floatToFixed(a, 8); break; default: // Not yet supported OGRE_EXCEPT( Exception::ERR_NOT_IMPLEMENTED, "pack to "+getFormatName(pf)+" not implemented", "PixelUtil::packColour"); break; } } }