Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //yay random variable names
- inline int RLEenc(const char* in, char* out, int l){
- int w=in[0];
- int a=0;
- int j=0;
- for(int i=1;i<l;i++){
- if(i-a>255||w!=in[i]){
- int s=i-a-1;
- out[j++]=s;
- out[j++]=w;
- a=i;
- w=in[i];
- }
- }
- int s=l-a-1;
- out[j++]=s;
- out[j++]=w;
- return j;
- }
- inline int RLEdec(const char* in, char* out, int l){
- int a=0;
- for(int i=0;i<l;i++){
- int t=in[i++]+1;
- for(int j=0;j<t;j++){
- out[a++]=in[i];
- }
- }
- return a;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement