void CMVDAtom::OnProcessMetaData() { Read(&UncompressedSize); if (UncompressedSize > 0) { BufferSize = getBytesRemaining(); Buffer = (uint8 *)(malloc(BufferSize)); Read(Buffer,BufferSize); } }
WrappedMemoryInputStream::SizeType WrappedMemoryInputStream::read( void* buffer, SizeType bytesToRead) { DCHECK(bytesToRead >= 0); SizeType num = std::min(bytesToRead, getBytesRemaining()); std::memcpy(buffer, static_cast<const u8*>(m_data) + m_currentPosition, static_cast<size_t>(num)); m_currentPosition += num; return num; }
void FTYPAtom::OnProcessMetaData() { // ftyp is really an mp4 thing, but some mov encoders are adding it anyway. // but a mov file with an ftyp should define a brand of qt (I think) Read(&major_brand); Read(&minor_version); total_brands = getBytesRemaining() / sizeof(uint32); if (total_brands > 32) { total_brands = 32; // restrict to 32 } for (uint32 i=0;i<total_brands;i++) { Read(&compatable_brands[i]); } }
void STSDAtom::ReadVideoDescription() { uint64 descBytesLeft; // read in Video Sample Data VideoDescriptionV0 *aVideoDescription; aVideoDescription = new VideoDescriptionV0; Read(&aVideoDescription->basefields.Size); Read(&aVideoDescription->basefields.DataFormat); Read(aVideoDescription->basefields.Reserved,6); Read(&aVideoDescription->basefields.DataReference); Read(&aVideoDescription->desc.Version); Read(&aVideoDescription->desc.Revision); Read(&aVideoDescription->desc.Vendor); Read(&aVideoDescription->desc.TemporaralQuality); Read(&aVideoDescription->desc.SpacialQuality); Read(&aVideoDescription->desc.Width); Read(&aVideoDescription->desc.Height); Read(&aVideoDescription->desc.HorizontalResolution); Read(&aVideoDescription->desc.VerticalResolution); Read(&aVideoDescription->desc.DataSize); // FrameCount is actually No of Frames per Sample which is usually 1 Read(&aVideoDescription->desc.FrameCount); Read(aVideoDescription->desc.CompressorName,32); Read(&aVideoDescription->desc.Depth); Read(&aVideoDescription->desc.ColourTableID); aVideoDescription->VOLSize = 0; aVideoDescription->theVOL = NULL; theVideoDescArray[0] = aVideoDescription; descBytesLeft = getBytesRemaining(); // May be a VOL // If not then seek back to where we are as it may be a complete new video description if (descBytesLeft > 0) { off_t pos = theStream->Position(); // More extended atoms AtomBase *aAtomBase = getAtom(theStream); aAtomBase->OnProcessMetaData(); printf("%s\n",aAtomBase->getAtomName()); if (dynamic_cast<ESDSAtom *>(aAtomBase)) { // ESDS atom good aVideoDescription->VOLSize = aAtomBase->getDataSize(); aVideoDescription->theVOL = (uint8 *)(malloc(aVideoDescription->VOLSize)); memcpy(aVideoDescription->theVOL,dynamic_cast<ESDSAtom *>(aAtomBase)->getVOL(),aVideoDescription->VOLSize); } else { // Seek Back theStream->Seek(pos,SEEK_SET); } delete aAtomBase; } PRINT(("Size:Format=%ld:%ld %Ld\n",aVideoDescription->basefields.Size,aVideoDescription->basefields.DataFormat,getBytesRemaining())); }
void STSDAtom::ReadSoundDescription() { uint64 descBytesLeft; SoundDescriptionV1 *aSoundDescriptionV1; aSoundDescriptionV1 = new SoundDescriptionV1; Read(&aSoundDescriptionV1->basefields.Size); Read(&aSoundDescriptionV1->basefields.DataFormat); Read(aSoundDescriptionV1->basefields.Reserved,6); Read(&aSoundDescriptionV1->basefields.DataReference); aSoundDescriptionV1->VOLSize = 0; aSoundDescriptionV1->theVOL = NULL; // Read in Audio Sample Data // We place into a V1 description even though it might be a V0 or earlier Read(&aSoundDescriptionV1->desc.Version); Read(&aSoundDescriptionV1->desc.Revision); Read(&aSoundDescriptionV1->desc.Vendor); Read(&aSoundDescriptionV1->desc.NoOfChannels); Read(&aSoundDescriptionV1->desc.SampleSize); Read(&aSoundDescriptionV1->desc.CompressionID); Read(&aSoundDescriptionV1->desc.PacketSize); Read(&aSoundDescriptionV1->desc.SampleRate); if ((aSoundDescriptionV1->desc.Version == 1) && (aSoundDescriptionV1->basefields.DataFormat != AUDIO_IMA4)) { Read(&(aSoundDescriptionV1->samplesPerPacket)); Read(&(aSoundDescriptionV1->bytesPerPacket)); Read(&(aSoundDescriptionV1->bytesPerFrame)); Read(&(aSoundDescriptionV1->bytesPerSample)); } else { // Calculate? if (aSoundDescriptionV1->basefields.DataFormat == AUDIO_IMA4) { aSoundDescriptionV1->samplesPerPacket = 64; aSoundDescriptionV1->bytesPerFrame = aSoundDescriptionV1->desc.NoOfChannels * 34; aSoundDescriptionV1->bytesPerSample = aSoundDescriptionV1->desc.SampleSize / 8; aSoundDescriptionV1->bytesPerPacket = 64 * aSoundDescriptionV1->bytesPerFrame; } else { aSoundDescriptionV1->bytesPerSample = aSoundDescriptionV1->desc.SampleSize / 8; aSoundDescriptionV1->bytesPerFrame = aSoundDescriptionV1->desc.NoOfChannels * aSoundDescriptionV1->bytesPerSample; aSoundDescriptionV1->bytesPerPacket = aSoundDescriptionV1->desc.PacketSize; aSoundDescriptionV1->samplesPerPacket = aSoundDescriptionV1->desc.PacketSize / aSoundDescriptionV1->bytesPerFrame; } } // 0 means we dont have one aSoundDescriptionV1->theWaveFormat.format_tag = 0; descBytesLeft = getBytesRemaining(); while (descBytesLeft > 0) { // More extended atoms AtomBase *aAtomBase = getAtom(theStream); aAtomBase->OnProcessMetaData(); printf("%s\n",aAtomBase->getAtomName()); if (dynamic_cast<WAVEAtom *>(aAtomBase)) { // WAVE atom aSoundDescriptionV1->theWaveFormat = dynamic_cast<WAVEAtom *>(aAtomBase)->getWaveFormat(); } if (dynamic_cast<ESDSAtom *>(aAtomBase)) { // ESDS atom good aSoundDescriptionV1->VOLSize = aAtomBase->getDataSize(); aSoundDescriptionV1->theVOL = (uint8 *)(malloc(aSoundDescriptionV1->VOLSize)); memcpy(aSoundDescriptionV1->theVOL,dynamic_cast<ESDSAtom *>(aAtomBase)->getVOL(),aSoundDescriptionV1->VOLSize); } if ((aAtomBase->getAtomSize() > 0) && (descBytesLeft >= aAtomBase->getAtomSize())) { descBytesLeft = descBytesLeft - aAtomBase->getAtomSize(); } else { DEBUGGER("Invalid Atom found when reading Sound Description\n"); descBytesLeft = 0; } delete aAtomBase; } theAudioDescArray[0] = aSoundDescriptionV1; PRINT(("Size:Format=%ld:%ld %Ld\n",aSoundDescriptionV1->basefields.Size,aSoundDescriptionV1->basefields.DataFormat,descBytesLeft)); }
void ESDSAtom::OnProcessMetaData() { theVOL = (uint8 *)(malloc(getBytesRemaining())); Read(theVOL,getBytesRemaining()); }