Int32 VcapVencVdecVdis_ipcBitsInit(VcapVencVdecVdis_res resolution[], 
                                         Bool enableFWrite,
                                         Bool enableLayerWrite)

{
    VENC_CALLBACK_S callback;
    Int i;

    VcapVencVdecVdis_resetAvgStatistics();
    VcapVencVdecVdis_resetStatistics();

    gVcapVencVdecVdis_ipcBitsCtrl.fObj.enableFWrite = enableFWrite;
    gVcapVencVdecVdis_ipcBitsCtrl.fObj.enableLayerWrite = enableLayerWrite;

    callback.newDataAvailableCb = VcapVencVdecVdis_ipcBitsInCbFxn;
    /* Register call back with encoder */
    Venc_registerCallback(&callback,
                         (Ptr)&gVcapVencVdecVdis_ipcBitsCtrl);

    VcapVencVdecVdis_FreeBitBufInit();
    if (gVcapVencVdecVdis_ipcBitsCtrl.fObj.enableFWrite == TRUE){
        VcapVencVdecVdis_ipcBitsInitFObj();
    }
    VcapVencVdecVdis_ipcBitsInitDmaObj();

    for (i=0; i<MCFW_IPCBITS_RESOLUTION_TYPES; i++)
        gVcapVencVdecVdis_ipcBitsCtrl.thrObj.resolution[i] = resolution[i];

    VcapVencVdecVdis_ipcBitsInitThrObj(&gVcapVencVdecVdis_ipcBitsCtrl.thrObj);
    memset (&gVcapVencVdecVdis_ipcBitsCtrl.decInfo,0,sizeof(gVcapVencVdecVdis_ipcBitsCtrl.decInfo));
    return OSA_SOK;
}
Int32 VcapVencVdecVdis_ipcBitsInit(VcapVencVdecVdis_res resolution, Bool enableFWrite)
{
    VENC_CALLBACK_S callback;
    Int32 status;

    VcapVencVdecVdis_resetStatistics();

    gVcapVencVdecVdis_ipcBitsCtrl.fObj.enableFWrite = enableFWrite;

    callback.newDataAvailableCb = VcapVencVdecVdis_ipcBitsInCbFxn;
    /* Register call back with encoder */
    Venc_registerCallback(&callback,
                          (Ptr)&gVcapVencVdecVdis_ipcBitsCtrl);

    VcapVencVdecVdis_FreeBitBufInit();
    if (gVcapVencVdecVdis_ipcBitsCtrl.fObj.enableFWrite == TRUE) {
        VcapVencVdecVdis_ipcBitsInitFObj();
    }
    gVcapVencVdecVdis_ipcBitsCtrl.thrObj.resolution = resolution;

    OSA_dmaInit();
    status = OSA_dmaOpen(&gVcapVencVdecVdis_ipcBitsCtrl.dmaHndl, OSA_DMA_MODE_NORMAL, 1);

    VcapVencVdecVdis_ipcBitsInitThrObj(&gVcapVencVdecVdis_ipcBitsCtrl.thrObj);
    return OSA_SOK;
}
Int32 VcapVenc_bitsWriteCreate()
{
    VENC_CALLBACK_S callback;

    Int32 status;

    gVcapVenc_ctrl.fileWriteChn = 0;

    gVcapVenc_ctrl.fileWriteEnable = Demo_getFileWriteEnable();

    if(gVcapVenc_ctrl.fileWriteEnable)
    {
        char path[256];

        Demo_getFileWritePath(path, "/dev/shm");

        gVcapVenc_ctrl.fileWriteChn = Demo_getChId("File Write", gDemo_info.maxVencChannels);

        sprintf(gVcapVenc_ctrl.fileWriteName, "%s/VID_CH%02d.h264", path, gVcapVenc_ctrl.fileWriteChn);
    }

    gVcapVenc_ctrl.exitWrThr = FALSE;
    gVcapVenc_ctrl.isWrThrStopDone = FALSE;

    callback.newDataAvailableCb = VcapVenc_bitsWriteCbFxn;

    /* Register call back with encoder */
    Venc_registerCallback(&callback,
                          (Ptr)&gVcapVenc_ctrl);

    status = OSA_semCreate(&gVcapVenc_ctrl.wrSem, 1, 0);
    OSA_assert(status==OSA_SOK);

    status = OSA_thrCreate(
                 &gVcapVenc_ctrl.wrThrHndl,
                 VcapVenc_bitsWriteMain,
                 OSA_THR_PRI_DEFAULT,
                 0,
                 &gVcapVenc_ctrl
             );

    OSA_assert(status==OSA_SOK);

    return OSA_SOK;
}