MCPcopy Create free account
hub / github.com/cisco/openh264 / CreatePicBuff

Function CreatePicBuff

codec/decoder/core/src/decoder.cpp:63–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61extern void FreePicture (PPicture pPic, CMemoryAlign* pMa);
62
63static 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
107static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, const int32_t kiOldSize,
108 const int32_t kiPicWidth, const int32_t kiPicHeight, const int32_t kiNewSize) {

Callers 1

WelsRequestMemFunction · 0.85

Calls 3

DestroyPicBuffFunction · 0.85
WelsMalloczMethod · 0.80
AllocPictureFunction · 0.70

Tested by

no test coverage detected