Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 23da4cf3 authored by Martin Storsjo's avatar Martin Storsjo
Browse files

avcenc: Switch malloc/free callbacks to use pointers instead of ints

There is no reason for casting the pointers to ints. This fixes
building the code on platforms where pointers are larger than ints,
e.g. 64 bit platforms.

Change-Id: I910cd207d0908287931c9a96eb270139967e029b
parent ffb82943
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -213,15 +213,15 @@ typedef void (*FuctionType_FrameUnbind)(void *userData, int);
    memory usage.
\param "size" "Size of requested memory in bytes."
\param "attribute" "Some value specifying types, priority, etc. of the memory."
\return "The address of the allocated memory casted to int"
\return "The address of the allocated memory"
*/
typedef int (*FunctionType_Malloc)(void *userData, int32 size, int attribute);
typedef void* (*FunctionType_Malloc)(void *userData, int32 size, int attribute);

/** Function pointer to free
\param "mem" "Pointer to the memory to be freed casted to int"
\param "mem" "Pointer to the memory to be freed"
\return "void"
*/
typedef void (*FunctionType_Free)(void *userData, int mem);
typedef void (*FunctionType_Free)(void *userData, void *mem);

/** Debug logging information is returned to the application thru this function.
\param "type"   "Type of logging message, see definition of AVCLogType."
+4 −4
Original line number Diff line number Diff line
@@ -152,7 +152,7 @@ OSCL_EXPORT_REF AVCStatus AVCConfigureSequence(AVCHandle *avcHandle, AVCCommonOb
        framesize = (FrameHeightInMbs * PicWidthInMbs);
        if (video->mblock)
        {
            avcHandle->CBAVC_Free(userData, (uint32)video->mblock);
            avcHandle->CBAVC_Free(userData, video->mblock);
            video->mblock = NULL;
        }
        video->mblock = (AVCMacroblock*) avcHandle->CBAVC_Malloc(userData, sizeof(AVCMacroblock) * framesize, DEFAULT_ATTR);
@@ -187,7 +187,7 @@ OSCL_EXPORT_REF AVCStatus AVCConfigureSequence(AVCHandle *avcHandle, AVCCommonOb

        if (video->MbToSliceGroupMap)
        {
            avcHandle->CBAVC_Free(userData, (uint32)video->MbToSliceGroupMap);
            avcHandle->CBAVC_Free(userData, video->MbToSliceGroupMap);
            video->MbToSliceGroupMap = NULL;
        }
        video->MbToSliceGroupMap = (int*) avcHandle->CBAVC_Malloc(userData, sizeof(uint) * PicSizeInMapUnits * 2, 7/*DEFAULT_ATTR*/);
@@ -212,14 +212,14 @@ OSCL_EXPORT_REF AVCStatus CleanUpDPB(AVCHandle *avcHandle, AVCCommonObj *video)
    {
        if (dpb->fs[ii] != NULL)
        {
            avcHandle->CBAVC_Free(userData, (int)dpb->fs[ii]);
            avcHandle->CBAVC_Free(userData, dpb->fs[ii]);
            dpb->fs[ii] = NULL;
        }
    }
#ifndef PV_MEMORY_POOL
    if (dpb->decoded_picture_buffer)
    {
        avcHandle->CBAVC_Free(userData, (int)dpb->decoded_picture_buffer);
        avcHandle->CBAVC_Free(userData, dpb->decoded_picture_buffer);
        dpb->decoded_picture_buffer = NULL;
    }
#endif
+4 −4
Original line number Diff line number Diff line
@@ -131,13 +131,13 @@ inline static void ConvertYUV420SemiPlanarToYUV420Planar(
    }
}

static int32_t MallocWrapper(
static void* MallocWrapper(
        void *userData, int32_t size, int32_t attrs) {
    return reinterpret_cast<int32_t>(malloc(size));
    return malloc(size);
}

static void FreeWrapper(void *userData, int32_t ptr) {
    free(reinterpret_cast<void *>(ptr));
static void FreeWrapper(void *userData, void* ptr) {
    free(ptr);
}

static int32_t DpbAllocWrapper(void *userData,
+16 −16
Original line number Diff line number Diff line
@@ -610,32 +610,32 @@ OSCL_EXPORT_REF void PVAVCCleanUpEncoder(AVCHandle *avcHandle)

        if (encvid->functionPointer != NULL)
        {
            avcHandle->CBAVC_Free(userData, (int)encvid->functionPointer);
            avcHandle->CBAVC_Free(userData, encvid->functionPointer);
        }

        if (encvid->min_cost)
        {
            avcHandle->CBAVC_Free(userData, (int)encvid->min_cost);
            avcHandle->CBAVC_Free(userData, encvid->min_cost);
        }

        if (encvid->intraSearch)
        {
            avcHandle->CBAVC_Free(userData, (int)encvid->intraSearch);
            avcHandle->CBAVC_Free(userData, encvid->intraSearch);
        }

        if (encvid->mot16x16)
        {
            avcHandle->CBAVC_Free(userData, (int)encvid->mot16x16);
            avcHandle->CBAVC_Free(userData, encvid->mot16x16);
        }

        if (encvid->rateCtrl)
        {
            avcHandle->CBAVC_Free(userData, (int)encvid->rateCtrl);
            avcHandle->CBAVC_Free(userData, encvid->rateCtrl);
        }

        if (encvid->overrunBuffer)
        {
            avcHandle->CBAVC_Free(userData, (int)encvid->overrunBuffer);
            avcHandle->CBAVC_Free(userData, encvid->overrunBuffer);
        }

        video = encvid->common;
@@ -643,45 +643,45 @@ OSCL_EXPORT_REF void PVAVCCleanUpEncoder(AVCHandle *avcHandle)
        {
            if (video->MbToSliceGroupMap)
            {
                avcHandle->CBAVC_Free(userData, (int)video->MbToSliceGroupMap);
                avcHandle->CBAVC_Free(userData, video->MbToSliceGroupMap);
            }
            if (video->mblock != NULL)
            {
                avcHandle->CBAVC_Free(userData, (int)video->mblock);
                avcHandle->CBAVC_Free(userData, video->mblock);
            }
            if (video->decPicBuf != NULL)
            {
                CleanUpDPB(avcHandle, video);
                avcHandle->CBAVC_Free(userData, (int)video->decPicBuf);
                avcHandle->CBAVC_Free(userData, video->decPicBuf);
            }
            if (video->sliceHdr != NULL)
            {
                avcHandle->CBAVC_Free(userData, (int)video->sliceHdr);
                avcHandle->CBAVC_Free(userData, video->sliceHdr);
            }
            if (video->currPicParams != NULL)
            {
                if (video->currPicParams->slice_group_id)
                {
                    avcHandle->CBAVC_Free(userData, (int)video->currPicParams->slice_group_id);
                    avcHandle->CBAVC_Free(userData, video->currPicParams->slice_group_id);
                }

                avcHandle->CBAVC_Free(userData, (int)video->currPicParams);
                avcHandle->CBAVC_Free(userData, video->currPicParams);
            }
            if (video->currSeqParams != NULL)
            {
                avcHandle->CBAVC_Free(userData, (int)video->currSeqParams);
                avcHandle->CBAVC_Free(userData, video->currSeqParams);
            }
            if (encvid->bitstream != NULL)
            {
                avcHandle->CBAVC_Free(userData, (int)encvid->bitstream);
                avcHandle->CBAVC_Free(userData, encvid->bitstream);
            }
            if (video != NULL)
            {
                avcHandle->CBAVC_Free(userData, (int)video);
                avcHandle->CBAVC_Free(userData, video);
            }
        }

        avcHandle->CBAVC_Free(userData, (int)encvid);
        avcHandle->CBAVC_Free(userData, encvid);

        avcHandle->AVCObject = NULL;
    }
+2 −2
Original line number Diff line number Diff line
@@ -276,7 +276,7 @@ AVCEnc_Status AVCBitstreamUseOverrunBuffer(AVCEncBitstream* stream, int numExtra
                if (encvid->overrunBuffer)
                {
                    encvid->avcHandle->CBAVC_Free((uint32*)encvid->avcHandle->userData,
                                                  (int)encvid->overrunBuffer);
                                                  encvid->overrunBuffer);
                }

                encvid->oBSize = stream->oBSize;
@@ -315,7 +315,7 @@ AVCEnc_Status AVCBitstreamUseOverrunBuffer(AVCEncBitstream* stream, int numExtra
            memcpy(encvid->overrunBuffer, stream->overrunBuffer, stream->write_pos);
            // free old buffer
            encvid->avcHandle->CBAVC_Free((uint32*)encvid->avcHandle->userData,
                                          (int)stream->overrunBuffer);
                                          stream->overrunBuffer);

            // assign pointer to new buffer
            stream->overrunBuffer = encvid->overrunBuffer;
Loading