/// RefinementScan::WriteMCU // Write a single MCU in this scan. Return true if there are more blocks in this row. bool RefinementScan::WriteMCU(void) { bool more = true; int c; assert(m_pBlockCtrl); BeginWriteMCU(m_bMeasure?NULL:m_Stream.ByteStreamOf()); for(c = 0;c < m_ucCount;c++) { class Component *comp = m_pComponent[c]; class QuantizedRow *q = m_pBlockCtrl->CurrentQuantizedRow(comp->IndexOf()); class HuffmanCoder *ac = m_pACCoder[c]; class HuffmanStatistics *acstat = m_pACStatistics[c]; UWORD &skip = m_usSkip[c]; UBYTE mcux = (m_ucCount > 1)?(comp->MCUWidthOf() ):(1); UBYTE mcuy = (m_ucCount > 1)?(comp->MCUHeightOf()):(1); ULONG xmin = m_ulX[c]; ULONG xmax = xmin + mcux; ULONG x,y; if (xmax >= q->WidthOf()) { more = false; } for(y = 0;y < mcuy;y++) { for(x = xmin;x < xmax;x++) { LONG *block,dummy[64]; if (q && x < q->WidthOf()) { block = q->BlockAt(x)->m_Data; } else { block = dummy; memset(dummy ,0,sizeof(dummy) ); } if (m_bMeasure) { MeasureBlock(block,acstat,skip); } else { EncodeBlock(block,ac,skip); } } if (q) q = q->NextOf(); } // Done with this component, advance the block. m_ulX[c] = xmax; } return more; }
/// SequentialScan::WriteMCU // Write a single MCU in this scan. Return true if there are more blocks in this row. bool SequentialScan::WriteMCU(void) { bool more = true; int c; assert(m_pBlockCtrl); BeginWriteMCU(m_Stream.ByteStreamOf()); for(c = 0;c < m_ucCount;c++) { class Component *comp = m_pComponent[c]; class QuantizedRow *q = m_pBlockCtrl->CurrentQuantizedRow(comp->IndexOf()); class HuffmanCoder *dc = m_pDCCoder[c]; class HuffmanCoder *ac = m_pACCoder[c]; class HuffmanStatistics *dcstat = m_pDCStatistics[c]; class HuffmanStatistics *acstat = m_pACStatistics[c]; LONG &prevdc = m_lDC[c]; UWORD &skip = m_usSkip[c]; UBYTE mcux = (m_ucCount > 1)?(comp->MCUWidthOf() ):(1); UBYTE mcuy = (m_ucCount > 1)?(comp->MCUHeightOf()):(1); ULONG xmin = m_ulX[c]; ULONG xmax = xmin + mcux; ULONG x,y; if (xmax >= q->WidthOf()) { more = false; } for(y = 0;y < mcuy;y++) { for(x = xmin;x < xmax;x++) { LONG *block,dummy[64]; if (q && x < q->WidthOf()) { block = q->BlockAt(x)->m_Data; } else { block = dummy; memset(dummy ,0,sizeof(dummy) ); block[0] = prevdc; } #if HIERARCHICAL_HACK // A nice hack for the hierarchical scan: If this is not the last frame // in the hierarchy, remove all coefficients below the diagonal to allow a // fast "EOB", they can be encoded by the level above. if (m_pFrame->NextOf()) { LONG i,j; for(j = 0;j < 8;j++) { for(i = 0;i < 8;i++) { if (i+j > 4) { block[i + (j << 3)] = 0; } } } } #endif if (m_bMeasure) { MeasureBlock(block,dcstat,acstat,prevdc,skip); } else { EncodeBlock(block,dc,ac,prevdc,skip); } } if (q) q = q->NextOf(); } // Done with this component, advance the block. m_ulX[c] = xmax; } return more; }