PVA_FF_FontRecord::PVA_FF_FontRecord(uint16 FontListID, uint16 FontID, int8 FontLength, uint8* FontName) : PVA_FF_Atom(FourCharConstToUint32('t', 't', 's', 'f')) { OSCL_UNUSED_ARG(FontListID); _fontID = 0; _fontLength = 0; _pFontName = NULL; if (_fontID == 0) { _fontID = FontID; } if (_fontLength == 0) { _fontLength = FontLength; } if (_fontLength > 0) { _pFontName = (uint8 *)(OSCL_MALLOC(_fontLength * sizeof(char))); for (uint32 i = 0; i < (uint32)_fontLength; i++) { _pFontName[i] = FontName[i]; } } recomputeSize(); }
OSCL_EXPORT_REF void PVMp4FFComposerPort::setParametersSync(PvmiMIOSession session, PvmiKvp* parameters, int num_elements, PvmiKvp*& ret_kvp) { OSCL_UNUSED_ARG(session); ret_kvp = NULL; if (iFormat == PVMF_MIME_H264_VIDEO_MP4) { //this code is specific to H264 file format for (int32 i = 0; i < num_elements; i++)//assuming the memory is allocated for key { if (pv_mime_strcmp(parameters->key, VIDEO_AVC_OUTPUT_SPS_CUR_VALUE) == 0) { memfrag_sps = (OsclMemoryFragment *)(OSCL_MALLOC(sizeof(OsclMemoryFragment))); memfrag_sps->len = parameters->capacity; memfrag_sps->ptr = (uint8*)(OSCL_MALLOC(sizeof(uint8) * memfrag_sps->len)); oscl_memcpy((void*)memfrag_sps->ptr, (const void*)parameters->value.key_specific_value, memfrag_sps->len); iNode->memvector_sps.push_back(memfrag_sps); //storing SPS in the vector iNode->iNum_SPS_Set += 1; } if (pv_mime_strcmp(parameters->key, VIDEO_AVC_OUTPUT_PPS_CUR_VALUE) == 0) { memfrag_pps = (OsclMemoryFragment *)(OSCL_MALLOC(sizeof(OsclMemoryFragment))); memfrag_pps->len = parameters->capacity; memfrag_pps->ptr = (uint8*)(OSCL_MALLOC(sizeof(uint8) * memfrag_pps->len)); oscl_memcpy((void*)memfrag_pps->ptr, (const void*)parameters->value.key_specific_value, memfrag_pps->len); iNode->memvector_pps.push_back(memfrag_pps); //storing PPS in the vector iNode->iNum_PPS_Set += 1; } } } if (iFormat == PVMF_MIME_3GPP_TIMEDTEXT) { for (int32 i = 0; i < num_elements; i++)//assuming the memory is allocated for keys { if (pv_mime_strcmp(parameters->key, TIMED_TEXT_OUTPUT_CONFIG_INFO_CUR_VALUE) == 0) { PVA_FF_TextSampleDescInfo* ptempDecoderinfo = OSCL_STATIC_CAST(PVA_FF_TextSampleDescInfo*, parameters->value.key_specific_value); PVA_FF_TextSampleDescInfo* pDecoderinfo = OSCL_NEW(PVA_FF_TextSampleDescInfo, (*ptempDecoderinfo)); iNode->textdecodervector.push_back(pDecoderinfo); } } }
int32 OsclFileCache::Open(uint32 mode, uint32 size) //Called to open the cache for a newly opened file. //The NativeOpen was just called prior to this and was successful. { //should not be called with zero-size cache. OSCL_ASSERT(size > 0); //Save the mode _mode = mode; //open logger object only if logging is enabled on this //file if (iContainer.iLogger) iLogger = PVLogger::GetLoggerObject("OsclFileCache"); else iLogger = NULL; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OsclFileCache(0x%x)::Open mode %d size %d", this, mode, size)); // Create the movable cache. // Re-allocate it if the size has changed. if (_movableCache.pBuffer && size != _movableCache.capacity) { OSCL_FREE(_movableCache.pBuffer); _movableCache.pBuffer = NULL; } if (!_movableCache.pBuffer && size > 0) { _movableCache.pBuffer = (uint8*)OSCL_MALLOC(size); } if (!_movableCache.pBuffer) { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OsclFileCache(0x%x)::Open ERROR no memory %d", this)); return (-1);//error } _movableCache.capacity = _movableCache.usableSize = size; _movableCache.filePosition = 0; _movableCache.updateStart = _movableCache.updateEnd = 0; _movableCache.currentPos = _movableCache.endPos = 0; //Position the cache at zero. SetCachePosition(0); //get initial file size & native position PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OsclFileCache(0x%x)::Open CallingNativeSize", this)); _fileSize = iContainer.CallNativeSize(); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OsclFileCache(0x%x)::Open CallingNativeTell", this)); _nativePosition = iContainer.CallNativeTell(); return 0; }
// Constructor PVA_FF_DecoderSpecificInfo::PVA_FF_DecoderSpecificInfo(PVA_FF_TextSampleDescInfo *pdata, uint32 size) : PVA_FF_BaseDescriptor(0x05) { _infoSize = size; _pinfo = (uint8 *)OSCL_MALLOC(_infoSize); oscl_memcpy(_pinfo, pdata, _infoSize); recomputeSize(); }
void PVA_FF_TextSampleEntry::addTextDecoderSpecificInfo(PVA_FF_TextSampleDescInfo *pinfo) { _displayFlags = pinfo->display_flags; _horzJustification = pinfo->hJust; _vertJustification = pinfo->vJust; _pBackgroundRGBA = (uint8 *)(OSCL_MALLOC(4 * sizeof(uint8))); _pBackgroundRGBA[0] = pinfo->bkRgba[0]; _pBackgroundRGBA[1] = pinfo->bkRgba[1]; _pBackgroundRGBA[2] = pinfo->bkRgba[2]; _pBackgroundRGBA[3] = pinfo->bkRgba[3]; _start_sample_num = pinfo->start_sample_num; _end_sample_num = pinfo->end_sample_num; _sdIndex = pinfo->sdindex; int16 top = pinfo->top; _pBoxRecord->setBoxTop(top); int16 left = pinfo->left; _pBoxRecord->setBoxLeft(left); int16 bottom = pinfo->bottom; _pBoxRecord->setBoxBottom(bottom); int16 right = pinfo->right; _pBoxRecord->setBoxRight(right); uint16 startchar = pinfo->startChar; _pStyleRecord->setStartChar(startchar); uint16 endchar = pinfo->endChar; _pStyleRecord->setEndChar(endchar); uint16 fontid = pinfo->font_id; _pStyleRecord->setFontID(fontid); uint8 fontsize_flag = pinfo->fontSizeFlags; _pStyleRecord->setFontStyleFlags(fontsize_flag); uint8 fontsize = pinfo->fontSize; _pStyleRecord->setFontSize(fontsize); uint8* tRGBA = pinfo->tRgba; _pStyleRecord->setTextColourRGBA(tRGBA); uint16 fontlistsize = pinfo->fontListSize; _pFontTableAtom->setFontListSize(fontlistsize); uint16 Fontlistid = pinfo->fontListID; uint16 FontID = pinfo->fontID; int8 Fontlength = pinfo->font_length; uint8* Fontname = pinfo->font_name; _pFontTableAtom->setFontRecord(Fontlistid, FontID, Fontlength, Fontname); }
OsclMemPoolResizableAllocator::MemPoolBufferInfo* OsclMemPoolResizableAllocator::addnewmempoolbuffer(uint32 aBufferAlignedSize) { OSCL_ASSERT(aBufferAlignedSize > 0); OSCL_ASSERT(aBufferAlignedSize == oscl_mem_aligned_size(aBufferAlignedSize)); // Allocate memory for one buffer uint8* newbuffer = NULL; if (iMemPoolBufferAllocator) { // Use the outside allocator newbuffer = (uint8*)iMemPoolBufferAllocator->ALLOCATE(aBufferAlignedSize); } else { // Allocate directly from heap newbuffer = (uint8*)OSCL_MALLOC(aBufferAlignedSize); } if (newbuffer == NULL) { OSCL_LEAVE(OsclErrNoMemory); // OSCL_UNUSED_RETURN(NULL); This statement was removed to avoid compiler warning for Unreachable Code } #if OSCL_MEM_FILL_WITH_PATTERN oscl_memset(newbuffer, 0x55, aBufferAlignedSize); #endif // Fill in the buffer info header MemPoolBufferInfo* newbufferinfo = (MemPoolBufferInfo*)newbuffer; newbufferinfo->iBufferPreFence = OSCLMEMPOOLRESIZABLEALLOCATOR_PREFENCE_PATTERN; newbufferinfo->iStartAddr = (OsclAny*)(newbuffer + iBufferInfoAlignedSize); newbufferinfo->iEndAddr = (OsclAny*)(newbuffer + aBufferAlignedSize - 1); newbufferinfo->iBufferSize = aBufferAlignedSize; newbufferinfo->iNumOutstanding = 0; newbufferinfo->iNextFreeBlock = (MemPoolBlockInfo*)(newbufferinfo->iStartAddr); newbufferinfo->iAllocatedSz = 0; newbufferinfo->iBufferPostFence = OSCLMEMPOOLRESIZABLEALLOCATOR_POSTFENCE_PATTERN; // Put in one free block in the new buffer MemPoolBlockInfo* freeblockinfo = (MemPoolBlockInfo*)(newbufferinfo->iStartAddr); freeblockinfo->iBlockPreFence = OSCLMEMPOOLRESIZABLEALLOCATOR_PREFENCE_PATTERN; freeblockinfo->iNextFreeBlock = NULL; freeblockinfo->iPrevFreeBlock = NULL; freeblockinfo->iBlockSize = aBufferAlignedSize - iBufferInfoAlignedSize; freeblockinfo->iBlockBuffer = (uint8*)freeblockinfo + iBlockInfoAlignedSize; freeblockinfo->iParentBuffer = newbufferinfo; freeblockinfo->iBlockPostFence = OSCLMEMPOOLRESIZABLEALLOCATOR_POSTFENCE_PATTERN; // Add the new buffer to the list iMemPoolBufferList.push_front(newbufferinfo); return newbufferinfo; }
int32 OsclFileCache::Open(uint32 mode, uint32 size) //Called to open the cache for a newly opened file. //The NativeOpen was just called prior to this and was successful. { //should not be called with zero-size cache. OSCL_ASSERT(size > 0); //Save the open parameters _cacheSize = size; _mode = mode; //open logger object only if logging is enabled on this //file if (iContainer.iLogger) iLogger = PVLogger::GetLoggerObject("OsclFileCache"); else iLogger = NULL; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OsclFileCache(0x%x)::Open mode %d size %d", this, mode, size)); // allocate memory for cache // free any old buffer since its size may be different if (_pCacheBufferStart) { OSCL_FREE(_pCacheBufferStart); _pCacheBufferStart = NULL; } _pCacheBufferStart = (uint8*)OSCL_MALLOC(_cacheSize); if (!_pCacheBufferStart) { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OsclFileCache(0x%x)::Open ERROR no memory %d", this)); return (-1);//error } //initialise the cache variables SetCachePosition(0); //get initial file size & native position _fileSize = iContainer.CallNativeSize(); _nativePosition = iContainer.CallNativeTell(); return 0; }
OSCL_EXPORT_REF void ThreadSafeMemPoolFixedChunkAllocator::createmempool() { if (iChunkSize == 0 || iNumChunk == 0) { OSCL_LEAVE(OsclErrArgument); } // Create one block of memory for the memory pool iChunkSizeMemAligned = oscl_mem_aligned_size(iChunkSize); int32 leavecode = 0; if (iMemPoolAllocator) { OSCL_TRY(leavecode, iMemPool = iMemPoolAllocator->ALLOCATE(iNumChunk * iChunkSizeMemAligned)); } else { OSCL_TRY(leavecode, iMemPool = OSCL_MALLOC(iNumChunk * iChunkSizeMemAligned)); } if (leavecode || iMemPool == NULL) { OSCL_LEAVE(OsclErrNoMemory); } #if OSCL_MEM_FILL_WITH_PATTERN oscl_memset(iMemPool, 0x55, iNumChunk*iChunkSizeMemAligned); #endif // Set up the free mem chunk list vector iFreeMemChunkList.reserve(iNumChunk); uint8* chunkptr = (uint8*)iMemPool; for (uint32 i = 0; i < iNumChunk; ++i) { iFreeMemChunkList.push_back((OsclAny*)chunkptr); chunkptr += iChunkSizeMemAligned; } }
OSCL_EXPORT_REF ThreadSafeMemPoolFixedChunkAllocator *ThreadSafeMemPoolFixedChunkAllocator::Create(const uint32 numchunk, const uint32 chunksize, Oscl_DefAlloc *gen_alloc) { OsclAny *ptr = NULL; if (gen_alloc) { ptr = gen_alloc->ALLOCATE(sizeof(ThreadSafeMemPoolFixedChunkAllocator)); } else { ptr = OSCL_MALLOC(sizeof(ThreadSafeMemPoolFixedChunkAllocator)); } if (ptr == NULL) { return NULL; } ThreadSafeMemPoolFixedChunkAllocator *self = OSCL_PLACEMENT_NEW(ptr, ThreadSafeMemPoolFixedChunkAllocator(numchunk, chunksize, gen_alloc)); return self; }
// ALL the standard OpenMAX IL core functions are implemented below static OMX_ERRORTYPE _OMX_MasterInit(OMXMasterCoreGlobalData *data) { OMX_ERRORTYPE Status = OMX_ErrorNone; OMX_U32 jj; OMX_U32 index; OMX_U32 master_index = 0; OMX_U32 component_index = 0; /* ** Step 1. Populate all the config files present in the specified path. ** Step 2. Populate all the libraries from the .cfg files that claim to support the OMX_INTERFACE_ID. ** Step 3. For these libraries, validate whether they really support the ID by doing a QueryInterface(). */ // Step 1 OsclConfigFileList aCfgList; OSCL_HeapString<OsclMemAllocator> configFilePath = PV_DYNAMIC_LOADING_CONFIG_FILE_PATH; aCfgList.Populate(configFilePath, OsclConfigFileList::ESortByName); // array of ptrs to various cores, one for every valid configuration OMXInterface** pInterface = (OMXInterface**)OSCL_MALLOC(aCfgList.Size() * sizeof(OMXInterface *)); if (pInterface == NULL) { return OMX_ErrorInsufficientResources; } // set the global ptr to this array data->iInterface = (void*)pInterface; // array of ptrs to the omx shared libraries, one for every valid configuration OsclSharedLibrary** pLibrary = (OsclSharedLibrary**)OSCL_MALLOC(aCfgList.Size() * sizeof(OsclSharedLibrary *)); if (pLibrary == NULL) { return OMX_ErrorInsufficientResources; } // set the global ptr to this array // data->iOMXLibrary = (void*)pLibrary; for (uint ii = 0; ii < aCfgList.Size(); ii++) { // Step 2 OsclLibraryList libList; libList.Populate(OMX_INTERFACE_ID, aCfgList.GetConfigfileAt(ii)); for (uint jj = 0; (jj < libList.Size()) && ((data->iNumOMXCores) < aCfgList.Size()); jj++) { OsclSharedLibrary* lib = OSCL_NEW(OsclSharedLibrary, ()); if (lib->LoadLib(libList.GetLibraryPathAt(jj)) == OsclLibSuccess) { OsclAny* interfacePtr = NULL; // Step 3 OsclLibStatus result = lib->QueryInterface(OMX_INTERFACE_ID, (OsclAny*&)interfacePtr); if (result == OsclLibSuccess && interfacePtr != NULL) { pLibrary[(data->iNumOMXCores)] = lib; OMXInterface* coreIntPtr = OSCL_DYNAMIC_CAST(OMXInterface*, interfacePtr); pInterface[(data->iNumOMXCores)] = coreIntPtr; (data->iNumOMXCores)++; continue; } } lib->Close(); OSCL_DELETE(lib); }
//Add a new fixed cache, maintaining sorted order of the list. OSCL_EXPORT_REF OsclFileCacheBuffer* OsclFileCache::AddFixedCache(const Oscl_File::OsclFixedCacheParam& aParam) { #if (OVERLAP_CHECKS) //Check for overlap with any existing fixed cache. //Caller should ensure there is no overlap. if (_fixedCaches.size()) { for (uint32 i = 0; i < _fixedCaches.size(); i++) { if (_fixedCaches[i].Contains(aParam.iFilePosition)) { //given start position falls in an existing cache. PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OsclFileCache(0x%x)::AddFixedCache ERROR Overlap!", this)); return NULL; } if (aParam.Contains(_fixedCaches[i].filePosition)) { //some cache start position falls in this range. PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OsclFileCache(0x%x)::AddFixedCache ERROR Overlap!", this)); return NULL; } //verify sort while we're at it if (i > 0) { if (_fixedCaches[i].filePosition < _fixedCaches[i-1].filePosition) { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OsclFileCache(0x%x)::AddFixedCache ERROR Sort!", this)); return NULL; } } } } #endif //Check for overlap with current movable cache. if (_movableCache.Contains(aParam.iFilePosition) || aParam.Contains(_movableCache.filePosition)) { //There is overlap. Dump the movable cache. //@TODO might be able to preserve some of the data here instead of complete //cache dump. PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OsclFileCache(0x%x)::AddFixedCache Movable Cache Overlap, dumping data", this)); if (_movableCache.IsUpdated()) { int32 result = _movableCache.WriteUpdatesToFile(); if (result != 0) { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OsclFileCache(0x%x)::AddFixedCache ERROR in WriteUpdatesToFile!", this)); return NULL; } } _movableCache.endPos = _movableCache.currentPos = 0; _movableCache.filePosition = 0; _movableCache.usableSize = _movableCache.capacity; } //Create new entry OsclFileCacheBuffer fc; fc.iContainer = this; fc.isFixed = true; fc.pBuffer = (uint8*)OSCL_MALLOC(aParam.iSize); if (!fc.pBuffer) { PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OsclFileCache(0x%x)::AddFixedCache ERROR no memory %d", this)); return NULL;//error } fc.capacity = fc.usableSize = aParam.iSize; fc.filePosition = aParam.iFilePosition; //Add this entry, maintaining sorted order. int32 insertIndex = (-1); if (_fixedCaches.size()) { for (uint32 i = 0; i < _fixedCaches.size(); i++) { if (fc.filePosition <= _fixedCaches[i].filePosition) { insertIndex = i; break; } } } if (insertIndex >= 0) { _fixedCaches.insert(&_fixedCaches[insertIndex], fc); return &_fixedCaches[insertIndex]; } else { _fixedCaches.push_back(fc); return &_fixedCaches[_fixedCaches.size()-1]; } }
OSCL_EXPORT_REF void OsclMemPoolFixedChunkAllocator::createmempool() { if (iChunkSize == 0 || iNumChunk == 0) { OSCL_LEAVE(OsclErrArgument); } if (iChunkAlignment > 0) { uint32 temp = iChunkAlignment - 1; iChunkSizeMemAligned = ((iChunkSize + temp) & (~temp)); } else { // Create one block of memory for the memory pool iChunkSizeMemAligned = oscl_mem_aligned_size(iChunkSize); } int32 leavecode = 0; if (iMemPoolAllocator) { OSCL_TRY(leavecode, iMemPool = iMemPoolAllocator->ALLOCATE((iNumChunk * iChunkSizeMemAligned) + iChunkAlignment)); } else { iMemPool = OSCL_MALLOC((iNumChunk * iChunkSizeMemAligned) + iChunkAlignment); } if (leavecode || iMemPool == NULL) { OSCL_LEAVE(OsclErrNoMemory); } #if OSCL_MEM_FILL_WITH_PATTERN oscl_memset(iMemPool, 0x55, (iNumChunk*iChunkSizeMemAligned) + iChunkAlignment); #endif // Set up the free mem chunk list vector iFreeMemChunkList.reserve(iNumChunk); uint8* chunkptr = (uint8*)iMemPool; // do the alignment if necessary if (iChunkAlignment > 0) { uint32 chunkptrAddr = (uint32) chunkptr; uint32 tempAlign = (iChunkAlignment - 1); uint32 difference = ((chunkptrAddr + tempAlign) & (~tempAlign)) - chunkptrAddr; chunkptr = chunkptr + difference; iMemPoolAligned = (OsclAny*) chunkptr; } else { iMemPoolAligned = iMemPool; } for (uint32 i = 0; i < iNumChunk; ++i) { iFreeMemChunkList.push_back((OsclAny*)chunkptr); chunkptr += iChunkSizeMemAligned; } }