/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 2003-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#include <vclib.h>
/* Move-to-front transformers.
**
** Written by Kiem-Phong Vo (kpv@research.att.com)
*/
{ m = mtf[p = 0]; \
while(m != c) \
mtf[0] = c; \
}
{ c = mtf[m = 0]; \
while(m != p) \
mtf[0] = c; \
}
/* arguments to select move-to-front coder */
};
#if __STD_C
#else
int encoding; /* !=0 if encoding */
#endif
{
predc = 0;
for(p = 0; p < 256; ++p)
/* weight increases slightly but decreases quickly */
#define SUCC(c,p,m,n) \
predc = c; \
MTFC(c,p,m,n); /* predicting succ[c] is next */ \
}
if(encoding)
SUCC(c,p,m,n);
}
}
else
SUCC(c,p,m,n);
}
}
return o-output;
}
/* move to zeroth location */
#if __STD_C
#else
int encoding; /* !=0 if encoding */
#endif
{
reg int c, p, m, n;
for(p = 0; p < 256; ++p)
mtf[p] = p;
if(encoding)
}
}
else
}
}
return o-output;
}
#if __STD_C
#else
#endif
{
return 0;
RETURN(-1);
RETURN(-1);
RETURN(-1);
if(out)
return sz;
}
#if __STD_C
#else
#endif
{
if(size == 0)
return 0;
RETURN(-1);
RETURN(-1);
RETURN(-1);
if(out)
return sz;
}
#if __STD_C
#else
#endif
{
char *ident;
ssize_t n;
break;
return 0;
RETURN(-1);
RETURN(-1);
if(datap)
return n;
}
#if __STD_C
#else
#endif
{
break;
}
}
#if __STD_C
#else
int type;
#endif
{
char *data;
if(type == VC_OPENING )
break;
}
if(!arg) /* get the default argument */
break;
return 0;
}
else if(type == VC_EXTRACT)
RETURN(-1);
RETURN(-1);
return 1;
}
else if(type == VC_RESTORE)
RETURN(-1);
RETURN(-1);
return 1;
}
return 0;
}
{ vcmtf,
"mtf", "Move-to-front transform.",
"[-version?mtf (AT&T Research) 2003-01-01]" USAGE_LICENSE,
1024*1024,
0
};