void Scan::StartParseHiddenRefinementScan(class ByteStream *io,class BufferCtrl *ctrl)
{
  m_bHidden = true;
  bool residual = false;

  if (m_pParser == NULL) {
    ScanType type = m_pFrame->ScanTypeOf();
    //
    switch(type) {
    case Baseline:
    case Sequential: 
    case Progressive:
      ParseMarker(io,Progressive);
      m_pParser = new(m_pEnviron) RefinementScan(m_pFrame,this,
                                                 m_ucScanStart,m_ucScanStop,
                                                 m_ucLowBit,m_ucHighBit,
                                                 false,false);
      break;
    case ACSequential:
    case ACProgressive:
#if ACCUSOFT_CODE
      ParseMarker(io,ACProgressive);
      m_pParser = new(m_pEnviron) ACRefinementScan(m_pFrame,this,
                                                   m_ucScanStart,m_ucScanStop,
                                                   m_ucLowBit,m_ucHighBit,
                                                   false,false);
#else
      JPG_THROW(NOT_IMPLEMENTED,"Scan::StartParseHiddenRefinementScan",
                "Arithmetic coding option not available in your code release, please contact Accusoft for a full version");
#endif
      break; 
    case Residual:
    case ResidualProgressive:
      residual = true;
      // fall through
    case ResidualDCT:
      ParseMarker(io,ResidualProgressive);
      m_pParser  = new(m_pEnviron) RefinementScan(m_pFrame,this,
                                                  m_ucScanStart,m_ucScanStop,
                                                  m_ucLowBit,m_ucHighBit,
                                                  false,residual);
      break;
    case ACResidual:
    case ACResidualProgressive:
      residual = true;
      // fall through
    case ACResidualDCT:
#if ACCUSOFT_CODE
      ParseMarker(io,ACResidualProgressive);
      m_pParser  = new(m_pEnviron) ACRefinementScan(m_pFrame,this, 
                                                    m_ucScanStart,m_ucScanStop,
                                                    m_ucLowBit,m_ucHighBit,
                                                    false,true);
#else
      JPG_THROW(NOT_IMPLEMENTED," Scan::MakeHiddenRefinementScan",
                "Arithmetic coding option not available in your code release, "
                "please contact Accusoft for a full version");
#endif   
      break; 
    default:
      JPG_THROW(NOT_IMPLEMENTED,"Scan::StartParseHiddenRefinementScan",
                "sorry, the coding mode in the codestream is currently not supported");
    }
  } 

  ctrl->PrepareForDecoding();
  m_pParser->StartParseScan(io,NULL,ctrl);
}
void Scan::StartParseHiddenRefinementScan(class ByteStream *io,class BufferCtrl *ctrl)
{
  m_bHidden = true;
  bool residual = false;

  if (m_pParser == NULL) {
    ScanType type = m_pFrame->ScanTypeOf();
     
    switch(type) {
    case Baseline:
    case Sequential: 
    case Progressive:
      ParseMarker(io,Progressive);
      m_pParser = new(m_pEnviron) RefinementScan(m_pFrame,this,
                                                 m_ucScanStart,m_ucScanStop,
                                                 m_ucLowBit,m_ucHighBit,
                                                 false,false);
      break;
    case ACSequential:
    case ACProgressive:
#if ACCUSOFT_CODE
      ParseMarker(io,ACProgressive);
      m_pParser = new(m_pEnviron) ACRefinementScan(m_pFrame,this,
                                                   m_ucScanStart,m_ucScanStop,
                                                   m_ucLowBit,m_ucHighBit,
                                                   false,false);
#else
      JPG_THROW(NOT_IMPLEMENTED,"Scan::StartParseHiddenRefinementScan",
                "Arithmetic coding option not available in your code release, please contact Accusoft for a full version");
#endif
      break; 
    case Residual:
    case ResidualProgressive:
      residual = true;
       
    case ResidualDCT:
      ParseMarker(io,ResidualProgressive);
      m_pParser  = new(m_pEnviron) RefinementScan(m_pFrame,this,
                                                  m_ucScanStart,m_ucScanStop,
                                                  m_ucLowBit,m_ucHighBit,
                                                  false,residual);
      break;
    case ACResidual:
    case ACResidualProgressive:
      residual = true;
       
    case ACResidualDCT:
#if ACCUSOFT_CODE
      ParseMarker(io,ACResidualProgressive);
      m_pParser  = new(m_pEnviron) ACRefinementScan(m_pFrame,this, 
                                                    m_ucScanStart,m_ucScanStop,
                                                    m_ucLowBit,m_ucHighBit,
                                                    false,true);
#else
      JPG_THROW(NOT_IMPLEMENTED," Scan::MakeHiddenRefinementScan",
                "Arithmetic coding option not available in your code release, "
                "please contact Accusoft for a full version");
#endif   
      break; 
    default:
      JPG_THROW(NOT_IMPLEMENTED,"Scan::StartParseHiddenRefinementScan",
                "sorry, the coding mode in the codestream is currently not supported");
    }
  } 

  ctrl->PrepareForDecoding();
  m_pParser->StartParseScan(io,NULL,ctrl);
}