Exemple #1
0
void StAVPacket::avDestructPacket(AVPacket* thePkt) {
    // use own deallocation
    stMemFreeAligned(thePkt->data);
    thePkt->data = NULL;
    thePkt->size = 0;

#if(LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52, 118, 0))
    for(int anIter = 0; anIter < thePkt->side_data_elems; ++anIter) {
        stMemFreeAligned(thePkt->side_data[anIter].data);
    }
    stMemFreeAligned(thePkt->side_data);
    thePkt->side_data       = NULL;
    thePkt->side_data_elems = 0;
#endif
}
Exemple #2
0
bool StJpegParser::insertSection(const uint8_t   theMarker,
                                 const uint16_t  theSectLen,
                                 const ptrdiff_t theOffset) {
    const size_t aDiff    = size_t(theSectLen) + 2; // 2 bytes for marker
    const size_t aNewSize = myLength + aDiff;
    if(aNewSize > myBuffSize) {
        myBuffSize = aNewSize + 256;
        stUByte_t* aNewData = stMemAllocAligned<stUByte_t*>(myBuffSize);
        if(aNewData == NULL) {
            return false;
        }
        stMemCpy(aNewData, myBuffer, myLength);
        if(myIsOwnData) {
            stMemFreeAligned(myBuffer);
        }
        myIsOwnData = true;

        // update pointers of image(s) data
        for(StHandle<StJpegParser::Image> anImg = myImages;
            !anImg.isNull(); anImg = anImg->Next) {
            ptrdiff_t anOffset = anImg->Data - myBuffer;
            if(anOffset >= theOffset) {
                anOffset += aDiff;
            }
            anImg->Data = aNewData + anOffset;
            if(!anImg->Thumb.isNull()) {
                anOffset = anImg->Thumb->Data - myBuffer;
                if(anOffset >= theOffset) {
                    anOffset += aDiff;
                }
                anImg->Thumb->Data = aNewData + anOffset;
            }
        }

        myBuffer = aNewData;
    }
    myLength = aNewSize;

    // update offset table
    for(size_t anIter = 0; anIter < OffsetsNb; ++anIter) {
        if(myOffsets[anIter] >= theOffset) {
            myOffsets[anIter] += aDiff;
        }
    }

    // initialize new section
    const size_t aTailSize = myLength - theOffset;
    std::memmove(myBuffer + theOffset + 2 + size_t(theSectLen),
                 myBuffer + theOffset,
                 aTailSize);
    stUByte_t* aData = myBuffer + theOffset;
    aData[0] = 0xFF;
    aData[1] = theMarker;
    StAlienData::Set16uBE(aData + 2, theSectLen);
    return true;
}
Exemple #3
0
void StImagePlane::nullify(StImagePlane::ImgFormat thePixelFormat) {
    if(myIsOwnPointer && (myDataPtr != NULL)) {
        stMemFreeAligned(myDataPtr);
    }
    myDataPtr = NULL;
    myIsOwnPointer = true;
    mySizeX = mySizeY = mySizeRowBytes = 0;
    setFormat(thePixelFormat);
    myIsTopBottom = true;
}
Exemple #4
0
void StPCMBuffer::resize(const size_t theSizeMin,
                         const bool   theToReduce) {
    if(mySizeBytes >= theSizeMin
    && !theToReduce) {
        return; // do not reduce buffer
    }

    mySizeBytes = theSizeMin;
    stMemZero(myPlanes, sizeof(myPlanes));
    stMemFreeAligned(myBuffer);
    myBuffer = stMemAllocAligned<uint8_t*>(mySizeBytes, 16);
    stMemZero(myBuffer, mySizeBytes);
    setupChannels(myChMap, myPlanesNb);
}
Exemple #5
0
StPCMBuffer::~StPCMBuffer() {
    stMemFreeAligned(myBuffer);
}
Exemple #6
0
void __stdcall StADLsdk::ADL_Main_Memory_Free(void* thePtr) {
    stMemFreeAligned(thePtr);
}