/* Compresses data to the result buffer The result size must be at least half of the input buffer. The number of samples also must be even!  */
int l1oip_law_to_4bit(u8 *data, int len, u8 *result, u32 *state)
/* Compresses data to the result buffer The result size must be at least half of the input buffer. The number of samples also must be even!  */
int l1oip_law_to_4bit(u8 *data, int len, u8 *result, u32 *state)
{
	int ii, i = 0, o = 0;
	if (!len)
		return 0;
	if (*state) {
		*result++ = table_com[(((*state)<<8)&0xff00) | (*data++)];
		len--;
		o++;
	}
	ii = len >> 1;
	while (i < ii) {
		*result++ = table_com[(data[0]<<8) | (data[1])];
		data += 2;
		i++;
		o++;
	}
	if (len & 1)
		*state = 0x100 + *data;
	else
		*state = 0;
	return o;
}