Exemple #1
0
/*------------------------------------------------------------------------------
    OSAL_AllocatorInit
------------------------------------------------------------------------------*/
OSAL_ERRORTYPE OSAL_AllocatorInit(OSAL_ALLOCATOR* alloc)
{
#ifdef OMX_MEM_TRC

        pf = fopen("omx_mem_trc.csv", "w");
        if(pf)
            fprintf(pf,
            "linead memory usage in bytes;linear memory usage in 4096 pages;\n");

#endif
#ifdef ANDROID
    if(alloc->pdwl)
        return OSAL_ERRORNONE;

    TRACE("OSAL_Init\n");

    DWLInitParam_t dwlInit;

    dwlInit.clientType = DWL_CLIENT_TYPE_H264_DEC;

    alloc->pdwl = (void*)DWLInit(&dwlInit);


    // NOTE: error handling
    return OSAL_ERRORNONE;
#endif
#ifdef MEMALLOCHW
    OSAL_ERRORTYPE err = OSAL_ERRORNONE;
    // open memalloc for linear memory allocation
    alloc->fd_memalloc = open("/tmp/dev/memalloc", O_RDWR | O_SYNC);
    //alloc->fd_memalloc = open("/dev/memalloc", O_RDWR | O_SYNC);
    if (alloc->fd_memalloc == -1)
    {
        TRACE_PRINT("memalloc not found\n");
        err = OSAL_ERROR_UNDEFINED;
        goto FAIL;
    }
    // open raw memory for memory mapping
    alloc->fd_mem = open("/dev/mem", O_RDWR | O_SYNC);
    //alloc->fd_mem = open("/dev/uio0", O_RDWR | O_SYNC);
    if (alloc->fd_mem == -1)
    {
        TRACE_PRINT("uio0 not found\n");
        err = OSAL_ERROR_UNDEFINED;
        goto FAIL;
    }
    return OSAL_ERRORNONE;
 FAIL:
    if (alloc->fd_memalloc > 0) close(alloc->fd_memalloc);
    if (alloc->fd_mem > 0)      close(alloc->fd_mem);
    return err;
#else
    return OSAL_ERRORNONE;
#endif
}
static void
gst_dwl_allocator_init (GstDwlAllocator * allocator)
{
  DWLInitParam_t params;

  GST_CAT_DEBUG (GST_CAT_MEMORY, "init allocator %p", allocator);

  /* Use H264 as client, not really needed for anything but as a container */
  params.clientType = DWL_CLIENT_TYPE_H264_DEC;
  allocator->dwl = DWLInit (&params);
}
/*------------------------------------------------------------------------------
    Function name   : vp6decinit
    Description     : 
    Return type     : VP6DecRet 
    Argument        : VP6DecInst * pDecInst
                      u32 useVideoFreezeConcealment
------------------------------------------------------------------------------*/
VP6DecRet VP6DecInit(VP6DecInst * pDecInst, 
                     u32 useVideoFreezeConcealment,
                     u32 numFrameBuffers,
                     DecDpbFlags dpbFlags)
{
    VP6DecRet ret;
    VP6DecContainer_t *pDecCont;
    const void *dwl;
    u32 i;
    u32 referenceFrameFormat;

    DWLInitParam_t dwlInit;
    DWLHwConfig_t config;

    DEC_API_TRC("VP6DecInit#\n");

    /* check that right shift on negative numbers is performed signed */
    /*lint -save -e* following check causes multiple lint messages */
#if (((-1) >> 1) != (-1))
#error Right bit-shifting (>>) does not preserve the sign
#endif
    /*lint -restore */

    if(pDecInst == NULL)
    {
        DEC_API_TRC("VP6DecInit# ERROR: pDecInst == NULL");
        return (VP6DEC_PARAM_ERROR);
    }

    *pDecInst = NULL;   /* return NULL instance for any error */

    /* check that VP6 decoding supported in HW */
    {

        DWLHwConfig_t hwCfg;

        DWLReadAsicConfig(&hwCfg);
        if(!hwCfg.vp6Support)
        {
            DEC_API_TRC("VP6DecInit# ERROR: VP6 not supported in HW\n");
            return VP6DEC_FORMAT_NOT_SUPPORTED;
        }
    }

    /* init DWL for the specified client */
    dwlInit.clientType = DWL_CLIENT_TYPE_VP6_DEC;

    dwl = DWLInit(&dwlInit);

    if(dwl == NULL)
    {
        DEC_API_TRC("VP6DecInit# ERROR: DWL Init failed\n");
        return (VP6DEC_DWL_ERROR);
    }

    /* allocate instance */
    pDecCont = (VP6DecContainer_t *) DWLmalloc(sizeof(VP6DecContainer_t));

    if(pDecCont == NULL)
    {
        DEC_API_TRC("VP6DecInit# ERROR: Memory allocation failed\n");
        ret = VP6DEC_MEMFAIL;
        goto err;
    }

    (void) DWLmemset(pDecCont, 0, sizeof(VP6DecContainer_t));
    pDecCont->dwl = dwl;

    /* initial setup of instance */

    pDecCont->decStat = VP6DEC_INITIALIZED;
    pDecCont->checksum = pDecCont;  /* save instance as a checksum */
    if(numFrameBuffers > 16)    numFrameBuffers = 16;
    if(numFrameBuffers < 3)     numFrameBuffers = 3;
    pDecCont->numBuffers = numFrameBuffers;

    VP6HwdAsicInit(pDecCont);   /* Init ASIC */

    if(VP6HwdAsicAllocateMem(pDecCont) != 0)
    {
        DEC_API_TRC("VP6DecInit# ERROR: ASIC Memory allocation failed\n");
        ret = VP6DEC_MEMFAIL;
        goto err;
    }

    (void)DWLmemset(&config, 0, sizeof(DWLHwConfig_t));

    DWLReadAsicConfig(&config);

    i = DWLReadAsicID() >> 16;
    if(i == 0x8170U)
        useVideoFreezeConcealment = 0;
    pDecCont->refBufSupport = config.refBufSupport;
    referenceFrameFormat = dpbFlags & DEC_REF_FRM_FMT_MASK;   
    if(referenceFrameFormat == DEC_REF_FRM_TILED_DEFAULT)
    {
        /* Assert support in HW before enabling.. */
        if(!config.tiledModeSupport)
        {
            return VP6DEC_FORMAT_NOT_SUPPORTED;
        }
        pDecCont->tiledModeSupport = config.tiledModeSupport;
    }
    else
        pDecCont->tiledModeSupport = 0;

    pDecCont->intraFreeze = useVideoFreezeConcealment;
    pDecCont->pictureBroken = 0;

    pDecCont->decStat = VP6DEC_INITIALIZED;

    /* return new instance to application */
    *pDecInst = (VP6DecInst) pDecCont;

    DEC_API_TRC("VP6DecInit# OK\n");
    return (VP6DEC_OK);

  err:
    if(pDecCont != NULL)
        DWLfree(pDecCont);

    if(dwl != NULL)
    {
        i32 dwlret = DWLRelease(dwl);

        ASSERT(dwlret == DWL_OK);
        (void) dwlret;
    }
    *pDecInst = NULL;
    return ret;
}