HM_SCC的调色板模式palette_mode编码流程整理

HM_SCC的调色板模式palette_mode编码流程整理

不足之处,还请各位大佬多多指教。

HM_SCC_plt_framework

    TEncGOP::TEncGOP(){
        m_numPalettePred = 0;  
        m_encodePPSPalette = false;
    }
    
    Void TAppEncTop::encode(){ 

        // initialize internal class & member variables
        xInitLibCfg();
        Void TAppEncTop::xInitLibCfg(){  
            // SCM new added variables
            m_cTEncTop.setUsePaletteMode                                    ( m_usePaletteMode );(542-546)
            m_cTEncTop.setPaletteMaxSize                                    ( m_paletteMaxSize );
            m_cTEncTop.setPaletteMaxPredSize                                ( m_paletteMaxPredSize );
            m_cTEncTop.setPalettePredInSPSEnabled                           ( m_palettePredInSPSEnabled );
            m_cTEncTop.setPalettePredInPPSEnabled                           ( m_palettePredInPPSEnabled );
        }

        xCreateLib();
        Void TAppEncTop::xCreateLib(){
            m_cTEncTop.create();
            Void TEncTop::create (){   
                m_cCuEncoder.create( m_maxTotalCUDepth, m_maxCUWidth, m_maxCUHeight, m_chromaFormatIDC, m_paletteMaxSize, m_paletteMaxPredSize );
                Void TEncCu::create(){ 
                    ...  
                } 
            }

        }

        xInitLib(m_isField);
        Void TAppEncTop::xInitLib(Bool isFieldCoding){

            m_cTEncTop.init(isFieldCoding);
            Void TEncTop::init(Bool isFieldCoding){
                Void TEncTop::xInitSPS(TComSPS &sps){ 

                    // Set up SPS screen extension settings
                    sps.getSpsScreenExtension().setUsePaletteMode( m_usePaletteMode );   
                    sps.getSpsScreenExtension().setPaletteMaxSize( m_paletteMaxSize );
                    sps.getSpsScreenExtension().setPaletteMaxPredSize( m_paletteMaxPredSize );
                    sps.getSpsScreenExtension().setMotionVectorResolutionControlIdc( m_motionVectorResolutionControlIdc );
                    assert( m_paletteMaxPredSize <= 128 );
                }
            }
        }


        // call encoding function for one frame
        if ( m_isField )  //场编码
        // {   (399-476,TEncTop.cpp)
        //     m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, flush ? 0 : &cPicYuvTrueOrg, snrCSC, m_cListPicYuvRec, outputAccessUnits, iNumEncoded, m_isTopFieldFirst );
        //     Void TEncTop::encode(){
        //         compressGOP(); 469
        //     }
        // }
        else
        {    
            m_cTEncTop.encode( bEos, flush ? 0 : pcPicYuvOrg, flush ? 0 : &cPicYuvTrueOrg, snrCSC, m_cListPicYuvRec, outputAccessUnits, iNumEncoded );
            Void TEncTop::encode(){
                compressGOP(); 
            }
        }

        Void TEncGOP::compressGOP(){

            printf("  => sending PPS %u with %u elements\n", pcSlice->getPPS()->getPPSId(), pcSlice->getPPS()->getPpsScreenExtension().getNumPalettePred());  //1853

            m_pcSliceEncoder->precompressSlice( pcPic );  
            Void TEncSlice::precompressSlice( TComPic* pcPic ){

            }

            m_pcSliceEncoder->compressSlice   ( pcPic, false, false );  
            Void TEncSlice::compressSlice( TComPic* pcPic, const Bool bCompressEntireSlice, const Bool bFastDeltaQP ){   
                /* slice-plt-initialize*/
                palette_initialize {...};     

                else
                {
                    xSetPredDefault(lastPalette, lastPaletteSize, pcSlice);
                }                                                                
                // This will only occur if dependent slice-segments (m_entropyCodingSyncContextState=true) are being used. 
                if( pCurrentTile->getTileWidthInCtus() >= 2 || !m_pcCfg->getEntropyCodingSyncEnabledFlag() ){ 
                    //初始化;
                }

                // run CTU trial encoder
                m_pcCuEncoder->compressCtu( pCtu, lastPaletteSize, lastPalette );  933  //默认不执行这个
                m_pcCuEncoder->compressCtu( pCtu, lastPaletteSize, lastPalette );  1254 //************默认执行这句********************//
                Void TEncCu::compressCtu( TComDataCU* pCtu, UChar* lastPaletteSize, Pel lastPalette[][MAX_PALETTE_PRED_SIZE] ){  
                    palette_initialize;
                    
                    xcompressCU();
                    Void TEncCu::xCompressCU( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, const UInt uiDepth DEBUG_STRING_FN_DECLARE(sDebug_), PartSize eParentPartSize )
                    {
                        ...
                        palette_initialize;

                        /***********************************************************************************************************************************/
                        testedModes[iterNumber]=xCheckPaletteMode( rpcBestCU, rpcTempCU, false, iterNumber, paletteSize);  1094,1102,1109,1116,
                        unsigned int TEncCu::xCheckPaletteMode(){
                            3447-3470
                            //搜索最佳调色板,返回无符号整型 testedModes表示成功与否。
                            UInt testedModes=m_pcPredSearch->paletteSearch(...);  3460
                            UInt TEncSearch::paletteSearch(){   8038-8334

                            }
                        }
                        /***********************************************************************************************************************************/
                        Void TEncCu::xCheckRDCostIntra( TComDataCU *&rpcBestCU,TComDataCU *&rpcTempCU,Double &cost,PartSize eSize DEBUG_STRING_FN_DECLARE(sDebug), Bool  bRGBIntraModeReuse){
                            m_pcEntropyCoder->encodePaletteModeInfo( rpcTempCU, 0, true, &bCodeDQP, &codeChromaQpAdjFlag );  
                        }

                        Void TEncCu::xCheckIntraPCM( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU ){
                            m_pcEntropyCoder->encodePaletteModeInfo( rpcTempCU, 0,    true );  
                        }

                        Void TEncCu::xCheckDQP( TComDataCU* pcCU ){
                            if ( pcCU->getQtRootCbf( 0) || ( pcCU->getPaletteModeFlag(0) && pcCU->getPaletteEscape(COMPONENT_Y, 0) ) ){...} 
                        }

                        Void TEncCu::xCheckRDCostIntraCSC(){
                            m_pcEntropyCoder->encodePaletteModeInfo( rpcTempCU, 0, true, &bCodeDQP, &codeChromaQpAdjFlag );  
                        }


                        
                    }
                    
                }

                // encode CTU and calculate the true bit counters.
                m_pcCuEncoder->encodeCtu( pCtu );  
                m_pcCuEncoder->encodeCtu( pCtu );  1596   //************默认执行这句进入CTU编码********************//
                
                Void TEncCu::encodeCtu ( TComDataCU* pCtu ){
                    // Encode CU data
                    xEncodeCU( pCtu, 0, 0 );
                    Void TEncCu::xEncodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
                    {
                    }
                }
            }

            // SCM added functions
            Void TEncSlice::xSetPredFromPPS(Pel lastPalette[MAX_NUM_COMPONENT][MAX_PALETTE_PRED_SIZE], UChar lastPaletteSize[MAX_NUM_COMPONENT], TComSlice *pcSlice)
            Void TEncSlice::xSetPredFromSPS(Pel lastPalette[MAX_NUM_COMPONENT][MAX_PALETTE_PRED_SIZE], UChar lastPaletteSize[MAX_NUM_COMPONENT], TComSlice *pcSlice)
            Void TEncSlice::xSetPredDefault(Pel lastPalette[MAX_NUM_COMPONENT][MAX_PALETTE_PRED_SIZE], UChar lastPaletteSize[MAX_NUM_COMPONENT], TComSlice *pcSlice)

        }

    }
    

        




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值