CSJ2K.j2k.entropy.encoder.MQCoder.byteOut C# (CSharp) Method

byteOut() private method

This function puts one byte of compressed bits in the output stream. The highest 8 bits of c are then put in b to be the next byte to write. This method delays the output of any 0xFF bytes until a non 0xFF byte has to be written to the output bit stream (the 'delFF' variable signals if there is a delayed 0xff byte).
private byteOut ( ) : void
return void
        private void byteOut()
        {
            if (nrOfWrittenBytes >= 0)
            {
                if (b == 0xFF)
                {
                    // Delay 0xFF byte
                    delFF = true;
                    b = SupportClass.URShift(c, 20);
                    c &= 0xFFFFF;
                    cT = 7;
                }
                else if (c < 0x8000000)
                {
                    // Write delayed 0xFF bytes
                    if (delFF)
                    {
                        out_Renamed.write(0xFF);
                        delFF = false;
                        nrOfWrittenBytes++;
                    }
                    out_Renamed.write(b);
                    nrOfWrittenBytes++;
                    b = SupportClass.URShift(c, 19);
                    c &= 0x7FFFF;
                    cT = 8;
                }
                else
                {
                    b++;
                    if (b == 0xFF)
                    {
                        // Delay 0xFF byte
                        delFF = true;
                        c &= 0x7FFFFFF;
                        b = SupportClass.URShift(c, 20);
                        c &= 0xFFFFF;
                        cT = 7;
                    }
                    else
                    {
                        // Write delayed 0xFF bytes
                        if (delFF)
                        {
                            out_Renamed.write(0xFF);
                            delFF = false;
                            nrOfWrittenBytes++;
                        }
                        out_Renamed.write(b);
                        nrOfWrittenBytes++;
                        b = ((SupportClass.URShift(c, 19)) & 0xFF);
                        c &= 0x7FFFF;
                        cT = 8;
                    }
                }
            }
            else
            {
                // NOTE: carry bit can never be set if the byte buffer was empty
                b = (SupportClass.URShift(c, 19));
                c &= 0x7FFFF;
                cT = 8;
                nrOfWrittenBytes++;
            }
        }