stuffer.cpp

来自「QAM module to use in Java with an easy i」· C++ 代码 · 共 58 行

CPP
58
字号
//---------------------------------------------------------------------------


#pragma hdrstop

#include "Stuffer.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

__fastcall Stuffer::Stuffer()
{
        workingsize=0;working=0;numberofonesinarow=0;
        GetNextChar=&DefaultGetNextChar;
}

int __fastcall Stuffer::Update()
{
       int i;
       if(workingsize<8)
       {
                int c=GetNextChar();
                int size=8;
                if(c>=0)
                {
                        int place=1;
                        int tmp2;
                        for(int i=0;i<8;i++)
                        {
                                tmp2=c&place;
                                place=place<<1;
                                if(tmp2>0)numberofonesinarow++;
                                 else numberofonesinarow=0;
                                if(numberofonesinarow==5)
                                {
                                        c=((((c)<<1)&(1024-place))|((c)&(place-1)))&(1023-place);
                                        numberofonesinarow=0;
                                        size++;
                                        place=place<<1;
                                }
                        }
                }
                 else{numberofonesinarow=0;c=126;}
                working=working|(c<<workingsize);
                workingsize+=size;
       }
       i=working&255;
       working=working>>8;
       workingsize-=8;
       return i;
}


int __fastcall Stuffer::DefaultGetNextChar(void)
{
        return -1;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?