diff options
author | Slávek Banko <[email protected]> | 2019-12-11 01:41:26 +0100 |
---|---|---|
committer | Slávek Banko <[email protected]> | 2019-12-11 02:23:35 +0100 |
commit | 73f00336178a9f312bac2992649120d462e0ac2d (patch) | |
tree | 8672519cb50cb0e642af0817188ad28f810338ee /kopete/protocols/msn/webcam/libmimic/vlc_encode.c | |
parent | 914254104c50dec222fb31ce7a25a21870e90f16 (diff) | |
download | tdenetwork-73f00336178a9f312bac2992649120d462e0ac2d.tar.gz tdenetwork-73f00336178a9f312bac2992649120d462e0ac2d.zip |
kopete: Restore the MSN protocol because a replacement MSN server was created.
This reverts commits 0486034738 - 2d5f9c55da and f6fd4ab6c0.
Signed-off-by: Slávek Banko <[email protected]>
Diffstat (limited to 'kopete/protocols/msn/webcam/libmimic/vlc_encode.c')
-rw-r--r-- | kopete/protocols/msn/webcam/libmimic/vlc_encode.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/kopete/protocols/msn/webcam/libmimic/vlc_encode.c b/kopete/protocols/msn/webcam/libmimic/vlc_encode.c new file mode 100644 index 00000000..6aeebe1c --- /dev/null +++ b/kopete/protocols/msn/webcam/libmimic/vlc_encode.c @@ -0,0 +1,84 @@ +/* Copyright (C) 2005 Ole André Vadla Ravnås <[email protected]> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <stdlib.h> +#include "mimic-private.h" + +extern guchar _col_zag[64]; +extern VlcSymbol _vlc_alphabet[16][128]; + +/* + * _vlc_encode_block + * + * Serialize an 8x8 block using variable length coding. + */ +void _vlc_encode_block(MimCtx *ctx, const gint *block, gint num_coeffs) +{ + gint i, num_zeroes; + + /* The DC value is written out as is. */ + _write_bits(ctx, block[0], 8); + + /* Number of zeroes prefixing the next non-zero value. */ + num_zeroes = 0; + + for (i = 1; i < num_coeffs && num_zeroes <= 14; i++) { + + /* Fetch AC coefficients from block in zig-zag order. */ + gint value = block[_col_zag[i]]; + + if (value != 0) { + VlcSymbol sym; + + /* Clip input values to [-128, +128]. */ + if (value < -128) + value = -128; + else if (value > 128) + value = 128; + + /* Look up symbol for the current non-zero value. */ + sym = _vlc_alphabet[num_zeroes][abs(value) - 1]; + + /* No symbol? very rare... */ + if (sym.length1 <= 0) + break; + + /* The symbols for negative values are the same as for positives, minus one. */ + if (value < 0) { + if (sym.length2 > 0) + sym.part2 -= 1; + else + sym.part1 -= 1; + } + + /* Write out the full symbol. */ + _write_bits(ctx, sym.part1, sym.length1); + if (sym.length2 > 0) + _write_bits(ctx, sym.part2, sym.length2); + + /* Start counting zeroes again. */ + num_zeroes = 0; + } else { + num_zeroes++; + } + } + + /* Write out EOB if necessary. */ + if (num_zeroes > 0) + _write_bits(ctx, 0xA, 4); +} + |