Example #1
0
void CompDecompressor::Decompress(ComponentByteIO* p_component_byteio,
                                  CoeffArray& coeff_data,
                                  SubbandList& bands)
{

    // Set up the code blocks
    SetupCodeBlocks( bands );

    for ( int b=bands.Length() ; b>=1 ; --b ){
        // Multiple quantiser are used only if
        // a. The global code_block_mode is QUANT_MULTIPLE
        //              and
        // b. More than one code block is present in the subband.
        bands(b).SetUsingMultiQuants( 
                           m_decparams.SpatialPartition() &&
                           m_decparams.GetCodeBlockMode() == QUANT_MULTIPLE &&
                           (bands(b).GetCodeBlocks().LengthX() > 1 ||
                           bands(b).GetCodeBlocks().LengthY() > 1)
                                );

        // Read the header data first
        SubbandByteIO subband_byteio(bands(b), *p_component_byteio);
        subband_byteio.Input();
        
        if ( !bands(b).Skipped() ){
            if (m_pparams.UsingAC()){
                // A pointer to the object(s) we'll be using for coding the bands
                BandCodec* bdecoder;
    
                if ( b>=bands.Length()-3){
                    if ( m_psort.IsIntra() && b==bands.Length() )
                        bdecoder=new IntraDCBandCodec(&subband_byteio, 
                                                       TOTAL_COEFF_CTXS ,bands);
                    else
                        bdecoder=new LFBandCodec(&subband_byteio ,
                                                 TOTAL_COEFF_CTXS, bands ,
                                                 b, m_psort.IsIntra());
                }
                else
                    bdecoder=new BandCodec( &subband_byteio , TOTAL_COEFF_CTXS ,
                                            bands , b, m_psort.IsIntra());

                bdecoder->Decompress(coeff_data , subband_byteio.GetBandDataLength());
                delete bdecoder;
            }
            else{
                // A pointer to the object(s) we'll be using for coding the bands
                BandVLC* bdecoder;
    
                   if ( m_psort.IsIntra() && b==bands.Length() )
                      bdecoder=new IntraDCBandVLC(&subband_byteio, bands);
                else
                    bdecoder=new BandVLC( &subband_byteio , bands ,
                                          b, m_psort.IsIntra());

                bdecoder->Decompress(coeff_data , subband_byteio.GetBandDataLength());
                delete bdecoder;
            }
        }
        else{
            SetToVal( coeff_data , bands(b) , 0 );
        }
    }
}