Encodes this macro block into internal code buffer. Several macro blocks can be encoded in parallel. Call CEncoder::WriteMacroBlock after this method.
483 {
484 uint8_t nPlanes;
485 uint32_t sigLen, codeLen = 0, wordPos, refLen, signLen;
489 uint32_t planeMask;
491 bool useRL;
492
493#ifdef TRACE
494
495#endif
496
497
498 for (uint32_t k = 0; k < bufferSize; k++) {
500 }
502
503
504 for (uint32_t k = 0; k < bufferSize; k++) {
506 }
508
509
511
512
513
516
517
519 planeMask = 1 << (nPlanes - 1);
520
521 for (int plane = nPlanes - 1; plane >= 0; plane--) {
522
523 for (uint32_t k = 0; k <
BufferLen; k++) {
524 sigBits[k] = 0;
525 }
526
527
529
531
532
534
535
538 } else {
539#ifdef TRACE
540
541
542
543
544
545
546#endif
547
548
549
550
552
553
557
559 useRL = false;
560 } else {
561
562 useRL = true;
563
565 }
566
567 if (useRL && codeLen <=
MaxCodeLen && codeLen < signLen) {
568
569
570
572
573
575
576
579 } else {
580
581
582
584
585
588
589
593
594 for (uint32_t k = 0; k < codeLen; k++) {
596 }
597 }
598
599
600
603
604 for (uint32_t k = 0; k < refLen; k++) {
606 }
608 }
609
610
611
615
616 for (uint32_t k = 0; k < refLen; k++) {
618 }
620 planeMask >>= 1;
621 }
623 }
uint32_t RLESigns(uint32_t codePos, uint32_t *signBits, uint32_t signLen)
uint32_t DecomposeBitplane(uint32_t bufferSize, uint32_t planeMask, uint32_t codePos, uint32_t *sigBits, uint32_t *refBits, uint32_t *signBits, uint32_t &signLen, uint32_t &codeLen)
uint32_t m_codePos
current position in encoded bitstream
uint8_t NumberOfBitplanes()
bool m_favorSpeed
favor speed over size
void ClearBit(uint32_t *stream, uint32_t pos)
constexpr int MaxBitPlanes
maximum number of bit planes of m_value: 32 minus sign bit
constexpr uint32_t CodeBufferBitLen
max number of bits in m_codeBuffer
void SetBit(uint32_t *stream, uint32_t pos)
void SetValueBlock(uint32_t *stream, uint32_t pos, uint32_t val, uint32_t k)
uint32_t AlignWordPos(uint32_t pos)
constexpr int RLblockSizeLen
block size length (< 16): ld(BufferSize) < RLblockSizeLen <= 2*ld(BufferSize)
constexpr uint32_t CodeBufferLen
number of words in code buffer (CodeBufferLen > BufferLen)
constexpr int MaxBitPlanesLog
number of bits to code the maximum number of bit planes (in 32 or 16 bit mode)
constexpr uint32_t MaxCodeLen
max length of RL encoded block
uint32_t NumberOfWords(uint32_t pos)
constexpr uint32_t BufferLen
number of words per buffer
constexpr uint32_t BufferSize
must be a multiple of WordWidth, BufferSize <= UINT16_MAX