void CompositionOffsetBox::parseBox(BitStream& bitstr)
{
    //  First parse the box header
    parseFullBoxHeader(bitstr);

    const std::uint32_t entryCount = bitstr.read32Bits();

    if (getVersion() == 0)
    {
        for (uint32_t i = 0; i < entryCount; ++i)
        {
            EntryVersion0 entryVersion0;
            entryVersion0.mSampleCount = bitstr.read32Bits();
            entryVersion0.mSampleOffset = bitstr.read32Bits();
            mEntryVersion0.push_back(entryVersion0);
        }
    }
    else if (getVersion() == 1)
    {
        for (uint32_t i = 0; i < entryCount; ++i)
        {
            EntryVersion1 entryVersion1;
            entryVersion1.mSampleCount = bitstr.read32Bits();
            entryVersion1.mSampleOffset = static_cast<std::int32_t>(bitstr.read32Bits());
            mEntryVersion1.push_back(entryVersion1);
        }
    }
}
void CodingConstraintsBox::parseBox(BitStream& bitstr)
{
    parseFullBoxHeader(bitstr);
    mAllRefPicsIntra = bitstr.readBits(1);
    mIntraPredUsed = bitstr.readBits(1);
    mMaxRefPicUsed = bitstr.readBits(4);
    bitstr.readBits(26); // discard reserved int(26)
}
Exemple #3
0
void ItemReferenceBox::parseBox(BitStream& bitstr)
{
    parseFullBoxHeader(bitstr);

    while (bitstr.numBytesLeft() > 0)
    {
        SingleItemTypeReferenceBox singleRef;
        singleRef.parseBox(bitstr);
        addItemRef(singleRef);
    }
}
Exemple #4
0
void PrimaryItemBox::parseBox(BitStream& bitstr)
{
    parseFullBoxHeader(bitstr);
    if (getVersion() == 0)
    {
        mItemId = bitstr.read16Bits();
    }
    else
    {
        mItemId = bitstr.read32Bits();
    }
}
void VideoMediaHeaderBox::parseBox(BitStream& bitstr)
{
    BitStream subBitstr;

    //  First parse the box header
    parseFullBoxHeader(bitstr);

    bitstr.read16Bits(); // graphicsmode = 0
    bitstr.read16Bits(); // opcolor = {0, 0, 0}
    bitstr.read16Bits();
    bitstr.read16Bits();
}
Exemple #6
0
void MetaBox::parseBox(ISOBMFF::BitStream& bitstr)
{
    parseFullBoxHeader(bitstr);

    while (bitstr.numBytesLeft() > 0)
    {
        FourCCInt boxType;
        BitStream subBitstr = bitstr.readSubBoxBitStream(boxType);

        if (boxType == "hdlr")
        {
            mHandlerBox.parseBox(subBitstr);
        }
        else if (boxType == "pitm")
        {
            mPrimaryItemBox.parseBox(subBitstr);
        }
        else if (boxType == "iloc")
        {
            mItemLocationBox.parseBox(subBitstr);
        }
        else if (boxType == "iinf")
        {
            mItemInfoBox.parseBox(subBitstr);
        }
        else if (boxType == "iref")
        {
            mItemReferenceBox.parseBox(subBitstr);
        }
        else if (boxType == "iprp")
        {
            mItemPropertiesBox.parseBox(subBitstr);
        }
        else if (boxType == "grpl")
        {
            mGroupsListBox.parseBox(subBitstr);
        }
        else if (boxType == "dinf")
        {
            mDataInformationBox.parseBox(subBitstr);
        }
        else if (boxType == "idat")
        {
            mItemDataBox.parseBox(subBitstr);
        }
        else if (boxType == "ipro")
        {
            mItemProtectionBox.parseBox(subBitstr);
        }
        // unsupported boxes are skipped
    }
}
Exemple #7
0
void TrackHeaderBox::parseBox(ISOBMFF::BitStream& bitstr)
{
    //  First parse the box header
    parseFullBoxHeader(bitstr);
    if ((getVersion() != 0) && (getVersion() != 1))
    {
        throw RuntimeError("TrackHeaderBox::parseBox() supports only 'tkhd' version 0 and version 1");
    }

    if (getVersion() == 0)
    {
        mCreationTime     = bitstr.read32Bits();
        mModificationTime = bitstr.read32Bits();
    }
    else
    {
        mCreationTime     = bitstr.read64Bits();
        mModificationTime = bitstr.read64Bits();
    }
    mTrackID = bitstr.read32Bits();
    bitstr.read32Bits();
    if (getVersion() == 0)
    {
        mDuration = bitstr.read32Bits();
    }
    else
    {
        mDuration = bitstr.read64Bits();
    }

    bitstr.read32Bits();  // Reserved
    bitstr.read32Bits();

    bitstr.read16Bits();                    // Layer
    mAlternateGroup = bitstr.read16Bits();  // Alternate Group
    mVolume         = bitstr.read16Bits();  // Volume
    bitstr.read16Bits();                    // Reserved

    mMatrix.clear();
    for (int n = 9; n > 0; n--)  // Matrix[9]
    {
        mMatrix.push_back(static_cast<int32_t>(bitstr.read32Bits()));
    }

    mWidth  = bitstr.read32Bits();
    mHeight = bitstr.read32Bits();
}
void ElementaryStreamDescriptorBox::parseBox(BitStream& bitstr)
{
    parseFullBoxHeader(bitstr);

    //////////////////////////////////////////////
    //      Fill in struct ES_Descriptor        //
    //////////////////////////////////////////////
    mES_Descriptor.ES_DescrTag = bitstr.read8Bits();
    if (mES_Descriptor.ES_DescrTag != 3)  // ES_DescrTag
    {
        throw RuntimeError("ElementaryStreamDescritorBox ES_Descriptor.ES_DescrTag not valid");
    }
    /* Expandable class... need to find out size based on (from ISO/IEC 14496-1)
     * int sizeOfInstance = 0;
     * bit(1) nextByte;
     * bit(7) sizeOfInstance;
     * while(nextByte) {
     *      bit(1) nextByte;
     *      bit(7) sizeByte;
     *      sizeOfInstance = sizeOfInstance<<7 | sizeByte; }
     */
    std::uint8_t readByte = 0;
    std::uint32_t size    = 0;
    do
    {
        readByte              = bitstr.read8Bits();
        std::uint8_t sizeByte = (readByte & 0x7F);
        size                  = (size << 7) | sizeByte;
    } while (readByte & 0x80);

    mES_Descriptor.size  = size;
    mES_Descriptor.ES_ID = bitstr.read16Bits();
    mES_Descriptor.flags = bitstr.read8Bits();

    if (mES_Descriptor.flags & 0x80)  // streamDependenceFlag as defined in 7.2.6.5.1 of ISO/IEC 14486-1:2010(E)
    {
        mES_Descriptor.dependsOn_ES_ID = bitstr.read16Bits();
    }

    if (mES_Descriptor.flags & 0x40)  // URL_Flag as defined in 7.2.6.5.1 of ISO/IEC 14486-1:2010(E)
    {
        mES_Descriptor.URLlength = bitstr.read8Bits();
        if (mES_Descriptor.URLlength)
        {
            bitstr.readStringWithLen(mES_Descriptor.URLstring, mES_Descriptor.URLlength);
        }
    }

    if (mES_Descriptor.flags & 0x20)  // OCRstreamFlag as defined in 7.2.6.5.1 of ISO/IEC 14486-1:2010(E)
    {
        mES_Descriptor.OCR_ES_Id = bitstr.read16Bits();
    }

    //////////////////////////////////////////////////////////////////
    //      Fill in struct ES_Descriptor.DecoderConfigDescriptor    //
    //////////////////////////////////////////////////////////////////
    mES_Descriptor.decConfigDescr.DecoderConfigDescrTag = bitstr.read8Bits();
    if (mES_Descriptor.decConfigDescr.DecoderConfigDescrTag != 4)  // DecoderConfigDescrTag
    {
        throw RuntimeError("ElementaryStreamDescritorBox DecoderConfigDescriptor.DecoderConfigDescrTag not valid");
    }

    readByte = 0;
    size     = 0;
    do
    {
        readByte              = bitstr.read8Bits();
        std::uint8_t sizeByte = (readByte & 0x7f);
        size                  = (size << 7) | sizeByte;
    } while (readByte & 0x80);

    mES_Descriptor.decConfigDescr.size                 = size;
    mES_Descriptor.decConfigDescr.objectTypeIndication = bitstr.read8Bits();
    mES_Descriptor.decConfigDescr.streamType           = (bitstr.read8Bits() >> 2);
    mES_Descriptor.decConfigDescr.bufferSizeDB         = bitstr.read24Bits();
    mES_Descriptor.decConfigDescr.maxBitrate           = bitstr.read32Bits();
    mES_Descriptor.decConfigDescr.avgBitrate           = bitstr.read32Bits();

    /////////////////////////////////////////////////////////////////////////////////////
    //      Fill in struct ES_Descriptor.DecoderConfigDescriptor.DecoderSpecificInfo   //
    /////////////////////////////////////////////////////////////////////////////////////
    while (bitstr.numBytesLeft())  // DecoderSpecificInfo is optional.
    {
        std::uint8_t tag = bitstr.read8Bits();

        readByte = 0;
        size     = 0;
        do
        {
            readByte              = bitstr.read8Bits();
            std::uint8_t sizeByte = (readByte & 0x7f);
            size                  = (size << 7) | sizeByte;
        } while (readByte & 0x80);

        DecoderSpecificInfo decSpecificInfo;

        decSpecificInfo.DecSpecificInfoTag = tag;
        decSpecificInfo.size               = size;
        bitstr.read8BitsArray(decSpecificInfo.DecSpecificInfo, decSpecificInfo.size);

        if (tag == 5)  // DecSpecificInfoTag
        {
            mES_Descriptor.decConfigDescr.decSpecificInfo = std::move(decSpecificInfo);
        }
        else
        {
            mOtherDecSpecificInfo.push_back(std::move(decSpecificInfo));
        }
    }
}
void ImageSpatialExtentsProperty::parseBox(BitStream& input)
{
    parseFullBoxHeader(input);
    mImageWidth = input.read32Bits();
    mImageHeight = input.read32Bits();
}