Encodes this macro block into internal code buffer. Several macro blocks can be encoded in parallel. Call CEncoder::WriteMacroBlock after this method.
482 {
483 UINT8 nPlanes;
484 UINT32 sigLen, codeLen = 0, wordPos, refLen, signLen;
488 UINT32 planeMask;
490 bool useRL;
491
492#ifdef TRACE
493
494#endif
495
496
497 for (UINT32 k=0; k < bufferSize; k++) {
499 }
501
502
503 for (UINT32 k=0; k < bufferSize; k++) {
505 }
507
508
510
511
512
515
516
518 planeMask = 1 << (nPlanes - 1);
519
520 for (int plane = nPlanes - 1; plane >= 0; plane--) {
521
523 sigBits[k] = 0;
524 }
525
526
528
530
531
533
534
537 } else {
538 #ifdef TRACE
539
540
541
542
543
544
545 #endif
546
547
548
549
551
552
556
558 useRL = false;
559 } else {
560
561 useRL = true;
562
564 }
565
566 if (useRL && codeLen <=
MaxCodeLen && codeLen < signLen) {
567
568
569
571
572
574
575
578 } else {
579
580
581
583
584
587
588
592
593 for (UINT32 k=0; k < codeLen; k++) {
595 }
596 }
597
598
599
602
603 for (UINT32 k=0; k < refLen; k++) {
605 }
607 }
608
609
610
614
615 for (UINT32 k=0; k < refLen; k++) {
617 }
619 planeMask >>= 1;
620 }
622}
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, BufferSize <= UINT16_MAX
#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