| 1488 | } |
| 1489 | |
| 1490 | int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWidth, const int32_t kiMaxHeight) { |
| 1491 | int32_t i = 0; |
| 1492 | WELS_VERIFY_RETURN_IF (ERR_INFO_INVALID_PARAM, (NULL == pCtx || kiMaxWidth <= 0 || kiMaxHeight <= 0)) |
| 1493 | pCtx->sMb.iMbWidth = (kiMaxWidth + 15) >> 4; |
| 1494 | pCtx->sMb.iMbHeight = (kiMaxHeight + 15) >> 4; |
| 1495 | |
| 1496 | if (pCtx->bInitialDqLayersMem && kiMaxWidth <= pCtx->iPicWidthReq |
| 1497 | && kiMaxHeight <= pCtx->iPicHeightReq) // have same dimension memory, skipped |
| 1498 | return ERR_NONE; |
| 1499 | |
| 1500 | CMemoryAlign* pMa = pCtx->pMemAlign; |
| 1501 | |
| 1502 | UninitialDqLayersContext (pCtx); |
| 1503 | |
| 1504 | do { |
| 1505 | PDqLayer pDq = (PDqLayer)pMa->WelsMallocz (sizeof (SDqLayer), "PDqLayer"); |
| 1506 | |
| 1507 | if (pDq == NULL) |
| 1508 | return ERR_INFO_OUT_OF_MEMORY; |
| 1509 | |
| 1510 | pCtx->pDqLayersList[i] = pDq; //to keep consistence with in UninitialDqLayersContext() |
| 1511 | memset (pDq, 0, sizeof (SDqLayer)); |
| 1512 | |
| 1513 | pCtx->sMb.pMbType[i] = (uint32_t*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (uint32_t), |
| 1514 | "pCtx->sMb.pMbType[]"); |
| 1515 | pCtx->sMb.pMv[i][LIST_0] = (int16_t (*)[16][2])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( |
| 1516 | int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMv[][]"); |
| 1517 | pCtx->sMb.pMv[i][LIST_1] = (int16_t (*)[16][2])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( |
| 1518 | int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMv[][]"); |
| 1519 | |
| 1520 | pCtx->sMb.pRefIndex[i][LIST_0] = (int8_t (*)[MB_BLOCK4x4_NUM])pMa->WelsMallocz (pCtx->sMb.iMbWidth * |
| 1521 | pCtx->sMb.iMbHeight * |
| 1522 | sizeof ( |
| 1523 | int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pRefIndex[][]"); |
| 1524 | pCtx->sMb.pRefIndex[i][LIST_1] = (int8_t (*)[MB_BLOCK4x4_NUM])pMa->WelsMallocz (pCtx->sMb.iMbWidth * |
| 1525 | pCtx->sMb.iMbHeight * |
| 1526 | sizeof ( |
| 1527 | int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pRefIndex[][]"); |
| 1528 | pCtx->sMb.pDirect[i] = (int8_t (*)[MB_BLOCK4x4_NUM])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * |
| 1529 | sizeof ( |
| 1530 | int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pDirect[]"); |
| 1531 | pCtx->sMb.pLumaQp[i] = (int8_t*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), |
| 1532 | "pCtx->sMb.pLumaQp[]"); |
| 1533 | pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[i] = (bool*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * |
| 1534 | sizeof ( |
| 1535 | bool), |
| 1536 | "pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[]"); |
| 1537 | pCtx->sMb.pTransformSize8x8Flag[i] = (bool*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( |
| 1538 | bool), |
| 1539 | "pCtx->sMb.pTransformSize8x8Flag[]"); |
| 1540 | pCtx->sMb.pChromaQp[i] = (int8_t (*)[2])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( |
| 1541 | int8_t) * 2, |
| 1542 | "pCtx->sMb.pChromaQp[]"); |
| 1543 | pCtx->sMb.pMvd[i][LIST_0] = (int16_t (*)[16][2])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( |
| 1544 | int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMvd[][]"); |
| 1545 | pCtx->sMb.pMvd[i][LIST_1] = (int16_t (*)[16][2])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( |
| 1546 | int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMvd[][]"); |
| 1547 | pCtx->sMb.pCbfDc[i] = (uint16_t*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (uint16_t), |
no test coverage detected