Encodes this macro block into internal code buffer. Several macro blocks can be encoded in parallel. Call CEncoder::WriteMacroBlock after this method.
480 {
481 UINT8 nPlanes;
482 UINT32 sigLen, codeLen = 0, wordPos, refLen, signLen;
486 UINT32 planeMask;
488 bool useRL;
489
490#ifdef TRACE
491
492#endif
493
494
495 for (UINT32 k=0; k < bufferSize; k++) {
497 }
499
500
501 for (UINT32 k=0; k < bufferSize; k++) {
503 }
505
506
508
509
510
513
514
516 planeMask = 1 << (nPlanes - 1);
517
518 for (int plane = nPlanes - 1; plane >= 0; plane--) {
519
521 sigBits[k] = 0;
522 }
523
524
526
528
529
531
532
535 } else {
536 #ifdef TRACE
537
538
539
540
541
542
543 #endif
544
545
546
547
549
550
554
556 useRL = false;
557 } else {
558
559 useRL = true;
560
562 }
563
564 if (useRL && codeLen <=
MaxCodeLen && codeLen < signLen) {
565
566
567
569
570
572
573
576 } else {
577
578
579
581
582
585
586
590
591 for (UINT32 k=0; k < codeLen; k++) {
593 }
594 }
595
596
597
600
601 for (UINT32 k=0; k < refLen; k++) {
603 }
605 }
606
607
608
612
613 for (UINT32 k=0; k < refLen; k++) {
615 }
617 planeMask >>= 1;
618 }
620}
UINT32 AlignWordPos(UINT32 pos)
void SetBit(UINT32 *stream, UINT32 pos)
void SetValueBlock(UINT32 *stream, UINT32 pos, UINT32 val, UINT32 k)
void ClearBit(UINT32 *stream, UINT32 pos)
UINT32 NumberOfWords(UINT32 pos)
#define CodeBufferBitLen
max number of bits in m_codeBuffer
#define MaxCodeLen
max length of RL encoded block
#define CodeBufferLen
number of words in code buffer (CodeBufferLen > BufferLen)
#define BufferLen
number of words per buffer
#define MaxBitPlanesLog
number of bits to code the maximum number of bit planes (in 32 or 16 bit mode)
#define BufferSize
must be a multiple of WordWidth
#define RLblockSizeLen
block size length (< 16): ld(BufferSize) < RLblockSizeLen <= 2*ld(BufferSize)
#define MaxBitPlanes
maximum number of bit planes of m_value: 32 minus sign bit
UINT8 NumberOfBitplanes()
UINT32 DecomposeBitplane(UINT32 bufferSize, UINT32 planeMask, UINT32 codePos, UINT32 *sigBits, UINT32 *refBits, UINT32 *signBits, UINT32 &signLen, UINT32 &codeLen)
UINT32 RLESigns(UINT32 codePos, UINT32 *signBits, UINT32 signLen)
UINT32 m_codePos
current position in encoded bitstream
bool m_favorSpeed
favor speed over size