/* GetCodecInstance() obtains an instance. It stores a pointer to the allocated instance in *ppInst and returns RETCODE_SUCCESS on success. Failure results in 0(null pointer) in *ppInst and RETCODE_FAILURE.  */
RetCode GetCodecInstance(CodecInst **ppInst)
/* GetCodecInstance() obtains an instance. It stores a pointer to the allocated instance in *ppInst and returns RETCODE_SUCCESS on success. Failure results in 0(null pointer) in *ppInst and RETCODE_FAILURE.  */
RetCode GetCodecInstance(CodecInst **ppInst)
{
    int i;
    CodecInst *pCodecInst;
    for (i = 0; i < MAX_NUM_INSTANCE; ++i) {
        pCodecInst = (CodecInst *) (&g_vpu_hw_map->codecInstPool[i]);
        if (!pCodecInst->inUse)
            break;
    }
    if (i == MAX_NUM_INSTANCE) {
        *ppInst = 0;
        return RETCODE_FAILURE;
    }
    i = pCodecInst->instIndex;
    memset(pCodecInst, 0, sizeof(CodecInst));
    pCodecInst->instIndex = i;
    pCodecInst->inUse = 1;
    *ppInst = pCodecInst;
    return RETCODE_SUCCESS;
}