| 61 | extern void FreePicture (PPicture pPic, CMemoryAlign* pMa); |
| 62 | |
| 63 | static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, const int32_t kiSize, |
| 64 | const int32_t kiPicWidth, const int32_t kiPicHeight) { |
| 65 | |
| 66 | PPicBuff pPicBuf = NULL; |
| 67 | int32_t iPicIdx = 0; |
| 68 | if (kiSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) { |
| 69 | return ERR_INFO_INVALID_PARAM; |
| 70 | } |
| 71 | |
| 72 | CMemoryAlign* pMa = pCtx->pMemAlign; |
| 73 | |
| 74 | pPicBuf = (PPicBuff)pMa->WelsMallocz (sizeof (SPicBuff), "PPicBuff"); |
| 75 | |
| 76 | if (NULL == pPicBuf) { |
| 77 | return ERR_INFO_OUT_OF_MEMORY; |
| 78 | } |
| 79 | |
| 80 | pPicBuf->ppPic = (PPicture*)pMa->WelsMallocz (kiSize * sizeof (PPicture), "PPicture*"); |
| 81 | |
| 82 | if (NULL == pPicBuf->ppPic) { |
| 83 | pPicBuf->iCapacity = 0; |
| 84 | DestroyPicBuff (pCtx, &pPicBuf, pMa); |
| 85 | return ERR_INFO_OUT_OF_MEMORY; |
| 86 | } |
| 87 | |
| 88 | for (iPicIdx = 0; iPicIdx < kiSize; ++ iPicIdx) { |
| 89 | PPicture pPic = AllocPicture (pCtx, kiPicWidth, kiPicHeight); |
| 90 | if (NULL == pPic) { |
| 91 | // init capacity first for free memory |
| 92 | pPicBuf->iCapacity = iPicIdx; |
| 93 | DestroyPicBuff (pCtx, &pPicBuf, pMa); |
| 94 | return ERR_INFO_OUT_OF_MEMORY; |
| 95 | } |
| 96 | pPicBuf->ppPic[iPicIdx] = pPic; |
| 97 | } |
| 98 | |
| 99 | // initialize context in queue |
| 100 | pPicBuf->iCapacity = kiSize; |
| 101 | pPicBuf->iCurrentIdx = 0; |
| 102 | * ppPicBuf = pPicBuf; |
| 103 | |
| 104 | return ERR_NONE; |
| 105 | } |
| 106 | |
| 107 | static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, const int32_t kiOldSize, |
| 108 | const int32_t kiPicWidth, const int32_t kiPicHeight, const int32_t kiNewSize) { |
no test coverage detected