⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 swdec_headers.c

📁 freescale i.mx31 BSP CE5.0全部源码
💻 C
📖 第 1 页 / 共 2 页
字号:
            }
            if ( tmp && (tmp!=END_OF_STREAM))
                return(SPRITE_ENABLE);
            tmp = pDecContainer->Hdrs.not8Bit = 
                SwDec_GetOneBit(pDecContainer);
            if (tmp == 1)
                return(NOT_8_BIT);
            tmp = pDecContainer->Hdrs.quantType = 
                SwDec_GetOneBit(pDecContainer);
            if (tmp == 1)
                return(QUANT_TYPE);
            if ( pDecContainer->Hdrs.videoObjectLayerVerid!=1 ) {
                /* quarter_sample */
                tmp = SwDec_GetOneBit(pDecContainer);
                if ( tmp==1 )
                    return(QUARTER_SAMPLE);
            }
            tmp = pDecContainer->Hdrs.complexityEstimationDisable =
                SwDec_GetOneBit(pDecContainer);
            if ( tmp==0 ){
                /* complexity estimation header */
                tmp = SwDec_DefineVopComplexityEstimation(pDecContainer);
                if ( tmp==HANTRO_NOK )
                    return(HANTRO_NOK);
            }
            pDecContainer->Hdrs.resyncMarkerDisable = 
                SwDec_GetOneBit(pDecContainer);
            tmp = pDecContainer->Hdrs.dataPartitioned = 
                SwDec_GetOneBit(pDecContainer);
            if ( tmp )
                pDecContainer->Hdrs.reversibleVlc = 
                    SwDec_GetOneBit(pDecContainer);
            else
                pDecContainer->Hdrs.reversibleVlc = 0;
            if ( pDecContainer->Hdrs.videoObjectLayerVerid!=1 ){
                /* newpred_enable */
                tmp = SwDec_GetOneBit(pDecContainer);
                if ( tmp==1 )
                    return(NEWPRED_ENABLE);
                /* reduced_resolution_vop_enable */
                tmp = SwDec_GetOneBit(pDecContainer);
                if ( tmp==1 )
                    return(REDUCED_RESOLUTION_VOP_ENABLE);
            }
            tmp = pDecContainer->Hdrs.scalability = 
                SwDec_GetOneBit(pDecContainer);
            if ( tmp==1)
                return(SCALABILITY);
            CHECK_END_OF_STREAM(tmp);
            /* stuffing */
            tmp = SwDec_GetBits(pDecContainer,
                    8-pDecContainer->StrmDesc.bitPosInWord);
            CHECK_END_OF_STREAM(tmp);
            
            pDecContainer->Hdrs.lastHeaderType = SC_VOL_START;
            /* user data */
            tmp = SwDec_SaveUserData(pDecContainer,SC_VOL_START);
            return(tmp);
    /*lint --e(744) */
    }
    
    return(HANTRO_OK);
}

/*------------------------------------------------------------------------------

   5.2  Function name: 
                SwDec_DecodeGovHeader

        Purpose: 
                Decodes Group Of Vop header
                 
        Input: 
                pointer to decContainer_t, name of first header to decode

        Output: 
                HANTRO_OK/HANTRO_NOK/END_OF_STREAM

------------------------------------------------------------------------------*/

u32 SwDec_DecodeGovHeader(decContainer_t *pDecContainer)
{
    u32 tmp;

    ASSERT(pDecContainer);

    tmp = pDecContainer->VopDesc.timeCodeHours = 
        SwDec_GetBits(pDecContainer,5);
    if ( (tmp>23) && (tmp!=END_OF_STREAM))
        return(HANTRO_NOK);
    tmp = pDecContainer->VopDesc.timeCodeMinutes = 
        SwDec_GetBits(pDecContainer,6);
    if ( (tmp>59) && (tmp!=END_OF_STREAM))
        return(HANTRO_NOK);
    /* marker bit */
    tmp = SwDec_GetOneBit(pDecContainer);
    if ( tmp==0 )
        return(HANTRO_NOK);
    tmp = pDecContainer->VopDesc.timeCodeSeconds = 
        SwDec_GetBits(pDecContainer,6);
    if ( (tmp>59) && (tmp!=END_OF_STREAM))
        return(HANTRO_NOK);
    pDecContainer->Hdrs.closedGov = 
        SwDec_GetOneBit(pDecContainer);
    pDecContainer->Hdrs.brokenLink = 
        SwDec_GetOneBit(pDecContainer);
    /* stuffing */
    tmp = SwDec_GetBits(pDecContainer,
            8-pDecContainer->StrmDesc.bitPosInWord);
    CHECK_END_OF_STREAM(tmp);

    pDecContainer->Hdrs.lastHeaderType = SC_GVOP_START;
    pDecContainer->VopDesc.govCounter++;
    tmp = SwDec_SaveUserData(pDecContainer,SC_GVOP_START);
    return(tmp);
        
}

/*------------------------------------------------------------------------------

   5.3  Function name: 
                SwDec_DefineVopComplexityEstimation

        Purpose: 
                Decodes fields from VOL define_vop_complexity_estimation_
                header
                 
        Input: 
                pointer to decContainer_t

        Output: 
                HANTRO_OK/HANTRO_NOK/END_OF_STREAM

------------------------------------------------------------------------------*/
u32 SwDec_DefineVopComplexityEstimation(decContainer_t *pDecContainer)
{
    u32 tmp;
    u32 markerBit;
    u32 estimationMethod;

    ASSERT(pDecContainer);

    estimationMethod = pDecContainer->Hdrs.estimationMethod = 
        SwDec_GetBits(pDecContainer,2);
    if ( (estimationMethod==VERSION1) || 
         (estimationMethod==VERSION2) ){
        tmp = pDecContainer->Hdrs.shapeComplexityEstimationDisable = 
            SwDec_GetOneBit(pDecContainer);
        if ( tmp==0 ){
            pDecContainer->Hdrs.opaque = SwDec_GetOneBit(pDecContainer);
            pDecContainer->Hdrs.transparent = SwDec_GetOneBit(pDecContainer);
            pDecContainer->Hdrs.intraCae = SwDec_GetOneBit(pDecContainer);
            pDecContainer->Hdrs.interCae = SwDec_GetOneBit(pDecContainer);
            pDecContainer->Hdrs.noUpdate = SwDec_GetOneBit(pDecContainer);
            pDecContainer->Hdrs.upsampling = SwDec_GetOneBit(pDecContainer);
        } else {
            /* initialisation to zero */
            pDecContainer->Hdrs.opaque = 0;
            pDecContainer->Hdrs.transparent = 0;
            pDecContainer->Hdrs.intraCae = 0;
            pDecContainer->Hdrs.interCae = 0;
            pDecContainer->Hdrs.noUpdate = 0;
            pDecContainer->Hdrs.upsampling = 0;
        }
        tmp = 
            pDecContainer->Hdrs.textureComplexityEstimationSet1Disable =
            SwDec_GetOneBit(pDecContainer);
        if ( tmp==0 ){
            pDecContainer->Hdrs.intraBlocks = SwDec_GetOneBit(pDecContainer);
            pDecContainer->Hdrs.interBlocks = SwDec_GetOneBit(pDecContainer);
            pDecContainer->Hdrs.inter4vBlocks = SwDec_GetOneBit(pDecContainer);
            pDecContainer->Hdrs.notCodedBlocks = SwDec_GetOneBit(pDecContainer);
        } else {
            /* Initialization to zero */
            pDecContainer->Hdrs.intraBlocks = 0;
            pDecContainer->Hdrs.interBlocks = 0;
            pDecContainer->Hdrs.inter4vBlocks = 0;
            pDecContainer->Hdrs.notCodedBlocks = 0;
        }
        markerBit = SwDec_GetOneBit(pDecContainer);
        if ( markerBit==0 )
            return(HANTRO_NOK);
        tmp = 
            pDecContainer->Hdrs.textureComplexityEstimationSet2Disable =
            SwDec_GetOneBit(pDecContainer);
        if ( tmp==0 ){
            pDecContainer->Hdrs.dctCoefs = SwDec_GetOneBit(pDecContainer);
            pDecContainer->Hdrs.dctLines = SwDec_GetOneBit(pDecContainer);
            pDecContainer->Hdrs.vlcSymbols = SwDec_GetOneBit(pDecContainer);
            pDecContainer->Hdrs.vlcBits = SwDec_GetOneBit(pDecContainer);
        } else {
            /* initialisation to zero */
            pDecContainer->Hdrs.dctCoefs = 0;
            pDecContainer->Hdrs.dctLines = 0;
            pDecContainer->Hdrs.vlcSymbols = 0;
            pDecContainer->Hdrs.vlcBits = 0;
        }
        tmp = pDecContainer->Hdrs.motionCompensationComplexityDisable =
            SwDec_GetOneBit(pDecContainer);
        if ( tmp==0 ){
            pDecContainer->Hdrs.apm = SwDec_GetOneBit(pDecContainer);
            pDecContainer->Hdrs.npm = SwDec_GetOneBit(pDecContainer);
            pDecContainer->Hdrs.interpolateMcQ = SwDec_GetOneBit(pDecContainer);
            pDecContainer->Hdrs.forwBackMcQ = SwDec_GetOneBit(pDecContainer);
            pDecContainer->Hdrs.halfpel2 = SwDec_GetOneBit(pDecContainer);
            pDecContainer->Hdrs.halfpel4 = SwDec_GetOneBit(pDecContainer);
        } else {
            /* initilisation to zero */
            pDecContainer->Hdrs.apm = 0;
            pDecContainer->Hdrs.npm = 0;
            pDecContainer->Hdrs.interpolateMcQ = 0;
            pDecContainer->Hdrs.forwBackMcQ = 0;
            pDecContainer->Hdrs.halfpel2 = 0;
            pDecContainer->Hdrs.halfpel4 = 0;
        }
        markerBit = SwDec_GetOneBit(pDecContainer);
        if ( markerBit==0 )
            return(HANTRO_NOK);
        if ( estimationMethod==VERSION2 ){
            tmp = 
                pDecContainer->Hdrs.version2ComplexityEstimationDisable=
                SwDec_GetOneBit(pDecContainer);
            if ( tmp==0 ){
                pDecContainer->Hdrs.sadct = SwDec_GetOneBit(pDecContainer);
                pDecContainer->Hdrs.quarterpel = SwDec_GetOneBit(pDecContainer);
            } else {
                /* initialisation to zero */
                pDecContainer->Hdrs.sadct = 0;
                pDecContainer->Hdrs.quarterpel = 0;
            }
        } else {
            pDecContainer->Hdrs.version2ComplexityEstimationDisable = 1;
            /* init to zero */
            pDecContainer->Hdrs.sadct = 0;
            pDecContainer->Hdrs.quarterpel = 0;
        }
    }
    return(HANTRO_OK);
}

/*------------------------------------------------------------------------------

   5.4  Function name: 
                SwDec_SaveUserData

        Purpose: 
                Saves user data from headers
                 
        Input: 
                pointer to decContainer_t
                mode indicating which user data is handled

        Output: 
                HANTRO_OK/HANTRO_NOK/END_OF_STREAM

------------------------------------------------------------------------------*/

u32 SwDec_SaveUserData(decContainer_t *pDecContainer, u32 mode)
{
    u32 tmp;
    u32 len;
    u32 enable;
    u32 status = HANTRO_OK;
    u32 maxLen = 0;
    u32 *plen = NULL;
    u8 *pOutput = NULL;

    ASSERT(pDecContainer);
    ASSERT((mode == SC_VOS_START) || (mode == SC_VISO_START) ||
           (mode == SC_VOL_START) || (mode == SC_GVOP_START) );
    ASSERT(!pDecContainer->StrmDesc.bitPosInWord);

    tmp = SwDec_ShowBits(pDecContainer,32);
    if ( tmp!=SC_UD_START ){
        /* there is no user data */
        return(HANTRO_OK);
    }
    else
        SwDec_FlushBits(pDecContainer,32);
    
    switch (mode)
    {
        case SC_VOS_START:
            maxLen = pDecContainer->StrmDesc.userDataVOSMaxLen;
            plen = &(pDecContainer->StrmDesc.userDataVOSLen);
            pOutput = pDecContainer->StrmDesc.pUserDataVOS;
            break;

        case SC_VISO_START:
            maxLen = pDecContainer->StrmDesc.userDataVOMaxLen;
            plen = &(pDecContainer->StrmDesc.userDataVOLen);
            pOutput = pDecContainer->StrmDesc.pUserDataVO;
            break;

        case SC_VOL_START:
            maxLen = pDecContainer->StrmDesc.userDataVOLMaxLen;
            plen = &(pDecContainer->StrmDesc.userDataVOLLen);
            pOutput = pDecContainer->StrmDesc.pUserDataVOL;
            break;

        case SC_GVOP_START:
            maxLen = pDecContainer->StrmDesc.userDataGOVMaxLen;
            plen = &(pDecContainer->StrmDesc.userDataGOVLen);
            pOutput = pDecContainer->StrmDesc.pUserDataGOV;
            break;
    /*lint --e(744) */
    }

    if (maxLen && pOutput)
        enable = 1;
    else
        enable = 0;

    len = 0;
    /* read (and save) user data */
    while ( !IS_END_OF_STREAM(pDecContainer) )
    {
        tmp =  SwDec_ShowBits(pDecContainer,32);
        if ( (tmp>>8)==0x01 ){
            /* start code */
            if ( tmp!=SC_UD_START )
                break;
            else
            {
                (void)SwDec_FlushBits(pDecContainer,32);
                continue;
            }
        }
        tmp = tmp>>24;
        (void)SwDec_FlushBits(pDecContainer,8);

        if ( enable && (len<maxLen) ){
            /*lint --e(613) */
            *pOutput++ = (u8)tmp;
        }

        len++;
    }

    /*lint --e(613) */
    *plen = len;
    
    return(status);
}

/*------------------------------------------------------------------------------

    5.5. Function name: SwDec_ClearHeaders

         Purpose:   Initialize data to default values 
                 
         Input:     pointer to decHdrs_t 
                       
         Output: 

------------------------------------------------------------------------------*/

void SwDec_ClearHeaders(decHdrs_t *hdrs)
{

    MP4SwDecMemset(hdrs, 0, sizeof(decHdrs_t));
    /* have to be initialized into 1 to enable decoding stream without
     * VO-headers */
    hdrs->visualObjectVerid          = 1;
    hdrs->videoFormat                = 5;
    hdrs->colourPrimaries            = 1;
    hdrs->transferCharacteristics    = 1;
    hdrs->matrixCoefficients         = 1;
    hdrs->lowDelay                   = 1;

}
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -