summaryrefslogtreecommitdiff
path: root/src/libxinevdec
diff options
context:
space:
mode:
authorMike Melanson <mike@multimedia.cx>2004-03-14 21:27:03 +0000
committerMike Melanson <mike@multimedia.cx>2004-03-14 21:27:03 +0000
commit5ece915e5903946b2aeab11640a19410f62870b9 (patch)
tree5d98979221fc3e26256bae46bc4a11db29a3a003 /src/libxinevdec
parentebab86a8bee668e60d312ebd0536661388ce7dc1 (diff)
downloadxine-lib-5ece915e5903946b2aeab11640a19410f62870b9.tar.gz
xine-lib-5ece915e5903946b2aeab11640a19410f62870b9.tar.bz2
goodbye decoders-- you have served your purpose well and we salute you
CVS patchset: 6256 CVS date: 2004/03/14 21:27:03
Diffstat (limited to 'src/libxinevdec')
-rw-r--r--src/libxinevdec/Makefile.am69
-rw-r--r--src/libxinevdec/cinepak.c566
-rw-r--r--src/libxinevdec/cyuv.c288
-rw-r--r--src/libxinevdec/fli.c602
-rw-r--r--src/libxinevdec/idcinvideo.c408
-rw-r--r--src/libxinevdec/interplayvideo.c1388
-rw-r--r--src/libxinevdec/msrle.c377
-rw-r--r--src/libxinevdec/msvc.c415
-rw-r--r--src/libxinevdec/qtrle.c1040
-rw-r--r--src/libxinevdec/qtrpza.c465
-rw-r--r--src/libxinevdec/qtsmc.c698
-rw-r--r--src/libxinevdec/roqvideo.c578
-rw-r--r--src/libxinevdec/svq1.c1507
-rw-r--r--src/libxinevdec/svq1_codebooks.h1506
-rw-r--r--src/libxinevdec/wc3video.c539
15 files changed, 1 insertions, 10445 deletions
diff --git a/src/libxinevdec/Makefile.am b/src/libxinevdec/Makefile.am
index c114f44d4..b8584f541 100644
--- a/src/libxinevdec/Makefile.am
+++ b/src/libxinevdec/Makefile.am
@@ -10,50 +10,13 @@ libdir = $(XINE_PLUGINDIR)
lib_LTLIBRARIES = $(image_module) \
xineplug_decode_bitplane.la \
- xineplug_decode_cinepak.la \
- xineplug_decode_cyuv.la \
- xineplug_decode_fli.la \
- xineplug_decode_idcinvideo.la \
- xineplug_decode_msrle.la \
- xineplug_decode_msvc.la \
- xineplug_decode_qtsmc.la \
- xineplug_decode_roqvideo.la \
xineplug_decode_rgb.la \
- xineplug_decode_svq1.la \
- xineplug_decode_yuv.la \
- xineplug_decode_qtrpza.la \
- xineplug_decode_wc3video.la \
- xineplug_decode_qtrle.la \
- xineplug_decode_interplayvideo.la
+ xineplug_decode_yuv.la
xineplug_decode_bitplane_la_SOURCES = bitplane.c
xineplug_decode_bitplane_la_LIBADD = $(XINE_LIB)
xineplug_decode_bitplane_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-xineplug_decode_cinepak_la_SOURCES = cinepak.c
-xineplug_decode_cinepak_la_LIBADD = $(XINE_LIB)
-xineplug_decode_cinepak_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-
-xineplug_decode_cyuv_la_SOURCES = cyuv.c
-xineplug_decode_cyuv_la_LIBADD = $(XINE_LIB)
-xineplug_decode_cyuv_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-
-xineplug_decode_msvc_la_SOURCES = msvc.c
-xineplug_decode_msvc_la_LIBADD = $(XINE_LIB)
-xineplug_decode_msvc_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-
-xineplug_decode_roqvideo_la_SOURCES = roqvideo.c
-xineplug_decode_roqvideo_la_LIBADD = $(XINE_LIB)
-xineplug_decode_roqvideo_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-
-xineplug_decode_svq1_la_SOURCES = svq1.c svq1_codebooks.h
-xineplug_decode_svq1_la_LIBADD = $(XINE_LIB)
-xineplug_decode_svq1_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-
-xineplug_decode_fli_la_SOURCES = fli.c
-xineplug_decode_fli_la_LIBADD = $(XINE_LIB)
-xineplug_decode_fli_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-
xineplug_decode_rgb_la_SOURCES = rgb.c
xineplug_decode_rgb_la_LIBADD = $(XINE_LIB)
xineplug_decode_rgb_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
@@ -62,36 +25,6 @@ xineplug_decode_yuv_la_SOURCES = yuv.c
xineplug_decode_yuv_la_LIBADD = $(XINE_LIB)
xineplug_decode_yuv_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-xineplug_decode_msrle_la_SOURCES = msrle.c
-xineplug_decode_msrle_la_LIBADD = $(XINE_LIB)
-xineplug_decode_msrle_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-
-xineplug_decode_idcinvideo_la_SOURCES = idcinvideo.c
-xineplug_decode_idcinvideo_la_LIBADD = $(XINE_LIB)
-xineplug_decode_idcinvideo_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-
-xineplug_decode_qtsmc_la_SOURCES = qtsmc.c
-xineplug_decode_qtsmc_la_LIBADD = $(XINE_LIB)
-xineplug_decode_qtsmc_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-
-xineplug_decode_qtrpza_la_SOURCES = qtrpza.c
-xineplug_decode_qtrpza_la_LIBADD = $(XINE_LIB)
-xineplug_decode_qtrpza_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-
-xineplug_decode_wc3video_la_SOURCES = wc3video.c
-xineplug_decode_wc3video_la_LIBADD = $(XINE_LIB)
-xineplug_decode_wc3video_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-
-xineplug_decode_qtrle_la_SOURCES = qtrle.c
-xineplug_decode_qtrle_la_LIBADD = $(XINE_LIB)
-xineplug_decode_qtrle_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-
-xineplug_decode_interplayvideo_la_SOURCES = interplayvideo.c
-xineplug_decode_interplayvideo_la_LIBADD = $(XINE_LIB)
-xineplug_decode_interplayvideo_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-
xineplug_decode_image_la_SOURCES = image.c
xineplug_decode_image_la_LIBADD = $(XINE_LIB) $(DYNAMIC_LD_LIBS) $(PNG_LIBS)
xineplug_decode_image_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
-
-noinst_HEADERS = svq1_codebooks.h
diff --git a/src/libxinevdec/cinepak.c b/src/libxinevdec/cinepak.c
deleted file mode 100644
index a2fa78cce..000000000
--- a/src/libxinevdec/cinepak.c
+++ /dev/null
@@ -1,566 +0,0 @@
-/*
- * Copyright (C) 2002-2003 the xine project
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * by Ewald Snel <ewald@rambo.its.tudelft.nl>
- *
- * based on overview of Cinepak algorithm and example decoder
- * by Tim Ferguson: http://www.csse.monash.edu.au/~timf/
- *
- * $Id: cinepak.c,v 1.38 2004/02/09 22:04:11 jstembridge Exp $
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "xine_internal.h"
-#include "video_out.h"
-#include "buffer.h"
-#include "bswap.h"
-#include "xineutils.h"
-
-#define MAX_STRIPS 32
-#define VIDEOBUFSIZE 128 * 1024
-
-
-typedef struct {
- uint8_t y0, y1, y2, y3;
- uint8_t u, v;
-} cvid_codebook_t;
-
-typedef struct {
- uint16_t id;
- uint16_t x1, y1;
- uint16_t x2, y2;
- cvid_codebook_t v4_codebook[256];
- cvid_codebook_t v1_codebook[256];
-} cvid_strip_t;
-
-typedef struct {
- video_decoder_class_t decoder_class;
-} cvid_class_t;
-
-typedef struct cvid_decoder_s {
- video_decoder_t video_decoder;
-
- cvid_class_t *class;
-
- xine_stream_t *stream;
- int64_t video_step;
- int decoder_ok;
-
- unsigned char *buf;
- int bufsize;
- int size;
-
- cvid_strip_t strips[MAX_STRIPS];
-
- unsigned int coded_width;
- unsigned int coded_height;
- int luma_pitch;
- int chroma_pitch;
- uint8_t *current;
- int offsets[3];
-
- unsigned int width;
- unsigned int height;
- double ratio;
-} cvid_decoder_t;
-
-static unsigned char yuv_palette[256 * 4];
-static int color_depth;
-
-static void cinepak_decode_codebook (cvid_codebook_t *codebook,
- int chunk_id, int size, uint8_t *data)
-{
- uint8_t *eod = (data + size);
- uint32_t flag, mask;
- int i, n;
-
- n = (chunk_id & 0x0400) ? 4 : 6;
- flag = 0;
- mask = 0;
-
- for (i=0; i < 256; i++) {
- if ((chunk_id & 0x0100) && !(mask >>= 1)) {
- if ((data + 4) > eod)
- break;
-
- flag = BE_32 (data);
- data += 4;
- mask = 0x80000000;
- }
-
- if (!(chunk_id & 0x0100) || (flag & mask)) {
- if ((data + n) > eod)
- break;
-
- if (n == 6) {
- codebook[i].y0 = *data++;
- codebook[i].y1 = *data++;
- codebook[i].y2 = *data++;
- codebook[i].y3 = *data++;
- codebook[i].u = 128 + *data++;
- codebook[i].v = 128 + *data++;
- } else if (color_depth == 8) {
- /* if color depth is 8, this codebook type indicates palette lookup */
- codebook[i].y0 = yuv_palette[*(data + 0) * 4];
- codebook[i].y1 = yuv_palette[*(data + 1) * 4];
- codebook[i].y2 = yuv_palette[*(data + 2) * 4];
- codebook[i].y3 = yuv_palette[*(data + 3) * 4];
- codebook[i].u =
- (yuv_palette[*(data + 0) * 4 + 1] +
- yuv_palette[*(data + 1) * 4 + 1] +
- yuv_palette[*(data + 2) * 4 + 1] +
- yuv_palette[*(data + 3) * 4 + 1]) / 4;
- codebook[i].v =
- (yuv_palette[*(data + 0) * 4 + 2] +
- yuv_palette[*(data + 1) * 4 + 2] +
- yuv_palette[*(data + 2) * 4 + 2] +
- yuv_palette[*(data + 3) * 4 + 2]) / 4;
- data += 4;
- } else {
- /* if color depth is 40, this codebook type indicates greyscale */
- codebook[i].y0 = *data++;
- codebook[i].y1 = *data++;
- codebook[i].y2 = *data++;
- codebook[i].y3 = *data++;
- codebook[i].u = 128;
- codebook[i].v = 128;
- }
- }
- }
-}
-
-static int cinepak_decode_vectors (cvid_decoder_t *this, cvid_strip_t *strip,
- int chunk_id, int size, uint8_t *data)
-{
- uint8_t *eod = (data + size);
- uint32_t flag, mask;
- cvid_codebook_t *codebook;
- unsigned int x, y;
- uint8_t *iy[4];
- uint8_t *iu[2];
- uint8_t *iv[2];
-
- flag = 0;
- mask = 0;
-
- for (y=strip->y1; y < strip->y2; y+=4) {
-
- iy[0] = &this->current[strip->x1 + (y * this->luma_pitch) + this->offsets[0]];
- iy[1] = iy[0] + this->luma_pitch;
- iy[2] = iy[1] + this->luma_pitch;
- iy[3] = iy[2] + this->luma_pitch;
- iu[0] = &this->current[(strip->x1/2) + ((y/2) * this->chroma_pitch) + this->offsets[1]];
- iu[1] = iu[0] + this->chroma_pitch;
- iv[0] = &this->current[(strip->x1/2) + ((y/2) * this->chroma_pitch) + this->offsets[2]];
- iv[1] = iv[0] + this->chroma_pitch;
-
- for (x=strip->x1; x < strip->x2; x+=4) {
- if ((chunk_id & 0x0100) && !(mask >>= 1)) {
- if ((data + 4) > eod)
- return -1;
-
- flag = BE_32 (data);
- data += 4;
- mask = 0x80000000;
- }
-
- if (!(chunk_id & 0x0100) || (flag & mask)) {
- if (!(chunk_id & 0x0200) && !(mask >>= 1)) {
- if ((data + 4) > eod)
- return -1;
-
- flag = BE_32 (data);
- data += 4;
- mask = 0x80000000;
- }
-
- if ((chunk_id & 0x0200) || (~flag & mask)) {
- if (data >= eod)
- return -1;
-
- codebook = &strip->v1_codebook[*data++];
- iy[0][0] = codebook->y0; iy[0][1] = codebook->y0;
- iy[1][0] = codebook->y0; iy[1][1] = codebook->y0;
- iu[0][0] = codebook->u; iv[0][0] = codebook->v;
-
- iy[0][2] = codebook->y1; iy[0][3] = codebook->y1;
- iy[1][2] = codebook->y1; iy[1][3] = codebook->y1;
- iu[0][1] = codebook->u; iv[0][1] = codebook->v;
-
- iy[2][0] = codebook->y2; iy[2][1] = codebook->y2;
- iy[3][0] = codebook->y2; iy[3][1] = codebook->y2;
- iu[1][0] = codebook->u; iv[1][0] = codebook->v;
-
- iy[2][2] = codebook->y3; iy[2][3] = codebook->y3;
- iy[3][2] = codebook->y3; iy[3][3] = codebook->y3;
- iu[1][1] = codebook->u; iv[1][1] = codebook->v;
-
- } else if (flag & mask) {
- if ((data + 4) > eod)
- return -1;
-
- codebook = &strip->v4_codebook[*data++];
- iy[0][0] = codebook->y0; iy[0][1] = codebook->y1;
- iy[1][0] = codebook->y2; iy[1][1] = codebook->y3;
- iu[0][0] = codebook->u; iv[0][0] = codebook->v;
-
- codebook = &strip->v4_codebook[*data++];
- iy[0][2] = codebook->y0; iy[0][3] = codebook->y1;
- iy[1][2] = codebook->y2; iy[1][3] = codebook->y3;
- iu[0][1] = codebook->u; iv[0][1] = codebook->v;
-
- codebook = &strip->v4_codebook[*data++];
- iy[2][0] = codebook->y0; iy[2][1] = codebook->y1;
- iy[3][0] = codebook->y2; iy[3][1] = codebook->y3;
- iu[1][0] = codebook->u; iv[1][0] = codebook->v;
-
- codebook = &strip->v4_codebook[*data++];
- iy[2][2] = codebook->y0; iy[2][3] = codebook->y1;
- iy[3][2] = codebook->y2; iy[3][3] = codebook->y3;
- iu[1][1] = codebook->u; iv[1][1] = codebook->v;
- }
- }
-
- iy[0] += 4; iy[1] += 4;
- iy[2] += 4; iy[3] += 4;
- iu[0] += 2; iu[1] += 2;
- iv[0] += 2; iv[1] += 2;
- }
- }
-
- return 0;
-}
-
-static int cinepak_decode_strip (cvid_decoder_t *this,
- cvid_strip_t *strip, uint8_t *data, int size)
-{
- uint8_t *eod = (data + size);
- int chunk_id, chunk_size;
-
- if (strip->x1 >= this->coded_width || strip->x2 > this->coded_width ||
- strip->y1 >= this->coded_height || strip->y2 > this->coded_height ||
- strip->x1 >= strip->x2 || strip->y1 >= strip->y2)
- return -1;
-
- while ((data + 4) <= eod) {
- chunk_id = BE_16 (&data[0]);
- chunk_size = BE_16 (&data[2]) - 4;
- data += 4;
- chunk_size = ((data + chunk_size) > eod) ? (eod - data) : chunk_size;
-
- switch (chunk_id) {
- case 0x2000:
- case 0x2100:
- case 0x2400:
- case 0x2500:
- cinepak_decode_codebook (strip->v4_codebook, chunk_id, chunk_size, data);
- break;
- case 0x2200:
- case 0x2300:
- case 0x2600:
- case 0x2700:
- cinepak_decode_codebook (strip->v1_codebook, chunk_id, chunk_size, data);
- break;
- case 0x3000:
- case 0x3100:
- case 0x3200:
- return cinepak_decode_vectors (this, strip, chunk_id, chunk_size, data);
- }
-
- data += chunk_size;
- }
-
- return -1;
-}
-
-static int cinepak_decode_frame (cvid_decoder_t *this, uint8_t *data, int size) {
- uint8_t *eod = (data + size);
- int i, result, strip_size, frame_flags, num_strips;
- int y0 = 0;
-
- if (size < 10)
- return -1;
-
- frame_flags = data[0];
- num_strips = BE_16 (&data[8]);
- data += 10;
-
- if (num_strips > MAX_STRIPS)
- num_strips = MAX_STRIPS;
-
- for (i=0; i < num_strips; i++) {
- if ((data + 12) > eod)
- return -1;
-
- this->strips[i].id = BE_16 (data);
- this->strips[i].y1 = y0;
- this->strips[i].x1 = 0;
- this->strips[i].y2 = y0 + BE_16 (&data[8]);
- this->strips[i].x2 = this->coded_width;
-
- strip_size = BE_16 (&data[2]) - 12;
- data += 12;
- strip_size = ((data + strip_size) > eod) ? (eod - data) : strip_size;
-
- if ((i > 0) && !(frame_flags & 0x01)) {
- xine_fast_memcpy (this->strips[i].v4_codebook, this->strips[i-1].v4_codebook,
- sizeof(this->strips[i].v4_codebook));
-
- xine_fast_memcpy (this->strips[i].v1_codebook, this->strips[i-1].v1_codebook,
- sizeof(this->strips[i].v1_codebook));
- }
-
- result = cinepak_decode_strip (this, &this->strips[i], data, strip_size);
-
- if (result != 0)
- return result;
-
- data += strip_size;
- y0 = this->strips[i].y2;
- }
-
- return 0;
-}
-
-static void cinepak_copy_frame (cvid_decoder_t *this, uint8_t *base[3], int pitches[3]) {
- int i, j;
- uint8_t *src, *dst;
-
- src = &this->current[this->offsets[0]];
- dst = base[0];
-
- for (i=0; i < this->height; ++i) {
- memcpy (dst, src, this->width);
- src += this->luma_pitch;
- dst += pitches[0];
- }
-
- for (i=1; i < 3; i++) {
- src = &this->current[this->offsets[i]];
- dst = base[i];
-
- for (j=0; j < (this->height / 2); ++j) {
- memcpy (dst, src, (this->width / 2));
- src += this->chroma_pitch;
- dst += pitches[i];
- }
- }
-}
-
-static void cvid_decode_data (video_decoder_t *this_gen, buf_element_t *buf) {
- cvid_decoder_t *this = (cvid_decoder_t *) this_gen;
-
- palette_entry_t *palette;
- int i;
-
- if (buf->decoder_flags & BUF_FLAG_PREVIEW)
- return;
-
- /* convert the RGB palette to a YUV palette */
- if ((buf->decoder_flags & BUF_FLAG_SPECIAL) &&
- (buf->decoder_info[1] == BUF_SPECIAL_PALETTE)) {
- palette = (palette_entry_t *)buf->decoder_info_ptr[2];
- for (i = 0; i < buf->decoder_info[2]; i++) {
- yuv_palette[i * 4 + 0] =
- COMPUTE_Y(palette[i].r, palette[i].g, palette[i].b);
- yuv_palette[i * 4 + 1] =
- COMPUTE_U(palette[i].r, palette[i].g, palette[i].b);
- yuv_palette[i * 4 + 2] =
- COMPUTE_V(palette[i].r, palette[i].g, palette[i].b);
- }
- }
-
- if (buf->decoder_flags & BUF_FLAG_FRAMERATE) {
- this->video_step = buf->decoder_info[0];
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION, this->video_step);
- }
-
- if (buf->decoder_flags & BUF_FLAG_STDHEADER) {
- xine_bmiheader *bih;
- int chroma_size;
-
- bih = (xine_bmiheader *) buf->content;
-
- this->width = (bih->biWidth + 1) & ~0x1;
- this->height = (bih->biHeight + 1) & ~0x1;
- this->ratio = (double)this->width/(double)this->height;
- this->coded_width = (this->width + 3) & ~0x3;
- this->coded_height = (this->height + 3) & ~0x3;
- this->luma_pitch = this->coded_width;
- this->chroma_pitch = this->coded_width / 2;
-
- chroma_size = (this->chroma_pitch * (this->coded_height / 2));
- this->current = (uint8_t *) realloc (this->current, 6*chroma_size);
- this->offsets[0] = 0;
- this->offsets[1] = 4*chroma_size;
- this->offsets[2] = 5*chroma_size;
-
- if (this->buf)
- free (this->buf);
- this->bufsize = VIDEOBUFSIZE;
- this->buf = malloc(this->bufsize);
- this->size = 0;
-
- color_depth = bih->biBitCount;
-
- this->stream->video_out->open (this->stream->video_out, this->stream);
- this->decoder_ok = 1;
-
- /* stream/meta info */
- _x_meta_info_set(this->stream, XINE_META_INFO_VIDEOCODEC, "Cinepak");
-
- } else if (this->decoder_ok) {
-
- if (this->size + buf->size > this->bufsize) {
- this->bufsize = this->size + 2 * buf->size;
- this->buf = realloc (this->buf, this->bufsize);
- }
-
- xine_fast_memcpy (&this->buf[this->size], buf->content, buf->size);
-
- this->size += buf->size;
-
- if (buf->decoder_flags & BUF_FLAG_FRAME_END) {
-
- vo_frame_t *img;
- int result;
-
- result = cinepak_decode_frame (this, this->buf, this->size);
-
- img = this->stream->video_out->get_frame (this->stream->video_out,
- this->width, this->height,
- this->ratio,
- XINE_IMGFMT_YV12, VO_BOTH_FIELDS);
-
- img->duration = this->video_step;
- img->pts = buf->pts;
- img->bad_frame = (result != 0);
-
- if (result == 0) {
- cinepak_copy_frame (this, img->base, img->pitches);
- }
-
- img->draw(img, this->stream);
- img->free(img);
-
- this->size = 0;
- }
- }
-}
-
-static void cvid_flush (video_decoder_t *this_gen) {
-}
-
-static void cvid_reset (video_decoder_t *this_gen) {
- cvid_decoder_t *this = (cvid_decoder_t *) this_gen;
-
- this->size = 0;
-}
-
-static void cvid_discontinuity (video_decoder_t *this_gen) {
-}
-
-static void cvid_dispose (video_decoder_t *this_gen) {
- cvid_decoder_t *this = (cvid_decoder_t *) this_gen;
-
- if (this->current) {
- free (this->current);
- }
-
- if (this->buf) {
- free (this->buf);
- }
-
- if (this->decoder_ok) {
- this->decoder_ok = 0;
- this->stream->video_out->close(this->stream->video_out, this->stream);
- }
-
- free (this_gen);
-}
-
-static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stream_t *stream) {
-
- cvid_decoder_t *this ;
-
- this = (cvid_decoder_t *) xine_xmalloc (sizeof (cvid_decoder_t));
-
- this->video_decoder.decode_data = cvid_decode_data;
- this->video_decoder.flush = cvid_flush;
- this->video_decoder.reset = cvid_reset;
- this->video_decoder.discontinuity = cvid_discontinuity;
- this->video_decoder.dispose = cvid_dispose;
- this->size = 0;
-
- this->stream = stream;
- this->class = (cvid_class_t *) class_gen;
-
- this->decoder_ok = 0;
- this->buf = NULL;
-
- return &this->video_decoder;
-}
-
-static char *get_identifier (video_decoder_class_t *this) {
- return "Cinepak";
-}
-
-static char *get_description (video_decoder_class_t *this) {
- return "Cinepak (CVID) video decoder plugin";
-}
-
-static void dispose_class (video_decoder_class_t *this) {
- free (this);
-}
-
-static void *init_plugin (xine_t *xine, void *data) {
-
- cvid_class_t *this;
-
- this = (cvid_class_t *) xine_xmalloc (sizeof (cvid_class_t));
-
- this->decoder_class.open_plugin = open_plugin;
- this->decoder_class.get_identifier = get_identifier;
- this->decoder_class.get_description = get_description;
- this->decoder_class.dispose = dispose_class;
-
- return this;
-}
-
-/*
- * exported plugin catalog entry
- */
-
-static uint32_t video_types[] = {
- BUF_VIDEO_CINEPAK,
- 0
- };
-
-static decoder_info_t dec_info_video = {
- video_types, /* supported types */
- 5 /* priority */
-};
-
-plugin_info_t xine_plugin_info[] = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_VIDEO_DECODER, 18, "cinepak", XINE_VERSION_CODE, &dec_info_video, init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
diff --git a/src/libxinevdec/cyuv.c b/src/libxinevdec/cyuv.c
deleted file mode 100644
index b8393bc97..000000000
--- a/src/libxinevdec/cyuv.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Copyright (C) 2000-2003 the xine project
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * $Id: cyuv.c,v 1.26 2004/02/09 22:04:11 jstembridge Exp $
- */
-
-/* And this is the header that came with the CYUV decoder: */
-/* ------------------------------------------------------------------------
- * Creative YUV Video Decoder
- *
- * Dr. Tim Ferguson, 2001.
- * For more details on the algorithm:
- * http://www.csse.monash.edu.au/~timf/videocodec.html
- *
- * This is a very simple predictive coder. A video frame is coded in YUV411
- * format. The first pixel of each scanline is coded using the upper four
- * bits of its absolute value. Subsequent pixels for the scanline are coded
- * using the difference between the last pixel and the current pixel (DPCM).
- * The DPCM values are coded using a 16 entry table found at the start of the
- * frame. Thus four bits per component are used and are as follows:
- * UY VY YY UY VY YY UY VY...
- * This code assumes the frame width will be a multiple of four pixels. This
- * should probably be fixed.
- *
- * You may freely use this source code. I only ask that you reference its
- * source in your projects documentation:
- * Tim Ferguson: http://www.csse.monash.edu.au/~timf/
- * ------------------------------------------------------------------------ */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "xine_internal.h"
-#include "video_out.h"
-#include "buffer.h"
-#include "xineutils.h"
-
-#define VIDEOBUFSIZE 128*1024
-
-typedef struct {
- video_decoder_class_t decoder_class;
-} cyuv_class_t;
-
-typedef struct cyuv_decoder_s {
- video_decoder_t video_decoder;
-
- xine_stream_t *stream;
- cyuv_class_t *class;
-
- int video_step;
- int skipframes;
- unsigned char *buf;
- int bufsize;
- int size;
- int width;
- int height;
- double ratio;
-} cyuv_decoder_t;
-
-/* ------------------------------------------------------------------------
- * This function decodes a buffer containing a CYUV encoded frame.
- *
- * buf - the input buffer to be decoded
- * size - the size of the input buffer
- * frame - the output frame buffer (YUY2 format)
- * width - the width of the output frame
- * height - the height of the output frame
- * bit_per_pixel - ignored for now: may be used later for conversions.
- */
-static void cyuv_decode(unsigned char *buf, int size, unsigned char *frame,
- int width, int height, int bit_per_pixel) {
-
- int i, xpos, ypos, cur_Y = 0, cur_U = 0, cur_V = 0;
- char *delta_y_tbl, *delta_c_tbl, *ptr;
-
- delta_y_tbl = buf + 16;
- delta_c_tbl = buf + 32;
- ptr = buf + (16 * 3);
-
- for(ypos = 0; ypos < height; ypos++) {
- for(xpos = 0; xpos < width; xpos += 4) {
- /* first pixels in scanline */
- if(xpos == 0) {
- cur_U = *(ptr++);
- cur_Y = (cur_U & 0x0f) << 4;
- cur_U = cur_U & 0xf0;
- *frame++ = cur_Y;
- *frame++ = cur_U;
-
- cur_V = *(ptr++);
- cur_Y = (cur_Y + delta_y_tbl[cur_V & 0x0f]) & 0xff;
- cur_V = cur_V & 0xf0;
- *frame++ = cur_Y;
- *frame++ = cur_V;
- }
- /* subsequent pixels in scanline */
- else {
- i = *(ptr++);
- cur_U = (cur_U + delta_c_tbl[i >> 4]) & 0xff;
- cur_Y = (cur_Y + delta_y_tbl[i & 0x0f]) & 0xff;
- *frame++ = cur_Y;
- *frame++ = cur_U;
-
- i = *(ptr++);
- cur_V = (cur_V + delta_c_tbl[i >> 4]) & 0xff;
- cur_Y = (cur_Y + delta_y_tbl[i & 0x0f]) & 0xff;
- *frame++ = cur_Y;
- *frame++ = cur_V;
- }
-
- i = *(ptr++);
- cur_Y = (cur_Y + delta_y_tbl[i & 0x0f]) & 0xff;
- *frame++ = cur_Y;
- *frame++ = cur_U;
-
- cur_Y = (cur_Y + delta_y_tbl[i >> 4]) & 0xff;
- *frame++ = cur_Y;
- *frame++ = cur_V;
- }
- }
-}
-
-static void cyuv_decode_data (video_decoder_t *this_gen,
- buf_element_t *buf) {
-
- cyuv_decoder_t *this = (cyuv_decoder_t *) this_gen;
- vo_frame_t *img; /* video out frame */
-
- if (buf->decoder_flags & (BUF_FLAG_PREVIEW | BUF_FLAG_SPECIAL))
- return;
-
- if (buf->decoder_flags & BUF_FLAG_STDHEADER) { /* need to initialize */
- this->stream->video_out->open (this->stream->video_out, this->stream);
-
- if(this->buf)
- free(this->buf);
-
- this->buf = malloc(VIDEOBUFSIZE);
- this->bufsize = VIDEOBUFSIZE;
- this->size = 0;
- this->width = *(unsigned int *)&buf->content[4];
- this->height = *(unsigned int *)&buf->content[8];
- this->ratio = (double)this->width/(double)this->height;
- this->skipframes = 0;
-
- _x_meta_info_set(this->stream, XINE_META_INFO_VIDEOCODEC, "Creative YUV");
-
- return;
- }
-
- if( this->size + buf->size > this->bufsize ) {
- this->bufsize = this->size + 2 * buf->size;
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "CYUV: increasing source buffer to %d to avoid overflow.\n", this->bufsize);
- this->buf = realloc( this->buf, this->bufsize );
- }
-
- xine_fast_memcpy (&this->buf[this->size], buf->content, buf->size);
- this->size += buf->size;
-
- if (buf->decoder_flags & BUF_FLAG_FRAMERATE) {
- this->video_step = buf->decoder_info[0];
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION, this->video_step);
- }
-
- if (buf->decoder_flags & BUF_FLAG_FRAME_END) { /* time to decode a frame */
- img = this->stream->video_out->get_frame (this->stream->video_out,
- this->width, this->height, this->ratio, XINE_IMGFMT_YUY2,
- VO_BOTH_FIELDS);
-
- img->pts = buf->pts;
- img->duration = this->video_step;
-
- cyuv_decode(this->buf, this->size, img->base[0],
- this->width, this->height, 0);
-
- this->skipframes = img->draw(img, this->stream);
- if( this->skipframes < 0 )
- this->skipframes = 0;
- img->free(img);
-
- this->size = 0;
- }
-}
-
-static void cyuv_flush (video_decoder_t *this_gen) {
-}
-
-static void cyuv_reset (video_decoder_t *this_gen) {
-}
-
-static void cyuv_discontinuity (video_decoder_t *this_gen) {
-}
-
-static void cyuv_dispose (video_decoder_t *this_gen) {
-
- cyuv_decoder_t *this = (cyuv_decoder_t *) this_gen;
-
- this->stream->video_out->close(this->stream->video_out, this->stream);
-
- free (this_gen);
-}
-
-static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stream_t *stream) {
-
- cyuv_decoder_t *this ;
-
- this = (cyuv_decoder_t *) xine_xmalloc (sizeof (cyuv_decoder_t));
-
- this->video_decoder.decode_data = cyuv_decode_data;
- this->video_decoder.flush = cyuv_flush;
- this->video_decoder.reset = cyuv_reset;
- this->video_decoder.discontinuity = cyuv_discontinuity;
- this->video_decoder.dispose = cyuv_dispose;
- this->size = 0;
-
- this->stream = stream;
- this->class = (cyuv_class_t *) class_gen;
-
- this->buf = NULL;
-
- return &this->video_decoder;
-}
-
-static char *get_identifier (video_decoder_class_t *this) {
- return "CYUV";
-}
-
-static char *get_description (video_decoder_class_t *this) {
- return "Creative YUV (CYUV) video decoder plugin";
-}
-
-static void dispose_class (video_decoder_class_t *this) {
- free (this);
-}
-
-static void *init_plugin (xine_t *xine, void *data) {
-
- cyuv_class_t *this;
-
- this = (cyuv_class_t *) xine_xmalloc (sizeof (cyuv_class_t));
-
- this->decoder_class.open_plugin = open_plugin;
- this->decoder_class.get_identifier = get_identifier;
- this->decoder_class.get_description = get_description;
- this->decoder_class.dispose = dispose_class;
-
- return this;
-}
-
-/*
- * exported plugin catalog entry
- */
-
-static uint32_t video_types[] = {
- BUF_VIDEO_CYUV,
- 0
- };
-
-static decoder_info_t dec_info_video = {
- video_types, /* supported types */
- 1 /* priority */
-};
-
-plugin_info_t xine_plugin_info[] = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_VIDEO_DECODER, 18, "cyuv", XINE_VERSION_CODE, &dec_info_video, init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
diff --git a/src/libxinevdec/fli.c b/src/libxinevdec/fli.c
deleted file mode 100644
index 1baa1f6a5..000000000
--- a/src/libxinevdec/fli.c
+++ /dev/null
@@ -1,602 +0,0 @@
-/*
- * Copyright (C) 2000-2003 the xine project
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * FLI Video Decoder by Mike Melanson (melanson@pcisys.net) and
- * Roberto Togni <rtogni@bresciaonline.it>
- * For more information on the FLI format, as well as various traps to
- * avoid when implementing a FLI decoder, visit:
- * http://www.pcisys.net/~melanson/codecs/
- *
- * $Id: fli.c,v 1.27 2004/02/09 22:04:11 jstembridge Exp $
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "xine_internal.h"
-#include "video_out.h"
-#include "buffer.h"
-#include "xineutils.h"
-#include "bswap.h"
-
-#define VIDEOBUFSIZE 128*1024
-
-#define PALETTE_SIZE (256 * 4)
-
-#define FLI_256_COLOR 4
-#define FLI_DELTA 7
-#define FLI_COLOR 11
-#define FLI_LC 12
-#define FLI_BLACK 13
-#define FLI_BRUN 15
-#define FLI_COPY 16
-#define FLI_MINI 18
-
-/**************************************************************************
- * fli specific decode functions
- *************************************************************************/
-
-typedef struct {
- video_decoder_class_t decoder_class;
-} fli_class_t;
-
-typedef struct fli_decoder_s {
- video_decoder_t video_decoder; /* parent video decoder structure */
-
- fli_class_t *class;
- xine_stream_t *stream;
-
- /* these are traditional variables in a video decoder object */
- uint64_t video_step; /* frame duration in pts units */
- int decoder_ok; /* current decoder status */
- int skipframes;
-
- unsigned char *buf; /* the accumulated buffer data */
- int bufsize; /* the maximum size of buf */
- int size; /* the current size of buf */
-
- int width; /* the width of a video frame */
- int height; /* the height of a video frame */
- double ratio; /* the width to height ratio */
-
- /* FLI decoding parameters */
- unsigned char yuv_palette[PALETTE_SIZE];
- yuv_planes_t yuv_planes;
- unsigned char *ghost_image;
- int magic_number; /* FLI file magic number, e.g., 0xAF11 */
-
-} fli_decoder_t;
-
-static void decode_fli_frame(fli_decoder_t *this) {
- int stream_ptr = 0;
- int stream_ptr_after_color_chunk;
- int pixel_ptr;
- int palette_ptr1;
- int palette_ptr2;
- unsigned char palette_idx1;
- unsigned char palette_idx2;
-
- unsigned int frame_size;
- int num_chunks;
-
- unsigned int chunk_size;
- int chunk_type;
-
- int i, j;
-
- int color_packets;
- int color_changes;
- int color_shift;
- unsigned char r, g, b;
-
- int lines, x;
- int compressed_lines;
- int starting_line;
- signed short line_packets;
- int y_ptr;
- signed char byte_run;
- int pixel_skip;
- int update_whole_frame = 0; /* palette change flag */
- int ghost_pixel_ptr;
- int ghost_y_ptr;
- int pixel_countdown;
-
- frame_size = LE_32(&this->buf[stream_ptr]);
- stream_ptr += 6; /* skip the magic number */
- num_chunks = LE_16(&this->buf[stream_ptr]);
- stream_ptr += 10; /* skip padding */
-
- /* iterate through the chunks */
- frame_size -= 16;
- while ((frame_size > 0) && (num_chunks > 0)) {
- chunk_size = LE_32(&this->buf[stream_ptr]);
- stream_ptr += 4;
- chunk_type = LE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
-
- switch (chunk_type) {
- case FLI_256_COLOR:
- case FLI_COLOR:
- stream_ptr_after_color_chunk = stream_ptr + chunk_size - 6;
- /* check special case: if this has the internal magic number of
- * 0xAF13, this file is from the Magic Carpet game and uses 6-bit
- * colors even though it reports 256-color chunks in a 0xAF12-type
- * file */
- if ((chunk_type == FLI_256_COLOR) && (this->magic_number != 0xAF13))
- color_shift = 0;
- else
- color_shift = 2;
- /* set up the palette */
- color_packets = LE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
- palette_ptr1 = 0;
- for (i = 0; i < color_packets; i++) {
- /* first byte is how many colors to skip */
- palette_ptr1 += (this->buf[stream_ptr++] * 4);
-
- /* next byte indicates how many entries to change */
- color_changes = this->buf[stream_ptr++];
-
- /* if there are 0 color changes, there are actually 256 */
- if (color_changes == 0)
- color_changes = 256;
-
- for (j = 0; j < color_changes; j++) {
-
- /* wrap around, for good measure */
- if (palette_ptr1 >= PALETTE_SIZE)
- palette_ptr1 = 0;
-
- r = this->buf[stream_ptr + 0] << color_shift;
- g = this->buf[stream_ptr + 1] << color_shift;
- b = this->buf[stream_ptr + 2] << color_shift;
-
- this->yuv_palette[palette_ptr1++] = COMPUTE_Y(r, g, b);
- this->yuv_palette[palette_ptr1++] = COMPUTE_U(r, g, b);
- this->yuv_palette[palette_ptr1++] = COMPUTE_V(r, g, b);
-
- palette_ptr1++;
- stream_ptr += 3;
- }
- }
-
- /* color chunks sometimes have weird 16-bit alignment issues;
- * therefore, take the hardline approach and set the stream_ptr
- * to the value calculate w.r.t. the size specified by the color
- * chunk header */
- stream_ptr = stream_ptr_after_color_chunk;
-
- /* palette has changed, must update frame */
- update_whole_frame = 1;
- break;
-
- case FLI_DELTA:
- y_ptr = ghost_y_ptr = 0;
- compressed_lines = LE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
- while (compressed_lines > 0) {
- line_packets = LE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
- if (line_packets < 0) {
- line_packets = -line_packets;
- y_ptr += (line_packets * this->yuv_planes.row_width);
- ghost_y_ptr += (line_packets * this->width);
- } else {
- pixel_ptr = y_ptr;
- ghost_pixel_ptr = ghost_y_ptr;
- for (i = 0; i < line_packets; i++) {
- /* account for the skip bytes */
- pixel_skip = this->buf[stream_ptr++];
- pixel_ptr += pixel_skip;
- ghost_pixel_ptr += pixel_skip;
- byte_run = this->buf[stream_ptr++];
- if (byte_run < 0) {
- byte_run = -byte_run;
- palette_ptr1 = (palette_idx1 = this->buf[stream_ptr++]) * 4;
- palette_ptr2 = (palette_idx2 = this->buf[stream_ptr++]) * 4;
- for (j = 0; j < byte_run; j++) {
- this->ghost_image[ghost_pixel_ptr++] = palette_idx1;
- this->yuv_planes.y[pixel_ptr] =
- this->yuv_palette[palette_ptr1 + 0];
- this->yuv_planes.u[pixel_ptr] =
- this->yuv_palette[palette_ptr1 + 1];
- this->yuv_planes.v[pixel_ptr] =
- this->yuv_palette[palette_ptr1 + 2];
- pixel_ptr++;
-
- this->ghost_image[ghost_pixel_ptr++] = palette_idx2;
- this->yuv_planes.y[pixel_ptr] =
- this->yuv_palette[palette_ptr2 + 0];
- this->yuv_planes.u[pixel_ptr] =
- this->yuv_palette[palette_ptr2 + 1];
- this->yuv_planes.v[pixel_ptr] =
- this->yuv_palette[palette_ptr2 + 2];
- pixel_ptr++;
- }
- } else {
- for (j = 0; j < byte_run * 2; j++) {
- palette_ptr1 = (palette_idx1 = this->buf[stream_ptr++]) * 4;
- this->ghost_image[ghost_pixel_ptr++] = palette_idx1;
- this->yuv_planes.y[pixel_ptr] =
- this->yuv_palette[palette_ptr1 + 0];
- this->yuv_planes.u[pixel_ptr] =
- this->yuv_palette[palette_ptr1 + 1];
- this->yuv_planes.v[pixel_ptr] =
- this->yuv_palette[palette_ptr1 + 2];
- pixel_ptr++;
- }
- }
- }
-
- y_ptr += this->yuv_planes.row_width;
- ghost_y_ptr += this->width;
- compressed_lines--;
- }
- }
- break;
-
- case FLI_LC:
- /* line compressed */
- starting_line = LE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
- y_ptr = starting_line * this->yuv_planes.row_width;
- ghost_y_ptr = starting_line * this->width;
-
- compressed_lines = LE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
- while (compressed_lines > 0) {
- pixel_ptr = y_ptr;
- ghost_pixel_ptr = ghost_y_ptr;
- line_packets = this->buf[stream_ptr++];
- if (line_packets > 0) {
- for (i = 0; i < line_packets; i++) {
- /* account for the skip bytes */
- pixel_skip = this->buf[stream_ptr++];
- pixel_ptr += pixel_skip;
- ghost_pixel_ptr += pixel_skip;
- byte_run = this->buf[stream_ptr++];
- if (byte_run > 0) {
- for (j = 0; j < byte_run; j++) {
- palette_ptr1 = (palette_idx1 = this->buf[stream_ptr++]) * 4;
- this->ghost_image[ghost_pixel_ptr++] = palette_idx1;
- this->yuv_planes.y[pixel_ptr] =
- this->yuv_palette[palette_ptr1 + 0];
- this->yuv_planes.u[pixel_ptr] =
- this->yuv_palette[palette_ptr1 + 1];
- this->yuv_planes.v[pixel_ptr] =
- this->yuv_palette[palette_ptr1 + 2];
- pixel_ptr++;
- }
- } else {
- byte_run = -byte_run;
- palette_ptr1 = (palette_idx1 = this->buf[stream_ptr++]) * 4;
- for (j = 0; j < byte_run; j++) {
- this->ghost_image[ghost_pixel_ptr++] = palette_idx1;
- this->yuv_planes.y[pixel_ptr] =
- this->yuv_palette[palette_ptr1 + 0];
- this->yuv_planes.u[pixel_ptr] =
- this->yuv_palette[palette_ptr1 + 1];
- this->yuv_planes.v[pixel_ptr] =
- this->yuv_palette[palette_ptr1 + 2];
- pixel_ptr++;
- }
- }
- }
- }
-
- y_ptr += this->yuv_planes.row_width;
- ghost_y_ptr += this->width;
- compressed_lines--;
- }
- break;
-
- case FLI_BLACK:
- /* set the whole frame to color 0 (which is usually black) by
- * clearing the ghost image and trigger a full frame update */
- memset(this->ghost_image, 0,
- this->width * this->height * sizeof(unsigned char));
- update_whole_frame = 1;
- break;
-
- case FLI_BRUN:
- /* Byte run compression: This chunk type only occurs in the first
- * FLI frame and it will update the entire frame. Take a lazy
- * approach and update only the ghost image. Then let the ghost
- * image updater at the end of the decoder handle the rest. */
- update_whole_frame = 1;
- ghost_y_ptr = 0;
- for (lines = 0; lines < this->height; lines++) {
- ghost_pixel_ptr = ghost_y_ptr;
- /* disregard the line packets; instead, iterate through all
- * pixels on a row */
- stream_ptr++;
- pixel_countdown = this->width;
- while (pixel_countdown > 0) {
- byte_run = this->buf[stream_ptr++];
- if (byte_run > 0) {
- palette_ptr1 = (palette_idx1 = this->buf[stream_ptr++]) * 4;
- for (j = 0; j < byte_run; j++) {
- this->ghost_image[ghost_pixel_ptr++] = palette_idx1;
- pixel_countdown--;
- if (pixel_countdown < 0)
- xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
- "fli warning: pixel_countdown < 0 (%d)\n", pixel_countdown);
- }
- } else { /* copy bytes if byte_run < 0 */
- byte_run = -byte_run;
- for (j = 0; j < byte_run; j++) {
- palette_ptr1 = (palette_idx1 = this->buf[stream_ptr++]) * 4;
- this->ghost_image[ghost_pixel_ptr++] = palette_idx1;
- pixel_countdown--;
- if (pixel_countdown < 0)
- xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
- "fli warning: pixel_countdown < 0 (%d)\n", pixel_countdown);
- }
- }
- }
-
- ghost_y_ptr += this->width;
- }
- break;
-
- case FLI_COPY:
- /* copy the chunk (uncompressed frame) to the ghost image and
- * schedule the whole frame to be updated */
- if (chunk_size - 6 > this->width * this->height) {
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "FLI: in chunk FLI_COPY : source data (%d bytes) bigger than image, skipping chunk\n",
- chunk_size - 6);
- break;
- } else
- memcpy(this->ghost_image, &this->buf[stream_ptr], chunk_size - 6);
- stream_ptr += chunk_size - 6;
- update_whole_frame = 1;
- break;
-
- case FLI_MINI:
- /* some sort of a thumbnail? disregard this chunk... */
- stream_ptr += chunk_size - 6;
- break;
-
- default:
- xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
- "FLI: Unrecognized chunk type: %d\n", chunk_type);
- break;
- }
-
- frame_size -= chunk_size;
- num_chunks--;
- }
-
- if (update_whole_frame) {
-
- pixel_ptr = ghost_pixel_ptr = 0;
- for (lines = 0; lines < this->height; lines++) {
- for (x = 0; x < this->width; x++) {
- palette_ptr1 = this->ghost_image[ghost_pixel_ptr++] * 4;
- this->yuv_planes.y[pixel_ptr] = this->yuv_palette[palette_ptr1 + 0];
- this->yuv_planes.u[pixel_ptr] = this->yuv_palette[palette_ptr1 + 1];
- this->yuv_planes.v[pixel_ptr] = this->yuv_palette[palette_ptr1 + 2];
- pixel_ptr++;
- }
- }
- }
-
- /* by the end of the chunk, the stream ptr should equal the frame
- * size (minus 1, possibly); if it doesn't, issue a warning */
- if ((stream_ptr != this->size) && (stream_ptr != this->size - 1))
- xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
- "warning: processed FLI chunk where chunk size = %d\nand final chunk ptr = %d\n",
- this->size, stream_ptr);
-}
-
-/**************************************************************************
- * xine video plugin functions
- *************************************************************************/
-
-/*
- * This function receives a buffer of data from the demuxer layer and
- * figures out how to handle it based on its header flags.
- */
-static void fli_decode_data (video_decoder_t *this_gen,
- buf_element_t *buf) {
-
- fli_decoder_t *this = (fli_decoder_t *) this_gen;
- vo_frame_t *img; /* video out frame */
-
- /* a video decoder does not care about this flag (?) */
- if (buf->decoder_flags & BUF_FLAG_PREVIEW)
- return;
-
- if (buf->decoder_flags & BUF_FLAG_FRAMERATE)
- this->video_step = buf->decoder_info[0];
-
- if (buf->decoder_flags & BUF_FLAG_HEADER) { /* need to initialize */
- this->stream->video_out->open (this->stream->video_out, this->stream);
-
- if(this->buf)
- free(this->buf);
-
- /* RGB -> YUV converter requires even width */
- this->width = (LE_16(&buf->content[8]) + 1) & ~0x1;
- this->height = LE_16(&buf->content[10]);
- this->ratio = (double)this->width/(double)this->height;
- this->magic_number = LE_16(&buf->content[4]);
-
- this->ghost_image = xine_xmalloc(this->width * this->height);
- init_yuv_planes(&this->yuv_planes, this->width, this->height);
-
- if (this->buf)
- free (this->buf);
- this->bufsize = VIDEOBUFSIZE;
- this->buf = malloc(this->bufsize);
- this->size = 0;
-
- this->stream->video_out->open (this->stream->video_out, this->stream);
- this->decoder_ok = 1;
-
- /* load the stream/meta info */
- _x_meta_info_set(this->stream, XINE_META_INFO_VIDEOCODEC, "FLI/FLC Video");
-
- return;
- } else if (this->decoder_ok) {
-
- if (this->size + buf->size > this->bufsize) {
- this->bufsize = this->size + 2 * buf->size;
- this->buf = realloc (this->buf, this->bufsize);
- }
-
- xine_fast_memcpy (&this->buf[this->size], buf->content, buf->size);
-
- this->size += buf->size;
-
- if (buf->decoder_flags & BUF_FLAG_FRAME_END) {
-
- img = this->stream->video_out->get_frame (this->stream->video_out,
- this->width, this->height,
- this->ratio, XINE_IMGFMT_YUY2, VO_BOTH_FIELDS);
-
- img->duration = this->video_step;
- img->pts = buf->pts;
- img->bad_frame = 0;
-
- decode_fli_frame(this);
- yuv444_to_yuy2(&this->yuv_planes, img->base[0], img->pitches[0]);
-
- img->draw(img, this->stream);
- img->free(img);
-
- this->size = 0;
- }
- }
-}
-
-/*
- * This function is called when xine needs to flush the system. Not
- * sure when or if this is used or even if it needs to do anything.
- */
-static void fli_flush (video_decoder_t *this_gen) {
-}
-
-/*
- * This function resets the video decoder.
- */
-static void fli_reset (video_decoder_t *this_gen) {
- fli_decoder_t *this = (fli_decoder_t *) this_gen;
-
- this->size = 0;
-}
-
-static void fli_discontinuity (video_decoder_t *this_gen) {
-}
-
-/*
- * This function frees the video decoder instance allocated to the decoder.
- */
-static void fli_dispose (video_decoder_t *this_gen) {
-
- fli_decoder_t *this = (fli_decoder_t *) this_gen;
-
- if (this->buf) {
- free (this->buf);
- this->buf = NULL;
- }
-
- free_yuv_planes(&this->yuv_planes);
- free(this->ghost_image);
-
- if (this->decoder_ok) {
- this->decoder_ok = 0;
- this->stream->video_out->close(this->stream->video_out, this->stream);
- }
-
- free (this_gen);
-}
-
-static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stream_t *stream) {
-
- fli_decoder_t *this ;
-
- this = (fli_decoder_t *) xine_xmalloc (sizeof (fli_decoder_t));
-
- this->video_decoder.decode_data = fli_decode_data;
- this->video_decoder.flush = fli_flush;
- this->video_decoder.reset = fli_reset;
- this->video_decoder.discontinuity = fli_discontinuity;
- this->video_decoder.dispose = fli_dispose;
- this->size = 0;
-
- this->stream = stream;
- this->class = (fli_class_t *) class_gen;
-
- this->decoder_ok = 0;
- this->buf = NULL;
-
- return &this->video_decoder;
-}
-
-static char *get_identifier (video_decoder_class_t *this) {
- return "FLI Video";
-}
-
-static char *get_description (video_decoder_class_t *this) {
- return "Autodesk Animator FLI/FLC video decoder plugin";
-}
-
-static void dispose_class (video_decoder_class_t *this) {
- free (this);
-}
-
-static void *init_plugin (xine_t *xine, void *data) {
-
- fli_class_t *this;
-
- this = (fli_class_t *) xine_xmalloc (sizeof (fli_class_t));
-
- this->decoder_class.open_plugin = open_plugin;
- this->decoder_class.get_identifier = get_identifier;
- this->decoder_class.get_description = get_description;
- this->decoder_class.dispose = dispose_class;
-
- return this;
-}
-
-/*
- * exported plugin catalog entry
- */
-
-static uint32_t video_types[] = {
- BUF_VIDEO_FLI,
- 0
- };
-
-static decoder_info_t dec_info_video = {
- video_types, /* supported types */
- 5 /* priority */
-};
-
-plugin_info_t xine_plugin_info[] = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_VIDEO_DECODER, 18, "fli", XINE_VERSION_CODE, &dec_info_video, init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
-
diff --git a/src/libxinevdec/idcinvideo.c b/src/libxinevdec/idcinvideo.c
deleted file mode 100644
index 65308eb4a..000000000
--- a/src/libxinevdec/idcinvideo.c
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- * Copyright (C) 2000-2003 the xine project
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * Id CIN Video Decoder by Dr. Tim Ferguson. For more information about
- * the Id CIN format, visit:
- * http://www.csse.monash.edu.au/~timf/
- *
- * $Id: idcinvideo.c,v 1.23 2004/02/09 22:04:11 jstembridge Exp $
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "buffer.h"
-#include "xine_internal.h"
-#include "video_out.h"
-#include "xineutils.h"
-#include "bswap.h"
-
-#define VIDEOBUFSIZE 128*1024
-
-typedef struct {
- video_decoder_class_t decoder_class;
-} idcinvideo_class_t;
-
-typedef struct idcinvideo_decoder_s {
- video_decoder_t video_decoder; /* parent video decoder structure */
-
- idcinvideo_class_t *class;
- xine_stream_t *stream;
-
- /* these are traditional variables in a video decoder object */
- uint64_t video_step; /* frame duration in pts units */
- int decoder_ok; /* current decoder status */
- int skipframes;
-
- unsigned char *buf; /* the accumulated buffer data */
- int bufsize; /* the maximum size of buf */
- int size; /* the current size of buf */
-
- int width; /* the width of a video frame */
- int height; /* the height of a video frame */
- double ratio; /* the width to height ratio */
-
- unsigned char yuv_palette[256 * 4];
- yuv_planes_t yuv_planes;
-
-} idcinvideo_decoder_t;
-
-/**************************************************************************
- * idcinvideo specific decode functions
- *************************************************************************/
-
-#define HUF_TOKENS 256
-
-typedef struct
-{
- long rate;
- long width;
- long channels;
-} wavinfo_t;
-
-typedef struct
-{
- int count;
- unsigned char used;
- int children[2];
-} hnode_t;
-
-static hnode_t huff_nodes[256][HUF_TOKENS*2];
-static int num_huff_nodes[256];
-
-/*
- * Decodes input Huffman data using the Huffman table.
- */
-static void huff_decode(idcinvideo_decoder_t *this) {
- hnode_t *hnodes;
- long i;
- int prev;
- unsigned char v = 0;
- int bit_pos, node_num, dat_pos;
- int plane_ptr = 0;
-
- prev = bit_pos = dat_pos = 0;
- for(i = 0; i < (this->width * this->height); i++) {
- node_num = num_huff_nodes[prev];
- hnodes = huff_nodes[prev];
-
- while(node_num >= HUF_TOKENS) {
- if(!bit_pos) {
- if(dat_pos > this->size) {
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "Huffman decode error.\n");
- return;
- }
- bit_pos = 8;
- v = this->buf[dat_pos++];
- }
-
- node_num = hnodes[node_num].children[v & 0x01];
- v = v >> 1;
- bit_pos--;
- }
-
- this->yuv_planes.y[plane_ptr] = this->yuv_palette[node_num * 4 + 0];
- this->yuv_planes.u[plane_ptr] = this->yuv_palette[node_num * 4 + 1];
- this->yuv_planes.v[plane_ptr] = this->yuv_palette[node_num * 4 + 2];
- plane_ptr++;
-
- prev = node_num;
- }
-}
-
-/*
- * Find the lowest probability node in a Huffman table, and mark it as
- * being assigned to a higher probability.
- * Returns the node index of the lowest unused node, or -1 if all nodes
- * are used.
- */
-static int huff_smallest_node(hnode_t *hnodes, int num_hnodes) {
- int i;
- int best, best_node;
-
- best = 99999999;
- best_node = -1;
- for(i = 0; i < num_hnodes; i++) {
- if(hnodes[i].used)
- continue;
- if(!hnodes[i].count)
- continue;
- if(hnodes[i].count < best) {
- best = hnodes[i].count;
- best_node = i;
- }
- }
-
- if(best_node == -1)
- return -1;
- hnodes[best_node].used = 1;
- return best_node;
-}
-
-/*
- * Build the Huffman tree using the generated/loaded probabilities histogram.
- *
- * On completion:
- * huff_nodes[prev][i < HUF_TOKENS] - are the nodes at the base of the tree.
- * huff_nodes[prev][i >= HUF_TOKENS] - are used to construct the tree.
- * num_huff_nodes[prev] - contains the index to the root node of the tree.
- * That is: huff_nodes[prev][num_huff_nodes[prev]] is the root node.
- */
-static void huff_build_tree(int prev) {
- hnode_t *node, *hnodes;
- int num_hnodes, i;
-
- num_hnodes = HUF_TOKENS;
- hnodes = huff_nodes[prev];
- for(i = 0; i < HUF_TOKENS * 2; i++)
- hnodes[i].used = 0;
-
- while (1) {
- node = &hnodes[num_hnodes]; /* next free node */
-
- /* pick two lowest counts */
- node->children[0] = huff_smallest_node(hnodes, num_hnodes);
- if(node->children[0] == -1)
- break; /* reached the root node */
-
- node->children[1] = huff_smallest_node(hnodes, num_hnodes);
- if(node->children[1] == -1)
- break; /* reached the root node */
-
- /* combine nodes probability for new node */
- node->count = hnodes[node->children[0]].count +
- hnodes[node->children[1]].count;
- num_hnodes++;
- }
-
- num_huff_nodes[prev] = num_hnodes - 1;
-}
-
-
-/**************************************************************************
- * xine video plugin functions
- *************************************************************************/
-
-/*
- * This function receives a buffer of data from the demuxer layer and
- * figures out how to handle it based on its header flags.
- */
-static void idcinvideo_decode_data (video_decoder_t *this_gen,
- buf_element_t *buf) {
-
- idcinvideo_decoder_t *this = (idcinvideo_decoder_t *) this_gen;
- palette_entry_t *palette;
- unsigned char *histograms;
- int i, j, histogram_index = 0;
-
- vo_frame_t *img; /* video out frame */
-
- /* a video decoder does not care about this flag (?) */
- if (buf->decoder_flags & BUF_FLAG_PREVIEW)
- return;
-
- /* load the palette */
- if ((buf->decoder_flags & BUF_FLAG_SPECIAL) &&
- (buf->decoder_info[1] == BUF_SPECIAL_PALETTE)) {
- palette = (palette_entry_t *)buf->decoder_info_ptr[2];
- for (i = 0; i < buf->decoder_info[2]; i++) {
- this->yuv_palette[i * 4 + 0] =
- COMPUTE_Y(palette[i].r, palette[i].g, palette[i].b);
- this->yuv_palette[i * 4 + 1] =
- COMPUTE_U(palette[i].r, palette[i].g, palette[i].b);
- this->yuv_palette[i * 4 + 2] =
- COMPUTE_V(palette[i].r, palette[i].g, palette[i].b);
- }
- }
-
- if (buf->decoder_flags & BUF_FLAG_FRAMERATE) {
- this->video_step = buf->decoder_info[0];
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION, this->video_step);
- }
-
- if (buf->decoder_flags & BUF_FLAG_STDHEADER) { /* need to initialize */
- xine_bmiheader *bih = (xine_bmiheader *)buf->content;
-
- this->stream->video_out->open (this->stream->video_out, this->stream);
-
- if(this->buf)
- free(this->buf);
-
- this->width = bih->biWidth;
- this->height = bih->biHeight;
- this->ratio = (double)this->width/(double)this->height;
-
- /* initialize the Huffman tables */
- histograms = (unsigned char *)buf->content + sizeof(xine_bmiheader);
- for (i = 0; i < 256; i++) {
- for(j = 0; j < HUF_TOKENS; j++)
- huff_nodes[i][j].count = histograms[histogram_index++];
- huff_build_tree(i);
- }
-
- if (this->buf)
- free (this->buf);
- this->bufsize = VIDEOBUFSIZE;
- this->buf = malloc(this->bufsize);
- this->size = 0;
-
- init_yuv_planes(&this->yuv_planes, this->width, this->height);
-
- this->stream->video_out->open (this->stream->video_out, this->stream);
- this->decoder_ok = 1;
-
- /* load the stream/meta info */
- _x_meta_info_set(this->stream, XINE_META_INFO_VIDEOCODEC, "Id CIN Video");
-
- return;
- } else if (this->decoder_ok) {
-
- if (this->size + buf->size > this->bufsize) {
- this->bufsize = this->size + 2 * buf->size;
- this->buf = realloc (this->buf, this->bufsize);
- }
-
- xine_fast_memcpy (&this->buf[this->size], buf->content, buf->size);
-
- this->size += buf->size;
-
- if (buf->decoder_flags & BUF_FLAG_FRAME_END) {
-
- img = this->stream->video_out->get_frame (this->stream->video_out,
- this->width, this->height,
- this->ratio, XINE_IMGFMT_YUY2, VO_BOTH_FIELDS);
-
- img->duration = this->video_step;
- img->pts = buf->pts;
- img->bad_frame = 0;
-
- huff_decode(this);
- yuv444_to_yuy2(&this->yuv_planes, img->base[0], img->pitches[0]);
-
- img->draw(img, this->stream);
- img->free(img);
-
- this->size = 0;
- }
- }
-}
-
-/*
- * This function is called when xine needs to flush the system. Not
- * sure when or if this is used or even if it needs to do anything.
- */
-static void idcinvideo_flush (video_decoder_t *this_gen) {
-}
-
-/*
- * This function resets the video decoder.
- */
-static void idcinvideo_reset (video_decoder_t *this_gen) {
- idcinvideo_decoder_t *this = (idcinvideo_decoder_t *) this_gen;
-
- this->size = 0;
-}
-
-static void idcinvideo_discontinuity (video_decoder_t *this_gen) {
-}
-
-/*
- * This function frees the video decoder instance allocated to the decoder.
- */
-static void idcinvideo_dispose (video_decoder_t *this_gen) {
-
- idcinvideo_decoder_t *this = (idcinvideo_decoder_t *) this_gen;
-
- if (this->buf) {
- free (this->buf);
- this->buf = NULL;
- }
-
- if (this->decoder_ok) {
- this->decoder_ok = 0;
- this->stream->video_out->close(this->stream->video_out, this->stream);
- }
-
- free (this_gen);
-}
-
-static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stream_t *stream) {
-
- idcinvideo_decoder_t *this ;
-
- this = (idcinvideo_decoder_t *) xine_xmalloc (sizeof (idcinvideo_decoder_t));
-
- this->video_decoder.decode_data = idcinvideo_decode_data;
- this->video_decoder.flush = idcinvideo_flush;
- this->video_decoder.reset = idcinvideo_reset;
- this->video_decoder.discontinuity = idcinvideo_discontinuity;
- this->video_decoder.dispose = idcinvideo_dispose;
- this->size = 0;
-
- this->stream = stream;
- this->class = (idcinvideo_class_t *) class_gen;
-
- this->decoder_ok = 0;
- this->buf = NULL;
-
- return &this->video_decoder;
-}
-
-static char *get_identifier (video_decoder_class_t *this) {
- return "Id CIN Video";
-}
-
-static char *get_description (video_decoder_class_t *this) {
- return "Id Quake II Cinematic video decoder plugin";
-}
-
-static void dispose_class (video_decoder_class_t *this) {
- free (this);
-}
-
-static void *init_plugin (xine_t *xine, void *data) {
-
- idcinvideo_class_t *this;
-
- this = (idcinvideo_class_t *) xine_xmalloc (sizeof (idcinvideo_class_t));
-
- this->decoder_class.open_plugin = open_plugin;
- this->decoder_class.get_identifier = get_identifier;
- this->decoder_class.get_description = get_description;
- this->decoder_class.dispose = dispose_class;
-
- return this;
-}
-
-/* plugin catalog information */
-static uint32_t supported_types[] = { BUF_VIDEO_IDCIN, 0 };
-
-static decoder_info_t video_decoder_info = {
- supported_types, /* supported types */
- 5 /* priority */
-};
-
-plugin_info_t xine_plugin_info[] = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_VIDEO_DECODER, 18, "idcinvideo", XINE_VERSION_CODE, &video_decoder_info, &init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
diff --git a/src/libxinevdec/interplayvideo.c b/src/libxinevdec/interplayvideo.c
deleted file mode 100644
index 503db7004..000000000
--- a/src/libxinevdec/interplayvideo.c
+++ /dev/null
@@ -1,1388 +0,0 @@
-/*
- * Copyright (C) 2000-2003 the xine project
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * Interplay MVE File Video Decoder by Mike Melanson (melanson@pcisys.net)
- * For more information regarding the Interplay MVE format, visit:
- * http://www.pcisys.net/~melanson/codecs/
- *
- * $Id: interplayvideo.c,v 1.12 2004/02/09 22:04:11 jstembridge Exp $
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "xine_internal.h"
-#include "video_out.h"
-#include "buffer.h"
-#include "xineutils.h"
-#include "bswap.h"
-
-/* debugging support */
-#define DEBUG_INTERPLAY 0
-#if DEBUG_INTERPLAY
-#define debug_interplay printf
-#else
-static inline void debug_interplay(const char *format, ...) { }
-#endif
-
-#define VIDEOBUFSIZE 128*1024
-
-typedef struct {
- video_decoder_class_t decoder_class;
-} interplay_class_t;
-
-typedef struct interplay_decoder_s {
- video_decoder_t video_decoder; /* parent video decoder structure */
-
- interplay_class_t *class;
- xine_stream_t *stream;
-
- /* these are traditional variables in a video decoder object */
- uint64_t video_step; /* frame duration in pts units */
- int decoder_ok; /* current decoder status */
- int skipframes;
-
- unsigned char *buf; /* the accumulated buffer data */
- int bufsize; /* the maximum size of buf */
- int size; /* the current size of buf */
-
- int width; /* the width of a video frame */
- int height; /* the height of a video frame */
- double ratio; /* the width to height ratio */
-
- unsigned char yuv_palette[256 * 4];
-
- yuv_planes_t yuv_planes1;
- yuv_planes_t yuv_planes2;
-
- yuv_planes_t *current_frame;
- yuv_planes_t *previous_frame;
-
- /* this is either 1 or 2 indicating the current_frame points to yuv_planes
- * structure 1 or 2 */
- int current_planes;
-
- unsigned char *decode_map;
- int decode_map_index;
-
-} interplay_decoder_t;
-
-/**************************************************************************
- * Interplay Video specific decode functions
- *************************************************************************/
-
-#define CHECK_STREAM_PTR(n) \
- if ((stream_ptr + n) > this->size) { \
- printf ("Interplay video warning: stream_ptr out of bounds (%d >= %d)\n", \
- stream_ptr + n, this->size); \
- return; \
- }
-
-#define COPY_BLOCK_FROM_CURRENT() \
- if (motion_pixel_ptr < 0) \
- printf ("Interplay video warning: motion pixel ptr < 0 (%d), motion byte = %d (0x%X)\n", \
- motion_pixel_ptr, motion_byte, motion_byte); \
- else if (motion_pixel_ptr >= motion_limit) \
- printf ("Interplay video warning: motion pixel ptr out of motion range (%d >= %d), motion byte = %d (0x%X)\n", \
- motion_pixel_ptr, motion_limit, motion_byte, motion_byte); \
- else for (i = 0; i < 8; i++) { \
- xine_fast_memcpy(&this->current_frame->y[pixel_ptr], \
- &this->current_frame->y[motion_pixel_ptr], 8); \
- xine_fast_memcpy(&this->current_frame->u[pixel_ptr], \
- &this->current_frame->u[motion_pixel_ptr], 8); \
- xine_fast_memcpy(&this->current_frame->v[pixel_ptr], \
- &this->current_frame->v[motion_pixel_ptr], 8); \
- pixel_ptr += this->width; \
- }
-
-#define COPY_BLOCK_FROM_PREVIOUS() \
- if (motion_pixel_ptr < 0) \
- printf ("Interplay video warning: motion pixel ptr < 0 (%d), motion byte = %d (0x%X)\n", \
- motion_pixel_ptr, motion_byte, motion_byte); \
- else if (motion_pixel_ptr >= motion_limit) \
- printf ("Interplay video warning: motion pixel ptr out of motion range (%d >= %d), motion byte = %d (0x%X)\n", \
- motion_pixel_ptr, motion_limit, motion_byte, motion_byte); \
- else for (i = 0; i < 8; i++) { \
- xine_fast_memcpy(&this->current_frame->y[pixel_ptr], \
- &this->previous_frame->y[motion_pixel_ptr], 8); \
- xine_fast_memcpy(&this->current_frame->u[pixel_ptr], \
- &this->previous_frame->u[motion_pixel_ptr], 8); \
- xine_fast_memcpy(&this->current_frame->v[pixel_ptr], \
- &this->previous_frame->v[motion_pixel_ptr], 8); \
- pixel_ptr += this->width; \
- }
-
-static void interplay_decode_frame(interplay_decoder_t *this) {
-
- int pixel_ptr, motion_pixel_ptr;
- int x, y;
- int xp, yp;
- int i, j;
- unsigned char code;
- int index = 0;
- int stream_ptr = 14;
- unsigned char color0, color1, color2, color3;
- unsigned char y0, u0, v0;
- unsigned char y1, u1, v1;
- unsigned char y2, u2, v2;
- unsigned char y3, u3, v3;
- unsigned char y4 = 0, u4 = 0, v4 = 0;
- int row_inc = this->width - 8;
- unsigned char motion_byte;
- int motion_limit = this->width * (this->height - 8);
- unsigned int flags;
- unsigned int flag_mask;
- int code_counts[16];
-
- for (i = 0; i < 6; i++) {
- for (j = 0; j < 16; j++)
- debug_interplay (" %02X", this->buf[i * 16 + j]);
- debug_interplay ("\n");
- }
-
- for (i = 0; i < 16; i++)
- code_counts[i] = 0;
-
- /* interate through the 8x8 blocks, left -> right, top -> bottom */
- for (y = 0; y < (this->width * this->height); y += (this->width * 8)) {
- for (x = y; x < (y + this->width); x += 8) {
- if (index & 1)
- code = this->decode_map[index >> 1] >> 4;
- else
- code = this->decode_map[index >> 1] & 0xF;
- index++;
-
- debug_interplay (" block %3d, %3d: encoding 0x%X\n",
- x - y, y / this->width, code);
- code_counts[code]++;
- switch (code) {
-
- case 0x0:
- case 0x1:
- /* skip block (actually, copy from previous frame) */
- motion_pixel_ptr = pixel_ptr = x;
- motion_byte = 0;
- COPY_BLOCK_FROM_PREVIOUS();
- break;
-
- case 0x2:
- /* copy block from current frame, right-bottom */
- CHECK_STREAM_PTR(1);
-
- motion_byte = this->buf[stream_ptr++];
- motion_pixel_ptr = pixel_ptr = x;
-
- if (motion_byte < 56) {
- /* horizontal component */
- motion_pixel_ptr += 8 + (motion_byte % 7);
- /* vertical component */
- motion_pixel_ptr += ((motion_byte / 7) * this->width);
- } else {
- /* horizontal component */
- motion_pixel_ptr += (-14 + ((motion_byte - 56) % 29));
- /* vertical component */
- motion_pixel_ptr += ((8 + ((motion_byte - 56) / 29)) * this->width);
- }
- COPY_BLOCK_FROM_CURRENT();
- break;
-
- case 0x3:
- /* copy block from current frame, left-top */
- CHECK_STREAM_PTR(1);
-
- motion_byte = this->buf[stream_ptr++];
- motion_pixel_ptr = pixel_ptr = x;
-
- if (motion_byte < 56) {
- /* horizontal component */
- motion_pixel_ptr -= 8 + (motion_byte % 7);
- /* vertical component */
- motion_pixel_ptr -= ((motion_byte / 7) * this->width);
- } else {
- /* horizontal component */
- motion_pixel_ptr -= (-14 + ((motion_byte - 56) % 29));
- /* vertical component */
- motion_pixel_ptr -= ((8 + ((motion_byte - 56) / 29)) * this->width);
- }
- COPY_BLOCK_FROM_CURRENT();
- break;
-
- case 0x4:
- /* copy block from previous frame, right-bottom */
- CHECK_STREAM_PTR(1);
-
- motion_byte = this->buf[stream_ptr++];
- motion_pixel_ptr = pixel_ptr = x;
-
- /* horizontal component */
- motion_pixel_ptr += (-8 + (motion_byte & 0xF));
- /* vertical component */
- motion_pixel_ptr += ((-8 + ((motion_byte >> 4) & 0xF)) * this->width);
- COPY_BLOCK_FROM_PREVIOUS();
- break;
-
- case 0x5:
- /* copy block from previous frame, left-top */
- CHECK_STREAM_PTR(2);
-
- motion_pixel_ptr = pixel_ptr = x;
- /* horizontal component */
- motion_byte = this->buf[stream_ptr++];
- motion_pixel_ptr += (signed char)motion_byte;
- /* vertical component */
- motion_byte = this->buf[stream_ptr++];
- motion_pixel_ptr += ((signed char)motion_byte * this->width);
- COPY_BLOCK_FROM_PREVIOUS();
- break;
-
- case 0x6:
- /* mystery opcode? skip multiple blocks? */
- break;
-
- case 0x7:
- /* 2-color encoding */
- color0 = this->buf[stream_ptr++];
- y0 = this->yuv_palette[color0 * 4 + 0];
- u0 = this->yuv_palette[color0 * 4 + 1];
- v0 = this->yuv_palette[color0 * 4 + 2];
- color1 = this->buf[stream_ptr++];
- y1 = this->yuv_palette[color1 * 4 + 0];
- u1 = this->yuv_palette[color1 * 4 + 1];
- v1 = this->yuv_palette[color1 * 4 + 2];
-
- if (color0 <= color1) {
- /* get 8 bytes, or 64 flags from the bytestream; if a flag is 0
- * use color 0; 1, use color 1 */
- CHECK_STREAM_PTR(8);
- pixel_ptr = x;
- for (i = 0; i < 8; i++) {
- flags = this->buf[stream_ptr++];
- for (flag_mask = 0x80; flag_mask != 0; flag_mask >>= 1) {
- if (flags & flag_mask) {
- this->current_frame->y[pixel_ptr] = y1;
- this->current_frame->u[pixel_ptr] = u1;
- this->current_frame->v[pixel_ptr] = v1;
- } else {
- this->current_frame->y[pixel_ptr] = y0;
- this->current_frame->u[pixel_ptr] = u0;
- this->current_frame->v[pixel_ptr] = v0;
- }
- pixel_ptr++;
- }
- pixel_ptr += row_inc;
- }
- } else {
- /* get 2 bytes, or 16 flags from the bytestream; use them to
- * paint 2x2 blocks */
- CHECK_STREAM_PTR(2);
- flags = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
- flag_mask = 0x8000;
-
- for (yp = x; yp < (x + this->width * 8); yp += (this->width * 2)) {
- for (xp = yp; xp < (yp + 8); xp += 2) {
-
- if (flags & flag_mask) {
- y2 = y1;
- u2 = u1;
- v2 = v1;
- } else {
- y2 = y0;
- u2 = u0;
- v2 = v0;
- }
- flag_mask >>= 1;
-
- pixel_ptr = xp;
- for (i = 0; i < 2; i++) {
- for (j = 0; j < 2; j++) {
- this->current_frame->y[pixel_ptr] = y2;
- this->current_frame->u[pixel_ptr] = u2;
- this->current_frame->v[pixel_ptr] = v2;
- pixel_ptr++;
- }
- pixel_ptr += this->width - 2;
- }
- }
- }
- }
- break;
-
- case 0x8:
- /* 2-color encoding for each 4x4 quadrant, or 2-color encoding on
- * either top and bottom or left and right halves */
- CHECK_STREAM_PTR(2);
- color0 = this->buf[stream_ptr++];
- color1 = this->buf[stream_ptr++];
- if (color0 <= color1) {
- /* there are 14 more byte in the stream, for a total of 16;
- * each set of 4 bytes contains 2 colors and 16 bit flags to
- * specify how one 4x4 quadrant should me painted */
- CHECK_STREAM_PTR(14);
-
- /* iterate through 4 quadrants */
- for (xp = 0; xp < 4; xp++) {
- if (xp == 0)
- pixel_ptr = x;
- else if (xp == 1)
- pixel_ptr = x + (this->width * 4);
- else if (xp == 2)
- pixel_ptr = x + 4;
- else
- pixel_ptr = x + (this->width * 4) + 4;
-
- /* get this quadrant's color pair if this is not the first
- * quadrant (those colors have already been obtained) */
- if (xp > 0) {
- color0 = this->buf[stream_ptr++];
- color1 = this->buf[stream_ptr++];
- }
- y0 = this->yuv_palette[color0 * 4 + 0];
- u0 = this->yuv_palette[color0 * 4 + 1];
- v0 = this->yuv_palette[color0 * 4 + 2];
- y1 = this->yuv_palette[color1 * 4 + 0];
- u1 = this->yuv_palette[color1 * 4 + 1];
- v1 = this->yuv_palette[color1 * 4 + 2];
-
- /* get the flags for this quadrant */
- flags = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
- flag_mask = 0x8000;
-
- /* paint the 4x4 block */
- for (i = 0; i < 4; i++) {
- for (j = 0; j < 4; j++) {
- if (flags & flag_mask) {
- this->current_frame->y[pixel_ptr] = y1;
- this->current_frame->u[pixel_ptr] = u1;
- this->current_frame->v[pixel_ptr] = v1;
- } else {
- this->current_frame->y[pixel_ptr] = y0;
- this->current_frame->u[pixel_ptr] = u0;
- this->current_frame->v[pixel_ptr] = v0;
- }
- pixel_ptr++;
- flag_mask >>= 1;
- }
- pixel_ptr += this->width - 4;
- }
- }
- } else {
- /* there are 10 more bytes in the stream for a total of 12;
- * each set of 6 bytes contains 2 colors and 32 bit flags to
- * specify how half of the 8x8 block (either 8x4 or 4x8) will
- * be painted */
- CHECK_STREAM_PTR(10);
- color2 = this->buf[stream_ptr + 4];
- color3 = this->buf[stream_ptr + 5];
- if (color2 <= color3) {
- /* block is split into left and right halves */
- for (xp = 0; xp < 2; xp++) {
- if (xp == 0) {
- pixel_ptr = x;
- y0 = this->yuv_palette[color0 * 4 + 0];
- u0 = this->yuv_palette[color0 * 4 + 1];
- v0 = this->yuv_palette[color0 * 4 + 2];
- y1 = this->yuv_palette[color1 * 4 + 0];
- u1 = this->yuv_palette[color1 * 4 + 1];
- v1 = this->yuv_palette[color1 * 4 + 2];
- flags = BE_32(&this->buf[stream_ptr]);
- } else {
- pixel_ptr = x + 4;
- y0 = this->yuv_palette[color2 * 4 + 0];
- u0 = this->yuv_palette[color2 * 4 + 1];
- v0 = this->yuv_palette[color2 * 4 + 2];
- y1 = this->yuv_palette[color3 * 4 + 0];
- u1 = this->yuv_palette[color3 * 4 + 1];
- v1 = this->yuv_palette[color3 * 4 + 2];
- flags = BE_32(&this->buf[stream_ptr + 6]);
- }
- flag_mask = 0x80000000;
-
- /* paint the 4x8 block */
- for (i = 0; i < 8; i++) {
- for (j = 0; j < 4; j++) {
- if (flags & flag_mask) {
- this->current_frame->y[pixel_ptr] = y1;
- this->current_frame->u[pixel_ptr] = u1;
- this->current_frame->v[pixel_ptr] = v1;
- } else {
- this->current_frame->y[pixel_ptr] = y0;
- this->current_frame->u[pixel_ptr] = u0;
- this->current_frame->v[pixel_ptr] = v0;
- }
- pixel_ptr++;
- flag_mask >>= 1;
- }
- pixel_ptr += this->width - 4;
- }
- }
- } else {
- /* block is split into top and bottom halves */
- for (xp = 0; xp < 2; xp++) {
- if (xp == 0) {
- pixel_ptr = x;
- y0 = this->yuv_palette[color0 * 4 + 0];
- u0 = this->yuv_palette[color0 * 4 + 1];
- v0 = this->yuv_palette[color0 * 4 + 2];
- y1 = this->yuv_palette[color1 * 4 + 0];
- u1 = this->yuv_palette[color1 * 4 + 1];
- v1 = this->yuv_palette[color1 * 4 + 2];
- flags = BE_32(&this->buf[stream_ptr]);
- } else {
- pixel_ptr = x + (this->width * 4);
- y0 = this->yuv_palette[color2 * 4 + 0];
- u0 = this->yuv_palette[color2 * 4 + 1];
- v0 = this->yuv_palette[color2 * 4 + 2];
- y1 = this->yuv_palette[color3 * 4 + 0];
- u1 = this->yuv_palette[color3 * 4 + 1];
- v1 = this->yuv_palette[color3 * 4 + 2];
- flags = BE_32(&this->buf[stream_ptr + 6]);
- }
- flag_mask = 0x80000000;
-
- /* paint the 8x4 block */
- for (i = 0; i < 4; i++) {
- for (j = 0; j < 8; j++) {
- if (flags & flag_mask) {
- this->current_frame->y[pixel_ptr] = y1;
- this->current_frame->u[pixel_ptr] = u1;
- this->current_frame->v[pixel_ptr] = v1;
- } else {
- this->current_frame->y[pixel_ptr] = y0;
- this->current_frame->u[pixel_ptr] = u0;
- this->current_frame->v[pixel_ptr] = v0;
- }
- pixel_ptr++;
- flag_mask >>= 1;
- }
- pixel_ptr += row_inc;
- }
- }
- }
-
- stream_ptr += 10;
- }
- break;
-
- case 0x9:
- /* 4-color encoding */
- CHECK_STREAM_PTR(4);
- color0 = this->buf[stream_ptr++];
- y0 = this->yuv_palette[color0 * 4 + 0];
- u0 = this->yuv_palette[color0 * 4 + 1];
- v0 = this->yuv_palette[color0 * 4 + 2];
- color1 = this->buf[stream_ptr++];
- y1 = this->yuv_palette[color1 * 4 + 0];
- u1 = this->yuv_palette[color1 * 4 + 1];
- v1 = this->yuv_palette[color1 * 4 + 2];
- color2 = this->buf[stream_ptr++];
- y2 = this->yuv_palette[color2 * 4 + 0];
- u2 = this->yuv_palette[color2 * 4 + 1];
- v2 = this->yuv_palette[color2 * 4 + 2];
- color3 = this->buf[stream_ptr++];
- y3 = this->yuv_palette[color3 * 4 + 0];
- u3 = this->yuv_palette[color3 * 4 + 1];
- v3 = this->yuv_palette[color3 * 4 + 2];
-
- if ((color0 <= color1) && (color2 <= color3)) {
-
- /* there are 16 bytes in the stream which form 64 2-bit
- * flags to select the color of each of the 64 pixels in
- * the 8x8 block */
- CHECK_STREAM_PTR(16);
- pixel_ptr = x;
- for (i = 0; i < 8; i++) {
- /* reload the flags at every row */
- flags = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
- flag_mask = 14;
- for (j = 0; j < 8; j++) {
- switch ((flags >> flag_mask) & 0x03) {
-
- case 0:
- this->current_frame->y[pixel_ptr] = y0;
- this->current_frame->u[pixel_ptr] = u0;
- this->current_frame->v[pixel_ptr] = v0;
- break;
-
- case 1:
- this->current_frame->y[pixel_ptr] = y1;
- this->current_frame->u[pixel_ptr] = u1;
- this->current_frame->v[pixel_ptr] = v1;
- break;
-
- case 2:
- this->current_frame->y[pixel_ptr] = y2;
- this->current_frame->u[pixel_ptr] = u2;
- this->current_frame->v[pixel_ptr] = v2;
- break;
-
- case 3:
- this->current_frame->y[pixel_ptr] = y3;
- this->current_frame->u[pixel_ptr] = u3;
- this->current_frame->v[pixel_ptr] = v3;
- break;
-
- }
- pixel_ptr++;
- flag_mask -= 2;
- }
- pixel_ptr += row_inc;
- }
-
- } else if ((color0 <= color1) && (color2 > color3)) {
-
- /* there are 4 bytes in the stream comprising 16 2-bit
- * flags which specify 1 of 4 colors for each of 16 2x2
- * blocks */
- CHECK_STREAM_PTR(4);
- flags = BE_32(&this->buf[stream_ptr]);
- stream_ptr += 4;
- flag_mask = 30;
-
- for (yp = x; yp < (x + this->width * 8); yp += (this->width * 2)) {
- for (xp = yp; xp < (yp + 8); xp += 2) {
-
- switch ((flags >> flag_mask) & 0x03) {
-
- case 0:
- y4 = y0;
- u4 = u0;
- v4 = v0;
- break;
-
- case 1:
- y4 = y1;
- u4 = u1;
- v4 = v1;
- break;
-
- case 2:
- y4 = y2;
- u4 = u2;
- v4 = v2;
- break;
-
- case 3:
- y4 = y3;
- u4 = u3;
- v4 = v3;
- break;
-
- }
- flag_mask -= 2;
-
- pixel_ptr = xp;
- for (i = 0; i < 2; i++) {
- for (j = 0; j < 2; j++) {
- this->current_frame->y[pixel_ptr] = y4;
- this->current_frame->u[pixel_ptr] = u4;
- this->current_frame->v[pixel_ptr] = v4;
- pixel_ptr++;
- }
- pixel_ptr += this->width - 2;
- }
- }
- }
-
- } else if ((color0 > color1) && (color2 <= color3)) {
-
- /* there are 8 bytes in the stream comprising 32 2-bit
- * flags which specify 1 of 4 colors for each of 32 2x1
- * blocks */
- CHECK_STREAM_PTR(8);
- flags = BE_32(&this->buf[stream_ptr]);
- stream_ptr += 4;
- flag_mask = 30;
-
- for (yp = x; yp < (x + this->width * 8); yp += this->width) {
-
- /* time to reload flags? */
- if (yp == (x + this->width * 4)) {
- flags = BE_32(&this->buf[stream_ptr]);
- stream_ptr += 4;
- flag_mask = 30;
- }
-
- for (xp = yp; xp < (yp + 8); xp += 2) {
-
- switch ((flags >> flag_mask) & 0x03) {
-
- case 0:
- y4 = y0;
- u4 = u0;
- v4 = v0;
- break;
-
- case 1:
- y4 = y1;
- u4 = u1;
- v4 = v1;
- break;
-
- case 2:
- y4 = y2;
- u4 = u2;
- v4 = v2;
- break;
-
- case 3:
- y4 = y3;
- u4 = u3;
- v4 = v3;
- break;
-
- }
- flag_mask -= 2;
-
- pixel_ptr = xp;
- for (i = 0; i < 2; i++) {
- this->current_frame->y[pixel_ptr] = y4;
- this->current_frame->u[pixel_ptr] = u4;
- this->current_frame->v[pixel_ptr] = v4;
- pixel_ptr++;
- }
- }
- }
-
- } else {
-
- /* there are 8 bytes in the stream comprising 32 2-bit
- * flags which specify 1 of 4 colors for each of 32 1x2
- * blocks */
- CHECK_STREAM_PTR(8);
- flags = BE_32(&this->buf[stream_ptr]);
- stream_ptr += 4;
- flag_mask = 30;
-
- for (yp = x; yp < (x + this->width * 8); yp += (this->width * 2)) {
-
- /* time to reload flags? */
- if (yp == (x + this->width * 4)) {
- flags = BE_32(&this->buf[stream_ptr]);
- stream_ptr += 4;
- flag_mask = 30;
- }
-
- for (xp = yp; xp < (yp + 8); xp++) {
-
- switch ((flags >> flag_mask) & 0x03) {
-
- case 0:
- y4 = y0;
- u4 = u0;
- v4 = v0;
- break;
-
- case 1:
- y4 = y1;
- u4 = u1;
- v4 = v1;
- break;
-
- case 2:
- y4 = y2;
- u4 = u2;
- v4 = v2;
- break;
-
- case 3:
- y4 = y3;
- u4 = u3;
- v4 = v3;
- break;
-
- }
- flag_mask -= 2;
-
- pixel_ptr = xp;
- for (i = 0; i < 2; i++) {
- this->current_frame->y[pixel_ptr] = y4;
- this->current_frame->u[pixel_ptr] = u4;
- this->current_frame->v[pixel_ptr] = v4;
- pixel_ptr += row_inc;
- }
- }
- }
- }
- break;
-
- case 0xA:
- /* 4-color encoding for each 4x4 quadrant, or 4-color encoding on
- * either top and bottom or left and right halves */
- CHECK_STREAM_PTR(4);
- color0 = this->buf[stream_ptr++];
- color1 = this->buf[stream_ptr++];
- color2 = this->buf[stream_ptr++];
- color3 = this->buf[stream_ptr++];
- if (color0 <= color1) {
- /* there are 28 more byte in the stream, for a total of 32;
- * each set of 8 bytes contains 4 colors and 16 2-bit flags to
- * specify how one 4x4 quadrant should me painted */
- CHECK_STREAM_PTR(28);
-
- /* iterate through 4 quadrants */
- for (xp = 0; xp < 4; xp++) {
- if (xp == 0)
- pixel_ptr = x;
- else if (xp == 1)
- pixel_ptr = x + (this->width * 4);
- else if (xp == 2)
- pixel_ptr = x + 4;
- else
- pixel_ptr = x + (this->width * 4) + 4;
-
- /* get this quadrant's color pair if this is not the first
- * quadrant (those colors have already been obtained) */
- if (xp > 0) {
- color0 = this->buf[stream_ptr++];
- color1 = this->buf[stream_ptr++];
- color2 = this->buf[stream_ptr++];
- color3 = this->buf[stream_ptr++];
- }
- y0 = this->yuv_palette[color0 * 4 + 0];
- u0 = this->yuv_palette[color0 * 4 + 1];
- v0 = this->yuv_palette[color0 * 4 + 2];
- y1 = this->yuv_palette[color1 * 4 + 0];
- u1 = this->yuv_palette[color1 * 4 + 1];
- v1 = this->yuv_palette[color1 * 4 + 2];
- y2 = this->yuv_palette[color2 * 4 + 0];
- u2 = this->yuv_palette[color2 * 4 + 1];
- v2 = this->yuv_palette[color2 * 4 + 2];
- y3 = this->yuv_palette[color3 * 4 + 0];
- u3 = this->yuv_palette[color3 * 4 + 1];
- v3 = this->yuv_palette[color3 * 4 + 2];
-
- /* get the flags for this quadrant */
- flags = BE_32(&this->buf[stream_ptr]);
- stream_ptr += 4;
- flag_mask = 30;
-
- /* paint the 4x4 block */
- for (i = 0; i < 4; i++) {
- for (j = 0; j < 4; j++) {
-
- switch ((flags >> flag_mask) & 0x03) {
-
- case 0:
- this->current_frame->y[pixel_ptr] = y0;
- this->current_frame->u[pixel_ptr] = u0;
- this->current_frame->v[pixel_ptr] = v0;
- break;
-
- case 1:
- this->current_frame->y[pixel_ptr] = y1;
- this->current_frame->u[pixel_ptr] = u1;
- this->current_frame->v[pixel_ptr] = v1;
- break;
-
- case 2:
- this->current_frame->y[pixel_ptr] = y2;
- this->current_frame->u[pixel_ptr] = u2;
- this->current_frame->v[pixel_ptr] = v2;
- break;
-
- case 3:
- this->current_frame->y[pixel_ptr] = y3;
- this->current_frame->u[pixel_ptr] = u3;
- this->current_frame->v[pixel_ptr] = v3;
- break;
-
- }
- flag_mask -= 2;
- pixel_ptr++;
- }
- pixel_ptr += this->width - 4;
- }
- }
- } else {
- /* there are 20 more bytes in the stream for a total of 24;
- * each set of 12 bytes contains 4 colors and 64 2-bit flags to
- * specify how half of the 8x8 block (either 8x4 or 4x8) will
- * be painted */
- CHECK_STREAM_PTR(20);
-
- if (color2 <= color3) {
- /* block is split into left and right halves */
- for (xp = 0; xp < 2; xp++) {
- if (xp == 0)
- pixel_ptr = x;
- else {
- color0 = this->buf[stream_ptr++];
- color1 = this->buf[stream_ptr++];
- color2 = this->buf[stream_ptr++];
- color3 = this->buf[stream_ptr++];
- pixel_ptr = x + 4;
- }
- y0 = this->yuv_palette[color0 * 4 + 0];
- u0 = this->yuv_palette[color0 * 4 + 1];
- v0 = this->yuv_palette[color0 * 4 + 2];
- y1 = this->yuv_palette[color1 * 4 + 0];
- u1 = this->yuv_palette[color1 * 4 + 1];
- v1 = this->yuv_palette[color1 * 4 + 2];
- y2 = this->yuv_palette[color2 * 4 + 0];
- u2 = this->yuv_palette[color2 * 4 + 1];
- v2 = this->yuv_palette[color2 * 4 + 2];
- y3 = this->yuv_palette[color3 * 4 + 0];
- u3 = this->yuv_palette[color3 * 4 + 1];
- v3 = this->yuv_palette[color3 * 4 + 2];
- flags = BE_32(&this->buf[stream_ptr]);
- stream_ptr += 4;
- flag_mask = 30;
-
- /* paint the 4x8 block */
- for (i = 0; i < 8; i++) {
-
- /* time to reload flags? */
- if (i == 4) {
- flags = BE_32(&this->buf[stream_ptr]);
- stream_ptr += 4;
- flag_mask = 30;
- }
- for (j = 0; j < 4; j++) {
-
- switch ((flags >> flag_mask) & 0x03) {
-
- case 0:
- this->current_frame->y[pixel_ptr] = y0;
- this->current_frame->u[pixel_ptr] = u0;
- this->current_frame->v[pixel_ptr] = v0;
- break;
-
- case 1:
- this->current_frame->y[pixel_ptr] = y1;
- this->current_frame->u[pixel_ptr] = u1;
- this->current_frame->v[pixel_ptr] = v1;
- break;
-
- case 2:
- this->current_frame->y[pixel_ptr] = y2;
- this->current_frame->u[pixel_ptr] = u2;
- this->current_frame->v[pixel_ptr] = v2;
- break;
-
- case 3:
- this->current_frame->y[pixel_ptr] = y3;
- this->current_frame->u[pixel_ptr] = u3;
- this->current_frame->v[pixel_ptr] = v3;
- break;
-
- }
-
- pixel_ptr++;
- flag_mask -= 2;
- }
- pixel_ptr += this->width - 4;
- }
- }
- } else {
- /* block is split into top and bottom halves */
- for (xp = 0; xp < 2; xp++) {
- if (xp == 0)
- pixel_ptr = x;
- else {
- color0 = this->buf[stream_ptr++];
- color1 = this->buf[stream_ptr++];
- color2 = this->buf[stream_ptr++];
- color3 = this->buf[stream_ptr++];
- pixel_ptr = x + (this->width * 4);
- }
- y0 = this->yuv_palette[color0 * 4 + 0];
- u0 = this->yuv_palette[color0 * 4 + 1];
- v0 = this->yuv_palette[color0 * 4 + 2];
- y1 = this->yuv_palette[color1 * 4 + 0];
- u1 = this->yuv_palette[color1 * 4 + 1];
- v1 = this->yuv_palette[color1 * 4 + 2];
- y2 = this->yuv_palette[color2 * 4 + 0];
- u2 = this->yuv_palette[color2 * 4 + 1];
- v2 = this->yuv_palette[color2 * 4 + 2];
- y3 = this->yuv_palette[color3 * 4 + 0];
- u3 = this->yuv_palette[color3 * 4 + 1];
- v3 = this->yuv_palette[color3 * 4 + 2];
- flags = BE_32(&this->buf[stream_ptr]);
- stream_ptr += 4;
- flag_mask = 30;
-
- /* paint the 8x4 block */
- for (i = 0; i < 4; i++) {
-
- /* time to reload flags? */
- if (i == 2) {
- flags = BE_32(&this->buf[stream_ptr]);
- stream_ptr += 4;
- flag_mask = 30;
- }
- for (j = 0; j < 8; j++) {
-
- switch ((flags >> flag_mask) & 0x03) {
-
- case 0:
- this->current_frame->y[pixel_ptr] = y0;
- this->current_frame->u[pixel_ptr] = u0;
- this->current_frame->v[pixel_ptr] = v0;
- break;
-
- case 1:
- this->current_frame->y[pixel_ptr] = y1;
- this->current_frame->u[pixel_ptr] = u1;
- this->current_frame->v[pixel_ptr] = v1;
- break;
-
- case 2:
- this->current_frame->y[pixel_ptr] = y2;
- this->current_frame->u[pixel_ptr] = u2;
- this->current_frame->v[pixel_ptr] = v2;
- break;
-
- case 3:
- this->current_frame->y[pixel_ptr] = y3;
- this->current_frame->u[pixel_ptr] = u3;
- this->current_frame->v[pixel_ptr] = v3;
- break;
-
- }
-
- pixel_ptr++;
- flag_mask -= 2;
- }
- pixel_ptr += row_inc;
- }
- }
- }
-
- stream_ptr += 10;
- }
- break;
-
- case 0xB:
- /* 64-color encoding (each pixel is a different color) */
- CHECK_STREAM_PTR(64);
-
- pixel_ptr = x;
- for (i = 0; i < 8; i++) {
- for (j = 0; j < 8; j++) {
- color0 = this->buf[stream_ptr++];
- this->current_frame->y[pixel_ptr] =
- this->yuv_palette[color0 * 4 + 0];
- this->current_frame->u[pixel_ptr] =
- this->yuv_palette[color0 * 4 + 1];
- this->current_frame->v[pixel_ptr] =
- this->yuv_palette[color0 * 4 + 2];
- pixel_ptr++;
- }
- pixel_ptr += row_inc;
- }
- break;
-
- case 0xC:
- /* 16-color block encoding: each 2x2 block is a different color */
- CHECK_STREAM_PTR(16);
- for (yp = x; yp < (x + this->width * 8); yp += (this->width * 2)) {
- for (xp = yp; xp < (yp + 8); xp += 2) {
- color0 = this->buf[stream_ptr++];
- y0 = this->yuv_palette[color0 * 4 + 0];
- u0 = this->yuv_palette[color0 * 4 + 1];
- v0 = this->yuv_palette[color0 * 4 + 2];
-
- pixel_ptr = xp;
- for (i = 0; i < 2; i++) {
- for (j = 0; j < 2; j++) {
- this->current_frame->y[pixel_ptr] = y0;
- this->current_frame->u[pixel_ptr] = u0;
- this->current_frame->v[pixel_ptr] = v0;
- pixel_ptr++;
- }
- pixel_ptr += this->width - 2;
- }
- }
- }
- break;
-
- case 0xD:
- /* 4-color block encoding: each 4x4 block is a different color */
- CHECK_STREAM_PTR(4);
- for (yp = x; yp < (x + this->width * 8); yp += (this->width * 4)) {
- for (xp = yp; xp < (yp + 8); xp += 4) {
- color0 = this->buf[stream_ptr++];
- y0 = this->yuv_palette[color0 * 4 + 0];
- u0 = this->yuv_palette[color0 * 4 + 1];
- v0 = this->yuv_palette[color0 * 4 + 2];
-
- pixel_ptr = xp;
- for (i = 0; i < 4; i++) {
- for (j = 0; j < 4; j++) {
- this->current_frame->y[pixel_ptr] = y0;
- this->current_frame->u[pixel_ptr] = u0;
- this->current_frame->v[pixel_ptr] = v0;
- pixel_ptr++;
- }
- pixel_ptr += this->width - 4;
- }
- }
- }
- break;
-
- case 0xE:
- /* 1-color encoding: the whole block is 1 solid color */
- CHECK_STREAM_PTR(1);
- color0 = this->buf[stream_ptr++];
- y0 = this->yuv_palette[color0 * 4 + 0];
- u0 = this->yuv_palette[color0 * 4 + 1];
- v0 = this->yuv_palette[color0 * 4 + 2];
-
- pixel_ptr = x;
- for (i = 0; i < 8; i++) {
- for (j = 0; j < 8; j++) {
- this->current_frame->y[pixel_ptr] = y0;
- this->current_frame->u[pixel_ptr] = u0;
- this->current_frame->v[pixel_ptr] = v0;
- pixel_ptr++;
- }
- pixel_ptr += row_inc;
- }
- break;
-
- case 0xF:
- /* dithered encoding */
- CHECK_STREAM_PTR(2);
- color0 = this->buf[stream_ptr++];
- y0 = this->yuv_palette[color0 * 4 + 0];
- u0 = this->yuv_palette[color0 * 4 + 1];
- v0 = this->yuv_palette[color0 * 4 + 2];
- color1 = this->buf[stream_ptr++];
- y1 = this->yuv_palette[color1 * 4 + 0];
- u1 = this->yuv_palette[color1 * 4 + 1];
- v1 = this->yuv_palette[color1 * 4 + 2];
-
- pixel_ptr = x;
- for (i = 0; i < 8; i++) {
- for (j = 0; j < 4; j++) {
- if (i & 1) {
- this->current_frame->y[pixel_ptr] = y1;
- this->current_frame->u[pixel_ptr] = u1;
- this->current_frame->v[pixel_ptr] = v1;
- pixel_ptr++;
- this->current_frame->y[pixel_ptr] = y0;
- this->current_frame->u[pixel_ptr] = u0;
- this->current_frame->v[pixel_ptr] = v0;
- pixel_ptr++;
- } else {
- this->current_frame->y[pixel_ptr] = y0;
- this->current_frame->u[pixel_ptr] = u0;
- this->current_frame->v[pixel_ptr] = v0;
- pixel_ptr++;
- this->current_frame->y[pixel_ptr] = y1;
- this->current_frame->u[pixel_ptr] = u1;
- this->current_frame->v[pixel_ptr] = v1;
- pixel_ptr++;
- }
- }
- pixel_ptr += row_inc;
- }
- break;
-
- }
- }
- }
-
- /* on the way out, make sure all the video data bytes were consumed */
- if (stream_ptr != this->size)
- xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG,
- "Interplay video warning: Finished decode with bytes left over (%d < %d)\n",
- stream_ptr, this->size);
-
- debug_interplay ("code counts:\n");
- for (i = 0; i < 16; i++)
- debug_interplay (" code %X: %d\n", i, code_counts[i]);
-}
-
-/**************************************************************************
- * xine video plugin functions
- *************************************************************************/
-
-/*
- * This function receives a buffer of data from the demuxer layer and
- * figures out how to handle it based on its header flags.
- */
-static void interplay_decode_data (video_decoder_t *this_gen,
- buf_element_t *buf) {
-
- interplay_decoder_t *this = (interplay_decoder_t *) this_gen;
- palette_entry_t *palette;
- int i;
-
- vo_frame_t *img; /* video out frame */
-
- /* a video decoder does not care about this flag (?) */
- if (buf->decoder_flags & BUF_FLAG_PREVIEW)
- return;
-
- /* load the palette */
- if ((buf->decoder_flags & BUF_FLAG_SPECIAL) &&
- (buf->decoder_info[1] == BUF_SPECIAL_PALETTE)) {
- palette = (palette_entry_t *)buf->decoder_info_ptr[2];
- for (i = 0; i < buf->decoder_info[2]; i++) {
- this->yuv_palette[i * 4 + 0] =
- COMPUTE_Y(palette[i].r, palette[i].g, palette[i].b);
- this->yuv_palette[i * 4 + 1] =
- COMPUTE_U(palette[i].r, palette[i].g, palette[i].b);
- this->yuv_palette[i * 4 + 2] =
- COMPUTE_V(palette[i].r, palette[i].g, palette[i].b);
- }
- }
-
- if (buf->decoder_flags & BUF_FLAG_FRAMERATE) {
- this->video_step = buf->decoder_info[0];
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION, this->video_step);
- }
-
- if (buf->decoder_flags & BUF_FLAG_STDHEADER) { /* need to initialize */
- this->stream->video_out->open (this->stream->video_out, this->stream);
-
- if(this->buf)
- free(this->buf);
-
- this->width = (buf->content[0] << 8) | buf->content[1];
- this->height = (buf->content[2] << 8) | buf->content[3];
- this->ratio = (double)this->width/(double)this->height;
-
- if (this->buf)
- free (this->buf);
- this->bufsize = VIDEOBUFSIZE;
- this->buf = malloc(this->bufsize);
- this->size = 0;
-
- /* the decode map consists of 4 bits for every 8x8 video block, or
- * 1 byte for every 2 blocks (128 pixels) */
- this->decode_map = xine_xmalloc(this->width * this->height / 128);
- this->decode_map_index = 0;
-
- init_yuv_planes(&this->yuv_planes1, this->width, this->height);
- init_yuv_planes(&this->yuv_planes2, this->width, this->height);
- this->current_planes = 1;
-
- /* take this opportunity to load the stream/meta info */
- _x_meta_info_set(this->stream, XINE_META_INFO_VIDEOCODEC,
- "Interplay MVE Video");
-
- this->decoder_ok = 1;
-
- return;
- } else if (this->decoder_ok) {
-
- /* check if the decoder map is being sent (keyframe flag is cleared */
- if ((buf->decoder_flags & BUF_FLAG_KEYFRAME) == 0) {
- xine_fast_memcpy (&this->decode_map[this->decode_map_index],
- buf->content, buf->size);
- return;
- }
-
- if (this->size + buf->size > this->bufsize) {
- this->bufsize = this->size + 2 * buf->size;
- this->buf = realloc (this->buf, this->bufsize);
- }
-
- xine_fast_memcpy (&this->buf[this->size], buf->content, buf->size);
-
- this->size += buf->size;
-
- if (buf->decoder_flags & BUF_FLAG_FRAME_END) {
-
- img = this->stream->video_out->get_frame (this->stream->video_out,
- this->width, this->height,
- this->ratio,
- XINE_IMGFMT_YUY2, VO_BOTH_FIELDS);
-
- img->duration = this->video_step;
- img->pts = buf->pts;
- img->bad_frame = 0;
-
- if (this->current_planes == 1) {
- this->current_planes = 2;
- this->current_frame = &this->yuv_planes1;
- this->previous_frame = &this->yuv_planes2;
- } else {
- this->current_planes = 1;
- this->current_frame = &this->yuv_planes2;
- this->previous_frame = &this->yuv_planes1;
- }
-
- interplay_decode_frame (this);
- yuv444_to_yuy2(this->current_frame, img->base[0], img->pitches[0]);
-
- img->draw(img, this->stream);
- img->free(img);
-
- this->size = this->decode_map_index = 0;
- }
- }
-}
-
-/*
- * This function is called when xine needs to flush the system.
- */
-static void interplay_flush (video_decoder_t *this_gen) {
-}
-
-/*
- * This function resets the video decoder.
- */
-static void interplay_reset (video_decoder_t *this_gen) {
- interplay_decoder_t *this = (interplay_decoder_t *) this_gen;
-
- this->size = 0;
-}
-
-/*
- * The decoder should forget any stored pts values here.
- */
-static void interplay_discontinuity (video_decoder_t *this_gen) {
-}
-
-/*
- * This function frees the video decoder instance allocated to the decoder.
- */
-static void interplay_dispose (video_decoder_t *this_gen) {
-
- interplay_decoder_t *this = (interplay_decoder_t *) this_gen;
-
- if (this->buf) {
- free (this->buf);
- this->buf = NULL;
- }
-
- if (this->decode_map) {
- free (this->decode_map);
- this->decode_map = NULL;
- }
-
- free_yuv_planes(&this->yuv_planes1);
- free_yuv_planes(&this->yuv_planes2);
-
- if (this->decoder_ok) {
- this->decoder_ok = 0;
- this->stream->video_out->close(this->stream->video_out, this->stream);
- }
-
- free (this_gen);
-}
-
-/*
- * This function allocates, initializes, and returns a private video
- * decoder structure.
- */
-static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stream_t *stream) {
-
- interplay_decoder_t *this ;
-
- this = (interplay_decoder_t *) xine_xmalloc (sizeof (interplay_decoder_t));
-
- this->video_decoder.decode_data = interplay_decode_data;
- this->video_decoder.flush = interplay_flush;
- this->video_decoder.reset = interplay_reset;
- this->video_decoder.discontinuity = interplay_discontinuity;
- this->video_decoder.dispose = interplay_dispose;
- this->size = 0;
-
- this->stream = stream;
- this->class = (interplay_class_t *) class_gen;
-
- this->decoder_ok = 0;
- this->buf = NULL;
-
- return &this->video_decoder;
-}
-
-/*
- * This function returns a brief string that describes (usually with the
- * decoder's most basic name) the video decoder plugin.
- */
-static char *get_identifier (video_decoder_class_t *this) {
- return "Interplay MVE Video";
-}
-
-/*
- * This function returns a slightly longer string describing the video
- * decoder plugin.
- */
-static char *get_description (video_decoder_class_t *this) {
- return "Interplay MVE File video decoder plugin";
-}
-
-/*
- * This function frees the video decoder class and any other memory that was
- * allocated.
- */
-static void dispose_class (video_decoder_class_t *this) {
- free (this);
-}
-
-/*
- * This function allocates a private video decoder class and initializes
- * the class's member functions.
- */
-static void *init_plugin (xine_t *xine, void *data) {
-
- interplay_class_t *this;
-
- this = (interplay_class_t *) xine_xmalloc (sizeof (interplay_class_t));
-
- this->decoder_class.open_plugin = open_plugin;
- this->decoder_class.get_identifier = get_identifier;
- this->decoder_class.get_description = get_description;
- this->decoder_class.dispose = dispose_class;
-
- return this;
-}
-
-/*
- * This is a list of all of the internal xine video buffer types that
- * this decoder is able to handle. Check src/xine-engine/buffer.h for a
- * list of valid buffer types (and add a new one if the one you need does
- * not exist). Terminate the list with a 0.
- */
-static uint32_t video_types[] = {
- BUF_VIDEO_INTERPLAY,
- 0
-};
-
-/*
- * This data structure combines the list of supported xine buffer types and
- * the priority that the plugin should be given with respect to other
- * plugins that handle the same buffer type. A plugin with priority (n+1)
- * will be used instead of a plugin with priority (n).
- */
-static decoder_info_t dec_info_video = {
- video_types, /* supported types */
- 5 /* priority */
-};
-
-/*
- * The plugin catalog entry. This is the only information that this plugin
- * will export to the public.
- */
-plugin_info_t xine_plugin_info[] = {
- /* { type, API, "name", version, special_info, init_function } */
- { PLUGIN_VIDEO_DECODER, 18, "interplay", XINE_VERSION_CODE, &dec_info_video, init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
diff --git a/src/libxinevdec/msrle.c b/src/libxinevdec/msrle.c
deleted file mode 100644
index ded2ed56a..000000000
--- a/src/libxinevdec/msrle.c
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * Copyright (C) 2000-2003 the xine project
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * MS RLE Decoder by Mike Melanson (melanson@pcisys.net)
- * For more information on the MS RLE format, visit:
- * http://www.pcisys.net/~melanson/codecs/
- *
- * $Id: msrle.c,v 1.26 2004/02/09 22:04:11 jstembridge Exp $
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "xine_internal.h"
-#include "video_out.h"
-#include "buffer.h"
-#include "xineutils.h"
-#include "bswap.h"
-
-#define VIDEOBUFSIZE 128*1024
-
-typedef struct {
- video_decoder_class_t decoder_class;
-} msrle_class_t;
-
-typedef struct msrle_decoder_s {
- video_decoder_t video_decoder; /* parent video decoder structure */
-
- msrle_class_t *class;
- xine_stream_t *stream;
-
- /* these are traditional variables in a video decoder object */
- uint64_t video_step; /* frame duration in pts units */
- int decoder_ok; /* current decoder status */
- int skipframes;
-
- unsigned char *buf; /* the accumulated buffer data */
- int bufsize; /* the maximum size of buf */
- int size; /* the current size of buf */
-
- int width; /* the width of a video frame */
- int height; /* the height of a video frame */
- double ratio; /* the width to height ratio */
-
- unsigned char yuv_palette[256 * 4];
- yuv_planes_t yuv_planes;
-
-} msrle_decoder_t;
-
-/**************************************************************************
- * MS RLE specific decode functions
- *************************************************************************/
-
-#define FETCH_NEXT_STREAM_BYTE() \
- if (stream_ptr >= this->size) \
- { \
- printf(_("MS RLE: stream ptr just went out of bounds (1)\n")); \
- return; \
- } \
- stream_byte = this->buf[stream_ptr++];
-
-static void decode_msrle8(msrle_decoder_t *this) {
-
- int stream_ptr = 0;
- unsigned char rle_code;
- unsigned char extra_byte;
- unsigned char stream_byte;
- int pixel_ptr = 0;
- int row_dec = this->yuv_planes.row_width;
- int row_ptr = (this->height - 1) * row_dec;
- int frame_size = this->yuv_planes.row_width * this->height;
- unsigned char y, u, v;
-
- while (row_ptr >= 0) {
- FETCH_NEXT_STREAM_BYTE();
- rle_code = stream_byte;
- if (rle_code == 0) {
- /* fetch the next byte to see how to handle escape code */
- FETCH_NEXT_STREAM_BYTE();
- if (stream_byte == 0) {
- /* line is done, goto the next one */
- row_ptr -= row_dec;
- pixel_ptr = 0;
- } else if (stream_byte == 1) {
- /* decode is done */
- return;
- } else if (stream_byte == 2) {
- /* reposition frame decode coordinates */
- FETCH_NEXT_STREAM_BYTE();
- pixel_ptr += stream_byte;
- FETCH_NEXT_STREAM_BYTE();
- row_ptr -= stream_byte * row_dec;
- } else {
- /* copy pixels from encoded stream */
- if ((row_ptr + pixel_ptr + stream_byte > frame_size) ||
- (row_ptr < 0)) {
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "MS RLE: frame ptr just went out of bounds (1)\n");
- return;
- }
-
- rle_code = stream_byte;
- extra_byte = stream_byte & 0x01;
- if (stream_ptr + rle_code + extra_byte > this->size) {
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "MS RLE: stream ptr just went out of bounds (2)\n");
- return;
- }
-
- while (rle_code--) {
- FETCH_NEXT_STREAM_BYTE();
- y = this->yuv_palette[stream_byte * 4 + 0];
- u = this->yuv_palette[stream_byte * 4 + 1];
- v = this->yuv_palette[stream_byte * 4 + 2];
- this->yuv_planes.y[row_ptr + pixel_ptr] = y;
- this->yuv_planes.u[row_ptr + pixel_ptr] = u;
- this->yuv_planes.v[row_ptr + pixel_ptr] = v;
- pixel_ptr++;
- }
-
- /* if the RLE code is odd, skip a byte in the stream */
- if (extra_byte)
- stream_ptr++;
- }
- } else {
- /* decode a run of data */
- if ((row_ptr + pixel_ptr + stream_byte > frame_size) ||
- (row_ptr < 0)) {
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "MS RLE: frame ptr just went out of bounds (2)\n");
- return;
- }
-
- FETCH_NEXT_STREAM_BYTE();
-
- y = this->yuv_palette[stream_byte * 4 + 0];
- u = this->yuv_palette[stream_byte * 4 + 1];
- v = this->yuv_palette[stream_byte * 4 + 2];
-
- while(rle_code--) {
- this->yuv_planes.y[row_ptr + pixel_ptr] = y;
- this->yuv_planes.u[row_ptr + pixel_ptr] = u;
- this->yuv_planes.v[row_ptr + pixel_ptr] = v;
- pixel_ptr++;
- }
- }
- }
-
- /* one last sanity check on the way out */
- if (stream_ptr < this->size)
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "MS RLE: ended frame decode with bytes left over (%d < %d)\n",
- stream_ptr, this->size);
-}
-
-/**************************************************************************
- * xine video plugin functions
- *************************************************************************/
-
-/*
- * This function receives a buffer of data from the demuxer layer and
- * figures out how to handle it based on its header flags.
- */
-static void msrle_decode_data (video_decoder_t *this_gen,
- buf_element_t *buf) {
-
- msrle_decoder_t *this = (msrle_decoder_t *) this_gen;
- xine_bmiheader *bih;
- palette_entry_t *palette;
- int i;
- vo_frame_t *img; /* video out frame */
-
- /* a video decoder does not care about this flag (?) */
- if (buf->decoder_flags & BUF_FLAG_PREVIEW)
- return;
-
- /* load the palette */
- if ((buf->decoder_flags & BUF_FLAG_SPECIAL) &&
- (buf->decoder_info[1] == BUF_SPECIAL_PALETTE)) {
- palette = (palette_entry_t *)buf->decoder_info_ptr[2];
- for (i = 0; i < buf->decoder_info[2]; i++) {
- this->yuv_palette[i * 4 + 0] =
- COMPUTE_Y(palette[i].r, palette[i].g, palette[i].b);
- this->yuv_palette[i * 4 + 1] =
- COMPUTE_U(palette[i].r, palette[i].g, palette[i].b);
- this->yuv_palette[i * 4 + 2] =
- COMPUTE_V(palette[i].r, palette[i].g, palette[i].b);
- }
- }
-
- if (buf->decoder_flags & BUF_FLAG_FRAMERATE) {
- this->video_step = buf->decoder_info[0];
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION, this->video_step);
- }
-
- if (buf->decoder_flags & BUF_FLAG_STDHEADER) { /* need to initialize */
- this->stream->video_out->open (this->stream->video_out, this->stream);
-
- if(this->buf)
- free(this->buf);
-
- bih = (xine_bmiheader *) buf->content;
- this->width = (bih->biWidth + 3) & ~0x03;
- this->height = (bih->biHeight + 3) & ~0x03;
- this->ratio = (double)this->width/(double)this->height;
-
- if (this->buf)
- free (this->buf);
- this->bufsize = VIDEOBUFSIZE;
- this->buf = malloc(this->bufsize);
- this->size = 0;
-
- init_yuv_planes(&this->yuv_planes, this->width, this->height);
-
- this->stream->video_out->open (this->stream->video_out, this->stream);
- this->decoder_ok = 1;
-
- /* load the stream/meta info */
- _x_meta_info_set(this->stream, XINE_META_INFO_VIDEOCODEC, "Microsoft RLE");
-
- return;
- } else if (this->decoder_ok) {
-
- if (this->size + buf->size > this->bufsize) {
- this->bufsize = this->size + 2 * buf->size;
- this->buf = realloc (this->buf, this->bufsize);
- }
-
- xine_fast_memcpy (&this->buf[this->size], buf->content, buf->size);
-
- this->size += buf->size;
-
- if (buf->decoder_flags & BUF_FLAG_FRAME_END) {
-
- img = this->stream->video_out->get_frame (this->stream->video_out,
- this->width, this->height,
- this->ratio, XINE_IMGFMT_YUY2, VO_BOTH_FIELDS);
-
- img->duration = this->video_step;
- img->pts = buf->pts;
- img->bad_frame = 0;
-
- decode_msrle8(this);
- yuv444_to_yuy2(&this->yuv_planes, img->base[0], img->pitches[0]);
-
- img->draw(img, this->stream);
- img->free(img);
-
- this->size = 0;
- }
- }
-}
-
-/*
- * This function is called when xine needs to flush the system. Not
- * sure when or if this is used or even if it needs to do anything.
- */
-static void msrle_flush (video_decoder_t *this_gen) {
-}
-
-/*
- * This function resets the video decoder.
- */
-static void msrle_reset (video_decoder_t *this_gen) {
- msrle_decoder_t *this = (msrle_decoder_t *) this_gen;
-
- this->size = 0;
-}
-
-static void msrle_discontinuity (video_decoder_t *this_gen) {
-}
-
-/*
- * This function frees the video decoder instance allocated to the decoder.
- */
-static void msrle_dispose (video_decoder_t *this_gen) {
- msrle_decoder_t *this = (msrle_decoder_t *) this_gen;
-
- if (this->buf) {
- free (this->buf);
- this->buf = NULL;
- }
-
- if (this->decoder_ok) {
- this->decoder_ok = 0;
- this->stream->video_out->close(this->stream->video_out, this->stream);
- }
-
- free (this_gen);
-}
-
-static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stream_t *stream) {
-
- msrle_decoder_t *this ;
-
- this = (msrle_decoder_t *) xine_xmalloc (sizeof (msrle_decoder_t));
-
- this->video_decoder.decode_data = msrle_decode_data;
- this->video_decoder.flush = msrle_flush;
- this->video_decoder.reset = msrle_reset;
- this->video_decoder.discontinuity = msrle_discontinuity;
- this->video_decoder.dispose = msrle_dispose;
- this->size = 0;
-
- this->stream = stream;
- this->class = (msrle_class_t *) class_gen;
-
- this->decoder_ok = 0;
- this->buf = NULL;
-
- return &this->video_decoder;
-}
-
-static char *get_identifier (video_decoder_class_t *this) {
- return "MS RLE";
-}
-
-static char *get_description (video_decoder_class_t *this) {
- return "Microsoft RLE video decoder plugin";
-}
-
-static void dispose_class (video_decoder_class_t *this) {
- free (this);
-}
-
-static void *init_plugin (xine_t *xine, void *data) {
-
- msrle_class_t *this;
-
- this = (msrle_class_t *) xine_xmalloc (sizeof (msrle_class_t));
-
- this->decoder_class.open_plugin = open_plugin;
- this->decoder_class.get_identifier = get_identifier;
- this->decoder_class.get_description = get_description;
- this->decoder_class.dispose = dispose_class;
-
- return this;
-}
-
-/*
- * exported plugin catalog entry
- */
-
-static uint32_t video_types[] = {
- BUF_VIDEO_MSRLE,
- 0
- };
-
-static decoder_info_t dec_info_video = {
- video_types, /* supported types */
- 1 /* priority */
-};
-
-plugin_info_t xine_plugin_info[] = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_VIDEO_DECODER, 18, "msrle", XINE_VERSION_CODE, &dec_info_video, init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
diff --git a/src/libxinevdec/msvc.c b/src/libxinevdec/msvc.c
deleted file mode 100644
index a2be6dbc0..000000000
--- a/src/libxinevdec/msvc.c
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- * Copyright (C) 2002-2003 the xine project
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * by Ewald Snel <ewald@rambo.its.tudelft.nl>
- *
- * based on overview of Microsoft Video-1 algorithm
- * by Mike Melanson: http://www.pcisys.net/~melanson/codecs/video1.txt
- *
- * $Id: msvc.c,v 1.30 2004/02/09 22:04:11 jstembridge Exp $
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "xine_internal.h"
-#include "video_out.h"
-#include "buffer.h"
-#include "bswap.h"
-#include "xineutils.h"
-
-#define VIDEOBUFSIZE 128 * 1024
-
-typedef struct {
- uint16_t yu;
- uint16_t yv;
-} yuy2_t;
-
-typedef struct {
- video_decoder_class_t decoder_class;
-} msvc_class_t;
-
-typedef struct msvc_decoder_s {
- video_decoder_t video_decoder;
-
- msvc_class_t *class;
- xine_stream_t *stream;
-
- int64_t video_step;
- int decoder_ok;
-
- unsigned char *buf;
- int bufsize;
- int size;
-
- unsigned int coded_width;
- unsigned int coded_height;
- int pitch;
- int depth;
- uint8_t *current;
- yuy2_t color_table[256];
-
- unsigned int width;
- unsigned int height;
- double ratio;
-} msvc_decoder_t;
-
-/* taken from libw32dll */
-#define MAXSAMPLE 255
-#define CENTERSAMPLE 128
-
-#define SCALEBITS 16
-#define FIX(x) ( (int32_t) ( (x) * (1<<SCALEBITS) + 0.5 ) )
-#define ONE_HALF ( (int32_t) (1<< (SCALEBITS-1)) )
-#define CBCR_OFFSET (CENTERSAMPLE << SCALEBITS)
-
-static inline void rgb_to_yuy2 (const int bits, uint32_t rgb, yuy2_t *c) {
- uint8_t r, g, b;
- uint8_t y, u, v;
-
- if (bits == 15) {
- b = (rgb & 0x001F) << 3;
- g = (rgb & 0x03E0) >> 5 << 3;
- r = (rgb & 0x7C00) >> 10 << 3;
- } else {
- b = (rgb & 0x0000FF);
- g = (rgb & 0x00FF00) >> 8;
- r = (rgb & 0xFF0000) >> 16;
- }
-
- y = (FIX(0.299) * r + FIX(0.587) * g + FIX(0.114) * b + ONE_HALF) >> SCALEBITS;
- u = (- FIX(0.16874) * r - FIX(0.33126) * g + FIX(0.5) * b + CBCR_OFFSET + ONE_HALF-1) >> SCALEBITS;
- v = (FIX(0.5) * r - FIX(0.41869) * g - FIX(0.08131) * b + CBCR_OFFSET + ONE_HALF-1) >> SCALEBITS;
-
- c->yu = le2me_16 (y | (u << 8));
- c->yv = le2me_16 (y | (v << 8));
-}
-
-static int msvc_decode_frame (msvc_decoder_t *this, uint8_t *data, int size) {
- uint8_t *eod = (data + size);
- uint32_t ctrl, clr8, skip;
- int x, y, i, j;
- uint16_t *out[4];
- yuy2_t c[2];
-
- skip = 0;
-
- for (y=(this->coded_height - 4); y >= 0; y-=4) {
-
- out[0] = (uint16_t *) &this->current[y * this->pitch];
- out[1] = (uint16_t *) (((uint8_t *) out[0]) + this->pitch);
- out[2] = (uint16_t *) (((uint8_t *) out[1]) + this->pitch);
- out[3] = (uint16_t *) (((uint8_t *) out[2]) + this->pitch);
-
- for (x=0; x < this->coded_width; x+=4) {
- if (skip == 0 || --skip == 0) {
- if ((data + 2) >= eod)
- return 0;
-
- ctrl = LE_16 (data);
- data += 2;
-
- if ((ctrl & ((this->depth == 8) ? 0xF000 : 0x8000)) == 0x8000) {
- if ((ctrl & ~0x3FF) == 0x8400) {
- skip = (ctrl & 0x3FF);
- } else {
- if (this->depth == 8)
- c[0] = this->color_table[(ctrl & 0xFF)];
- else
- rgb_to_yuy2 (15, ctrl, &c[0]);
-
- for (i=0; i < 4; i++) {
- out[i][0] = c[0].yu;
- out[i][1] = c[0].yv;
- out[i][2] = c[0].yu;
- out[i][3] = c[0].yv;
- }
- }
- } else {
- if (this->depth == 8) {
- if ((data + 2) >= eod)
- return -1;
-
- c[1] = this->color_table[data[0]];
- c[0] = this->color_table[data[1]];
- clr8 = (ctrl >= 0x9000);
- data += 2;
- } else {
- if ((data + 4) >= eod)
- return -1;
-
- rgb_to_yuy2 (15, LE_16 (&data[0]), &c[1]);
- rgb_to_yuy2 (15, LE_16 (&data[2]), &c[0]);
- clr8 = (data[1] & 0x80);
- data += 4;
- }
-
- for (i=0; i < 4; i+=2) {
- for (j=0; j < 4; j+=2) {
- out[3-i][j] = c[(ctrl & 1) ].yu;
- out[3-i][j+1] = c[(ctrl & 2) >> 1].yv;
- out[2-i][j] = c[(ctrl & 16)>> 4].yu;
- out[2-i][j+1] = c[(ctrl & 32)>> 5].yv;
- ctrl >>= 2;
-
- if (clr8 && !(i & j)) {
- if (this->depth == 8) {
- if ((data + 2) >= eod)
- return -1;
-
- c[1] = this->color_table[data[0]];
- c[0] = this->color_table[data[1]];
- data += 2;
- } else {
- if ((data + 4) >= eod)
- return -1;
-
- rgb_to_yuy2 (15, LE_16 (&data[0]), &c[1]);
- rgb_to_yuy2 (15, LE_16 (&data[2]), &c[0]);
- data += 4;
- }
- }
- }
-
- ctrl >>= 4;
- }
- }
- }
-
- out[0] += 4;
- out[1] += 4;
- out[2] += 4;
- out[3] += 4;
- }
- }
-
- return 0;
-}
-
-static void msvc_decode_data (video_decoder_t *this_gen, buf_element_t *buf) {
- msvc_decoder_t *this = (msvc_decoder_t *) this_gen;
-
- int i;
- palette_entry_t *palette;
-
- if (buf->decoder_flags & BUF_FLAG_PREVIEW)
- return;
-
- if ((buf->decoder_flags & BUF_FLAG_SPECIAL) &&
- (buf->decoder_info[1] == BUF_SPECIAL_PALETTE)) {
- palette = (palette_entry_t *)buf->decoder_info_ptr[2];
- for (i = 0; i < buf->decoder_info[2]; i++)
- rgb_to_yuy2(
- 32,
- (palette[i].r << 16) |
- (palette[i].g << 8) |
- (palette[i].b << 0),
- &this->color_table[i]);
- }
-
- if (buf->decoder_flags & BUF_FLAG_FRAMERATE) {
- this->video_step = buf->decoder_info[0];
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION, this->video_step);
- }
-
- if (buf->decoder_flags & BUF_FLAG_STDHEADER) {
- xine_bmiheader *bih;
- int image_size;
-
- bih = (xine_bmiheader *) buf->content;
-
- this->width = (bih->biWidth + 1) & ~0x1;
- this->height = bih->biHeight;
- this->ratio = (double)this->width/(double)this->height;
- this->coded_width = (this->width + 3) & ~0x3;
- this->coded_height = (this->height + 3) & ~0x3;
- this->pitch = 2*this->coded_width;
- this->depth = bih->biBitCount;
-
- if (this->depth != 8 && this->depth != 16) {
- fprintf (stderr, "Unsupported bit depth (%d)\n", this->depth);
- return;
- }
-
- image_size = (this->pitch * this->coded_height);
- this->current = (uint8_t *) realloc (this->current, image_size);
-
- if (this->buf)
- free (this->buf);
- this->bufsize = VIDEOBUFSIZE;
- this->buf = malloc(this->bufsize);
- this->size = 0;
-
- this->stream->video_out->open (this->stream->video_out, this->stream);
- this->decoder_ok = 1;
-
- /* load the stream/meta info */
- _x_meta_info_set(this->stream, XINE_META_INFO_VIDEOCODEC, "Microsoft Video-1");
-
- } else if (this->decoder_ok && !(buf->decoder_flags & BUF_FLAG_SPECIAL)) {
-
- if (this->size + buf->size > this->bufsize) {
- this->bufsize = this->size + 2 * buf->size;
- this->buf = realloc (this->buf, this->bufsize);
- }
-
- xine_fast_memcpy (&this->buf[this->size], buf->content, buf->size);
-
- this->size += buf->size;
-
- if (buf->decoder_flags & BUF_FLAG_FRAME_END) {
-
- vo_frame_t *img;
- int result;
-
- result = msvc_decode_frame (this, this->buf, this->size);
-
- img = this->stream->video_out->get_frame (this->stream->video_out,
- this->width, this->height,
- this->ratio,
- XINE_IMGFMT_YUY2, VO_BOTH_FIELDS);
-
- img->duration = this->video_step;
- img->pts = buf->pts;
- img->bad_frame = (result != 0);
-
- if (this->pitch == img->pitches[0]) {
- xine_fast_memcpy (img->base[0], this->current, img->pitches[0]*this->height);
- } else {
- uint8_t *src, *dst;
-
- src = (uint8_t *) this->current;
- dst = img->base[0];
-
- for (i=0; i < this->height; i++) {
- xine_fast_memcpy (dst, src, 2*this->width);
- src += this->pitch;
- dst += img->pitches[0];
- }
- }
-
- img->draw(img, this->stream);
- img->free(img);
-
- this->size = 0;
- }
- }
-}
-
-static void msvc_flush (video_decoder_t *this_gen) {
-}
-
-static void msvc_reset (video_decoder_t *this_gen) {
- msvc_decoder_t *this = (msvc_decoder_t *) this_gen;
-
- this->size = 0;
-}
-
-static void msvc_discontinuity (video_decoder_t *this_gen) {
-}
-
-static void msvc_dispose (video_decoder_t *this_gen) {
-
- msvc_decoder_t *this = (msvc_decoder_t *) this_gen;
-
- if (this->current) {
- free (this->current);
- this->current = NULL;
- }
-
- if (this->buf) {
- free (this->buf);
- this->buf = NULL;
- }
-
- if (this->decoder_ok) {
- this->decoder_ok = 0;
- this->stream->video_out->close(this->stream->video_out, this->stream);
- }
-
- free (this_gen);
-}
-
-static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stream_t *stream) {
-
- msvc_decoder_t *this ;
-
- this = (msvc_decoder_t *) xine_xmalloc (sizeof (msvc_decoder_t));
-
- this->video_decoder.decode_data = msvc_decode_data;
- this->video_decoder.flush = msvc_flush;
- this->video_decoder.reset = msvc_reset;
- this->video_decoder.discontinuity = msvc_discontinuity;
- this->video_decoder.dispose = msvc_dispose;
- this->size = 0;
-
- this->stream = stream;
- this->class = (msvc_class_t *) class_gen;
-
- this->decoder_ok = 0;
- this->buf = NULL;
-
- return &this->video_decoder;
-}
-
-static char *get_identifier (video_decoder_class_t *this) {
- return "MSVC";
-}
-
-static char *get_description (video_decoder_class_t *this) {
- return "Microsoft Video-1 video decoder plugin";
-}
-
-static void dispose_class (video_decoder_class_t *this) {
- free (this);
-}
-
-static void *init_plugin (xine_t *xine, void *data) {
-
- msvc_class_t *this;
-
- this = (msvc_class_t *) xine_xmalloc (sizeof (msvc_class_t));
-
- this->decoder_class.open_plugin = open_plugin;
- this->decoder_class.get_identifier = get_identifier;
- this->decoder_class.get_description = get_description;
- this->decoder_class.dispose = dispose_class;
-
- return this;
-}
-
-/*
- * exported plugin catalog entry
- */
-
-static uint32_t video_types[] = {
- BUF_VIDEO_MSVC,
- 0
- };
-
-static decoder_info_t dec_info_video = {
- video_types, /* supported types */
- 5 /* priority */
-};
-
-plugin_info_t xine_plugin_info[] = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_VIDEO_DECODER, 18, "msvc", XINE_VERSION_CODE, &dec_info_video, init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
diff --git a/src/libxinevdec/qtrle.c b/src/libxinevdec/qtrle.c
deleted file mode 100644
index 445dc71d7..000000000
--- a/src/libxinevdec/qtrle.c
+++ /dev/null
@@ -1,1040 +0,0 @@
-/*
- * Copyright (C) 2000-2003 the xine project
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * QT RLE Decoder by Mike Melanson (melanson@pcisys.net)
- * For more information on the QT RLE format, visit:
- * http://www.pcisys.net/~melanson/codecs/
- *
- * $Id: qtrle.c,v 1.20 2004/02/09 22:04:11 jstembridge Exp $
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "xine_internal.h"
-#include "video_out.h"
-#include "buffer.h"
-#include "xineutils.h"
-#include "bswap.h"
-
-#define VIDEOBUFSIZE 128*1024
-
-typedef struct {
- video_decoder_class_t decoder_class;
-} qtrle_class_t;
-
-typedef struct qtrle_decoder_s {
- video_decoder_t video_decoder; /* parent video decoder structure */
-
- qtrle_class_t *class;
- xine_stream_t *stream;
-
- /* these are traditional variables in a video decoder object */
- uint64_t video_step; /* frame duration in pts units */
- int decoder_ok; /* current decoder status */
- int skipframes;
-
- unsigned char *buf; /* the accumulated buffer data */
- int bufsize; /* the maximum size of buf */
- int size; /* the current size of buf */
-
- int width; /* the width of a video frame */
- int height; /* the height of a video frame */
- double ratio; /* the width to height ratio */
- int depth; /* color depth (bits/pixel) */
-
- unsigned char yuv_palette[256 * 4];
- yuv_planes_t yuv_planes;
-
-} qtrle_decoder_t;
-
-/**************************************************************************
- * QT RLE specific decode functions
- *************************************************************************/
-
-/* monochrome color definitions */
-#define Y_BLACK COMPUTE_Y(0x00, 0x00, 0x00)
-#define U_BLACK COMPUTE_U(0x00, 0x00, 0x00)
-#define V_BLACK COMPUTE_V(0x00, 0x00, 0x00)
-#define Y_WHITE COMPUTE_Y(0xFF, 0xFF, 0xFF)
-#define U_WHITE COMPUTE_U(0xFF, 0xFF, 0xFF)
-#define V_WHITE COMPUTE_V(0xFF, 0xFF, 0xFF)
-
-#define CHECK_STREAM_PTR(n) \
- if ((stream_ptr + n) > this->size) { \
- printf ("QT RLE problem: stream_ptr out of bounds (%d >= %d)\n", \
- stream_ptr + n, this->size); \
- return; \
- }
-
-#define CHECK_PIXEL_PTR(n) \
- if (pixel_ptr + n > pixel_limit) { \
- printf ("QT RLE problem: pixel_ptr >= pixel_limit (%d >= %d)\n", \
- pixel_ptr + n, pixel_limit); \
- return; \
- } \
-
-static void decode_qtrle_1(qtrle_decoder_t *this) {
-
- int stream_ptr;
- int header;
- int start_line;
- int lines_to_change;
- signed char rle_code;
- unsigned char skip_code;
- int row_ptr, pixel_ptr;
- int row_inc = this->width;
- unsigned char y[16], u[16], v[16];
- yuv_planes_t *yuv = &this->yuv_planes;
- int i, flags, flag_mask;
- int pixel_limit = this->width * this->height;
-
- /* check if this frame is even supposed to change */
- if (this->size < 8)
- return;
-
- /* start after the chunk size */
- stream_ptr = 4;
-
- /* fetch the header */
- CHECK_STREAM_PTR(2);
- header = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
-
- /* if a header is present, fetch additional decoding parameters */
- if (header & 0x0008) {
- CHECK_STREAM_PTR(8);
- start_line = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 4;
- lines_to_change = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 4;
- } else {
- start_line = 0;
- lines_to_change = this->height;
- }
-
- row_ptr = row_inc * start_line;
- pixel_ptr = row_ptr;
- while (lines_to_change) {
-
- CHECK_STREAM_PTR(2);
- skip_code = this->buf[stream_ptr++];
- rle_code = this->buf[stream_ptr++];
-
- /* check if decode is finished */
- if (rle_code == 0)
- return;
- if ((skip_code == 0x80) && (rle_code == 0x00))
- return;
-
- /* check if it is time to move to the next line */
- if ((skip_code == 0x80) && (rle_code == -1)) {
- row_ptr += row_inc;
- pixel_ptr = row_ptr;
- lines_to_change--;
- } else {
-
- if (skip_code >= 0x80) {
- /* skip to the next line and then skip more pixels */
- row_ptr += row_inc;
- pixel_ptr = row_ptr + ((skip_code & 0x7F) * 16);
- lines_to_change--;
- } else
- /* skip pixels on the current line */
- pixel_ptr += (skip_code * 16);
-
- if (rle_code < 0) {
- /* decode the run length code */
- rle_code = -rle_code;
-
- /* get the next 16 bits from the stream and treat them as 16
- * monochrome pixels */
- CHECK_STREAM_PTR(2);
- flags = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
- for (i = 0, flag_mask = 0x8000; i < 16; i++, flag_mask >>= 1) {
- if (flags & flag_mask) {
- y[i] = Y_WHITE;
- u[i] = U_WHITE;
- v[i] = V_WHITE;
- } else {
- y[i] = Y_BLACK;
- u[i] = U_BLACK;
- v[i] = V_BLACK;
- }
- }
- CHECK_PIXEL_PTR(rle_code * 16);
- while (rle_code--) {
- for (i = 0; i < 16; i++) {
- yuv->y[pixel_ptr] = y[i];
- yuv->u[pixel_ptr] = u[i];
- yuv->v[pixel_ptr] = v[i];
- pixel_ptr++;
- }
- }
- } else {
- /* copy pixels directly to output */
- CHECK_STREAM_PTR(rle_code * 2);
- CHECK_PIXEL_PTR(rle_code * 16);
- while (rle_code--) {
- flags = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
- for (i = 0, flag_mask = 0x8000; i < 16; i++, flag_mask >>= 1) {
- if (flags & flag_mask) {
- yuv->y[pixel_ptr] = Y_WHITE;
- yuv->u[pixel_ptr] = U_WHITE;
- yuv->v[pixel_ptr] = V_WHITE;
- } else {
- yuv->y[pixel_ptr] = Y_BLACK;
- yuv->u[pixel_ptr] = U_BLACK;
- yuv->v[pixel_ptr] = V_BLACK;
- }
- pixel_ptr++;
- }
- }
- }
- }
- }
-}
-
-static void decode_qtrle_2(qtrle_decoder_t *this) {
-
- int stream_ptr;
- int header;
- int start_line;
- int lines_to_change;
- signed char rle_code;
- unsigned char skip_code;
- int row_ptr, pixel_ptr;
- int row_inc = this->width;
- unsigned char y[16], u[16], v[16];
- yuv_planes_t *yuv = &this->yuv_planes;
- int i, shift, index, indices;
- int start_of_line = 1;
- int pixel_limit = this->width * this->height;
-
- /* check if this frame is even supposed to change */
- if (this->size < 8)
- return;
-
- /* start after the chunk size */
- stream_ptr = 4;
-
- /* fetch the header */
- CHECK_STREAM_PTR(2);
- header = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
-
- /* if a header is present, fetch additional decoding parameters */
- if (header & 0x0008) {
- CHECK_STREAM_PTR(8);
- start_line = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 4;
- lines_to_change = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 4;
- } else {
- start_line = 0;
- lines_to_change = this->height;
- }
-
- row_ptr = row_inc * start_line;
- pixel_ptr = row_ptr;
- while (lines_to_change) {
- if (start_of_line) {
- CHECK_STREAM_PTR(stream_ptr);
- skip_code = this->buf[stream_ptr++];
- if (skip_code == 0)
- return;
- skip_code--;
- start_of_line = 0;
- } else
- skip_code = 0;
-
- CHECK_STREAM_PTR(skip_code);
- rle_code = this->buf[stream_ptr++];
-
- if (rle_code == 0)
- return;
- else if (rle_code == -1) {
- /* reset to the start of next line */
- row_ptr += row_inc;
- pixel_ptr = row_ptr;
- start_of_line = 1;
- lines_to_change--;
- } else {
- if (skip_code & 0x80) {
- /* reset to the start of the next line and skip pixels */
- row_ptr += row_inc;
- pixel_ptr = row_ptr + (skip_code & 0x7F);
- lines_to_change--;
- } else {
- /* skip pixels on current line */
- pixel_ptr += skip_code;
- }
-
- if (rle_code < 0) {
- /* decode the run length code */
- rle_code = -rle_code;
-
- /* get the next 32 bits from the stream and treat them as 16
- * 2-bit indices into the palette */
- CHECK_STREAM_PTR(4);
- indices = BE_32(&this->buf[stream_ptr]);
- stream_ptr += 4;
- for (i = 0, shift = 30; i < 16; i++, shift -= 2) {
- index = (indices >> shift) & 0x03;
- y[i] = this->yuv_palette[index * 4 + 0];
- u[i] = this->yuv_palette[index * 4 + 1];
- v[i] = this->yuv_palette[index * 4 + 2];
- }
- CHECK_PIXEL_PTR(rle_code * 16);
- while (rle_code--) {
- for (i = 0; i < 16; i++) {
- yuv->y[pixel_ptr] = y[i];
- yuv->u[pixel_ptr] = u[i];
- yuv->v[pixel_ptr] = v[i];
- pixel_ptr++;
- }
- }
- } else {
- /* copy pixels directly to output */
- CHECK_STREAM_PTR(rle_code * 4);
- CHECK_PIXEL_PTR(rle_code * 16);
- while (rle_code--) {
- indices = BE_32(&this->buf[stream_ptr]);
- stream_ptr += 4;
- for (i = 0, shift = 30; i < 16; i++, shift -= 2) {
- index = (indices >> shift) & 0x03;
- yuv->y[pixel_ptr] = this->yuv_palette[index * 4 + 0];
- yuv->u[pixel_ptr] = this->yuv_palette[index * 4 + 1];
- yuv->v[pixel_ptr] = this->yuv_palette[index * 4 + 2];
- pixel_ptr++;
- }
- }
- }
- }
-
- row_ptr += row_inc;
- }
-}
-
-static void decode_qtrle_4(qtrle_decoder_t *this) {
-
- int stream_ptr;
- int header;
- int start_line;
- int lines_to_change;
- signed char rle_code;
- int row_ptr, pixel_ptr;
- int row_inc = this->width;
- unsigned char y[8], u[8], v[8];
- yuv_planes_t *yuv = &this->yuv_planes;
- int i, shift, index, indices;
- int pixel_limit = this->width * this->height;
-
- /* check if this frame is even supposed to change */
- if (this->size < 8)
- return;
-
- /* start after the chunk size */
- stream_ptr = 4;
-
- /* fetch the header */
- CHECK_STREAM_PTR(2);
- header = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
-
- /* if a header is present, fetch additional decoding parameters */
- if (header & 0x0008) {
- CHECK_STREAM_PTR(8);
- start_line = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 4;
- lines_to_change = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 4;
- } else {
- start_line = 0;
- lines_to_change = this->height;
- }
-
- row_ptr = row_inc * start_line;
- while (lines_to_change--) {
- CHECK_STREAM_PTR(2);
- pixel_ptr = row_ptr + (this->buf[stream_ptr++] - 1);
-
- while ((rle_code = (signed char)this->buf[stream_ptr++]) != -1) {
- if (rle_code == 0) {
- /* there's another skip code in the stream */
- CHECK_STREAM_PTR(1);
- pixel_ptr += (this->buf[stream_ptr++] - 1);
- } else if (rle_code < 0) {
- /* decode the run length code */
- rle_code = -rle_code;
-
- /* get the next 32 bits from the stream and treat them as 8
- * 4-bit indices into the palette */
- CHECK_STREAM_PTR(4);
- indices = BE_32(&this->buf[stream_ptr]);
- stream_ptr += 4;
- for (i = 0, shift = 28; i < 8; i++, shift -= 4) {
- index = (indices >> shift) & 0x0F;
- y[i] = this->yuv_palette[index * 4 + 0];
- u[i] = this->yuv_palette[index * 4 + 1];
- v[i] = this->yuv_palette[index * 4 + 2];
- }
- CHECK_PIXEL_PTR(rle_code * 8);
- while (rle_code--) {
- for (i = 0; i < 8; i++) {
- yuv->y[pixel_ptr] = y[i];
- yuv->u[pixel_ptr] = u[i];
- yuv->v[pixel_ptr] = v[i];
- pixel_ptr++;
- }
- }
- } else {
- /* copy pixels directly to output */
- CHECK_STREAM_PTR(rle_code * 4);
- CHECK_PIXEL_PTR(rle_code * 8);
- while (rle_code--) {
- indices = BE_32(&this->buf[stream_ptr]);
- stream_ptr += 4;
- for (i = 0, shift = 28; i < 8; i++, shift -= 4) {
- index = (indices >> shift) & 0x0F;
- yuv->y[pixel_ptr] = this->yuv_palette[index * 4 + 0];
- yuv->u[pixel_ptr] = this->yuv_palette[index * 4 + 1];
- yuv->v[pixel_ptr] = this->yuv_palette[index * 4 + 2];
- pixel_ptr++;
- }
- }
- }
- }
-
- row_ptr += row_inc;
- }
-}
-
-static void decode_qtrle_8(qtrle_decoder_t *this) {
-
- int stream_ptr;
- int header;
- int start_line;
- int lines_to_change;
- signed char rle_code;
- int row_ptr, pixel_ptr;
- int row_inc = this->width;
- unsigned char y[4], u[4], v[4];
- yuv_planes_t *yuv = &this->yuv_planes;
- int i;
- int pixel_limit = this->width * this->height;
-
- /* check if this frame is even supposed to change */
- if (this->size < 8)
- return;
-
- /* start after the chunk size */
- stream_ptr = 4;
-
- /* fetch the header */
- CHECK_STREAM_PTR(2);
- header = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
-
- /* if a header is present, fetch additional decoding parameters */
- if (header & 0x0008) {
- CHECK_STREAM_PTR(8);
- start_line = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 4;
- lines_to_change = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 4;
- } else {
- start_line = 0;
- lines_to_change = this->height;
- }
-
- row_ptr = row_inc * start_line;
- while (lines_to_change--) {
- CHECK_STREAM_PTR(2);
- pixel_ptr = row_ptr + (4 * (this->buf[stream_ptr++] - 1));
-
- while ((rle_code = (signed char)this->buf[stream_ptr++]) != -1) {
- if (rle_code == 0) {
- /* there's another skip code in the stream */
- pixel_ptr += (4 * (this->buf[stream_ptr++] - 1));
- CHECK_STREAM_PTR(1);
- } else if (rle_code < 0) {
- /* decode the run length code */
- rle_code = -rle_code;
- /* get the next 4 bytes from the stream, treat them as palette
- * indices, and output them to the rle_code times */
- CHECK_STREAM_PTR(4);
- for (i = 0; i < 4; i++) {
- y[i] = this->yuv_palette[this->buf[stream_ptr] * 4 + 0];
- u[i] = this->yuv_palette[this->buf[stream_ptr] * 4 + 1];
- v[i] = this->yuv_palette[this->buf[stream_ptr] * 4 + 2];
- stream_ptr++;
- }
- CHECK_PIXEL_PTR(rle_code * 4);
- while (rle_code--) {
- for (i = 0; i < 4; i++) {
- yuv->y[pixel_ptr] = y[i];
- yuv->u[pixel_ptr] = u[i];
- yuv->v[pixel_ptr] = v[i];
- pixel_ptr++;
- }
- }
- } else {
- CHECK_STREAM_PTR(rle_code);
- CHECK_PIXEL_PTR(rle_code);
-
- /* copy pixels directly to output */
- while (rle_code--) {
- for (i = 0; i < 4; i++) {
- yuv->y[pixel_ptr] =
- this->yuv_palette[this->buf[stream_ptr] * 4 + 0];
- yuv->u[pixel_ptr] =
- this->yuv_palette[this->buf[stream_ptr] * 4 + 1];
- yuv->v[pixel_ptr] =
- this->yuv_palette[this->buf[stream_ptr] * 4 + 2];
- stream_ptr++;
- pixel_ptr++;
- }
- }
- }
- }
-
- row_ptr += row_inc;
- }
-}
-
-static void decode_qtrle_16(qtrle_decoder_t *this) {
-
- int stream_ptr;
- int header;
- int start_line;
- int lines_to_change;
- signed char rle_code;
- int row_ptr, pixel_ptr;
- int row_inc = this->width;
- unsigned char r, g, b;
- unsigned char y, u, v;
- unsigned short packed_pixel;
- yuv_planes_t *yuv = &this->yuv_planes;
- int pixel_limit = this->width * this->height;
-
- /* check if this frame is even supposed to change */
- if (this->size < 8)
- return;
-
- /* start after the chunk size */
- stream_ptr = 4;
-
- /* fetch the header */
- CHECK_STREAM_PTR(2);
- header = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
-
- /* if a header is present, fetch additional decoding parameters */
- if (header & 0x0008) {
- CHECK_STREAM_PTR(8);
- start_line = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 4;
- lines_to_change = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 4;
- } else {
- start_line = 0;
- lines_to_change = this->height;
- }
-
- row_ptr = row_inc * start_line;
- while (lines_to_change--) {
- CHECK_STREAM_PTR(2);
- pixel_ptr = row_ptr + (this->buf[stream_ptr++] - 1);
-
- while ((rle_code = (signed char)this->buf[stream_ptr++]) != -1) {
- if (rle_code == 0) {
- /* there's another skip code in the stream */
- CHECK_STREAM_PTR(1);
- pixel_ptr += (this->buf[stream_ptr++] - 1);
- }
- else if (rle_code < 0) {
- /* decode the run length code */
- rle_code = -rle_code;
- CHECK_STREAM_PTR(2);
- packed_pixel = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
- UNPACK_RGB15(packed_pixel, r, g, b);
- y = COMPUTE_Y(r, g, b);
- u = COMPUTE_U(r, g, b);
- v = COMPUTE_V(r, g, b);
-
- CHECK_PIXEL_PTR(rle_code);
-
- while (rle_code--) {
- yuv->y[pixel_ptr] = y;
- yuv->u[pixel_ptr] = u;
- yuv->v[pixel_ptr] = v;
- pixel_ptr++;
- }
- } else {
- CHECK_PIXEL_PTR(rle_code);
- CHECK_STREAM_PTR(rle_code * 2);
-
- /* copy pixels directly to output */
- while (rle_code--) {
- packed_pixel = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
- UNPACK_RGB15(packed_pixel, r, g, b);
- y = COMPUTE_Y(r, g, b);
- u = COMPUTE_U(r, g, b);
- v = COMPUTE_V(r, g, b);
- yuv->y[pixel_ptr] = y;
- yuv->u[pixel_ptr] = u;
- yuv->v[pixel_ptr] = v;
- pixel_ptr++;
- }
- }
- }
-
- row_ptr += row_inc;
- }
-}
-
-static void decode_qtrle_24(qtrle_decoder_t *this) {
-
- int stream_ptr;
- int header;
- int start_line;
- int lines_to_change;
- signed char rle_code;
- int row_ptr, pixel_ptr;
- int row_inc = this->width;
- unsigned char r, g, b;
- unsigned char y, u, v;
- yuv_planes_t *yuv = &this->yuv_planes;
- int pixel_limit = this->width * this->height;
-
- /* check if this frame is even supposed to change */
- if (this->size < 8)
- return;
-
- /* start after the chunk size */
- stream_ptr = 4;
-
- /* fetch the header */
- CHECK_STREAM_PTR(2);
- header = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
-
- /* if a header is present, fetch additional decoding parameters */
- if (header & 0x0008) {
- CHECK_STREAM_PTR(8);
- start_line = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 4;
- lines_to_change = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 4;
- } else {
- start_line = 0;
- lines_to_change = this->height;
- }
-
- row_ptr = row_inc * start_line;
- while (lines_to_change--) {
- CHECK_STREAM_PTR(2);
- pixel_ptr = row_ptr + (this->buf[stream_ptr++] - 1);
-
- while ((rle_code = (signed char)this->buf[stream_ptr++]) != -1) {
- if (rle_code == 0) {
- /* there's another skip code in the stream */
- CHECK_STREAM_PTR(1);
- pixel_ptr += (this->buf[stream_ptr++] - 1);
- } else if (rle_code < 0) {
- /* decode the run length code */
- rle_code = -rle_code;
- CHECK_STREAM_PTR(3);
- r = this->buf[stream_ptr++];
- g = this->buf[stream_ptr++];
- b = this->buf[stream_ptr++];
- y = COMPUTE_Y(r, g, b);
- u = COMPUTE_U(r, g, b);
- v = COMPUTE_V(r, g, b);
-
- CHECK_PIXEL_PTR(rle_code);
-
- while (rle_code--) {
- yuv->y[pixel_ptr] = y;
- yuv->u[pixel_ptr] = u;
- yuv->v[pixel_ptr] = v;
- pixel_ptr++;
- }
- } else {
- CHECK_PIXEL_PTR(rle_code);
- CHECK_STREAM_PTR(rle_code * 3);
-
- /* copy pixels directly to output */
- while (rle_code--) {
- r = this->buf[stream_ptr++];
- g = this->buf[stream_ptr++];
- b = this->buf[stream_ptr++];
- y = COMPUTE_Y(r, g, b);
- u = COMPUTE_U(r, g, b);
- v = COMPUTE_V(r, g, b);
- yuv->y[pixel_ptr] = y;
- yuv->u[pixel_ptr] = u;
- yuv->v[pixel_ptr] = v;
- pixel_ptr++;
- }
- }
- }
-
- row_ptr += row_inc;
- }
-}
-
-static void decode_qtrle_32(qtrle_decoder_t *this) {
-
- int stream_ptr;
- int header;
- int start_line;
- int lines_to_change;
- signed char rle_code;
- int row_ptr, pixel_ptr;
- int row_inc = this->width;
- unsigned char r, g, b;
- unsigned char y, u, v;
- yuv_planes_t *yuv = &this->yuv_planes;
- int pixel_limit = this->width * this->height;
-
- /* check if this frame is even supposed to change */
- if (this->size < 8)
- return;
-
- /* start after the chunk size */
- stream_ptr = 4;
-
- /* fetch the header */
- CHECK_STREAM_PTR(2);
- header = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
-
- /* if a header is present, fetch additional decoding parameters */
- if (header & 0x0008) {
- CHECK_STREAM_PTR(8);
- start_line = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 4;
- lines_to_change = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 4;
- } else {
- start_line = 0;
- lines_to_change = this->height;
- }
-
- row_ptr = row_inc * start_line;
- while (lines_to_change--) {
- CHECK_STREAM_PTR(2);
- pixel_ptr = row_ptr + (this->buf[stream_ptr++] - 1);
-
- while ((rle_code = (signed char)this->buf[stream_ptr++]) != -1) {
- if (rle_code == 0) {
- /* there's another skip code in the stream */
- CHECK_STREAM_PTR(1);
- pixel_ptr += (this->buf[stream_ptr++] - 1);
- } else if (rle_code < 0) {
- /* decode the run length code */
- rle_code = -rle_code;
- CHECK_STREAM_PTR(4);
- stream_ptr++; /* skip alpha transparency (?) byte */
- r = this->buf[stream_ptr++];
- g = this->buf[stream_ptr++];
- b = this->buf[stream_ptr++];
- y = COMPUTE_Y(r, g, b);
- u = COMPUTE_U(r, g, b);
- v = COMPUTE_V(r, g, b);
-
- CHECK_PIXEL_PTR(rle_code);
-
- while (rle_code--) {
- yuv->y[pixel_ptr] = y;
- yuv->u[pixel_ptr] = u;
- yuv->v[pixel_ptr] = v;
- pixel_ptr++;
- }
- } else {
- CHECK_PIXEL_PTR(rle_code);
- CHECK_STREAM_PTR(rle_code * 4);
-
- /* copy pixels directly to output */
- while (rle_code--) {
- stream_ptr++; /* skip alpha transparency (?) byte */
- r = this->buf[stream_ptr++];
- g = this->buf[stream_ptr++];
- b = this->buf[stream_ptr++];
- y = COMPUTE_Y(r, g, b);
- u = COMPUTE_U(r, g, b);
- v = COMPUTE_V(r, g, b);
- yuv->y[pixel_ptr] = y;
- yuv->u[pixel_ptr] = u;
- yuv->v[pixel_ptr] = v;
- pixel_ptr++;
- }
- }
- }
-
- row_ptr += row_inc;
- }
-}
-
-/**************************************************************************
- * xine video plugin functions
- *************************************************************************/
-
-/*
- * This function receives a buffer of data from the demuxer layer and
- * figures out how to handle it based on its header flags.
- */
-static void qtrle_decode_data (video_decoder_t *this_gen,
- buf_element_t *buf) {
-
- qtrle_decoder_t *this = (qtrle_decoder_t *) this_gen;
- xine_bmiheader *bih;
- palette_entry_t *palette;
- int i;
- char codec_name[100];
-
- vo_frame_t *img; /* video out frame */
-
- /* a video decoder does not care about this flag (?) */
- if (buf->decoder_flags & BUF_FLAG_PREVIEW)
- return;
-
- if ((buf->decoder_flags & BUF_FLAG_SPECIAL) &&
- (buf->decoder_info[1] == BUF_SPECIAL_PALETTE)) {
- palette = (palette_entry_t *)buf->decoder_info_ptr[2];
- for (i = 0; i < buf->decoder_info[2]; i++) {
- this->yuv_palette[i * 4 + 0] =
- COMPUTE_Y(palette[i].r, palette[i].g, palette[i].b);
- this->yuv_palette[i * 4 + 1] =
- COMPUTE_U(palette[i].r, palette[i].g, palette[i].b);
- this->yuv_palette[i * 4 + 2] =
- COMPUTE_V(palette[i].r, palette[i].g, palette[i].b);
- }
- }
-
- if (buf->decoder_flags & BUF_FLAG_FRAMERATE) {
- this->video_step = buf->decoder_info[0];
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION, this->video_step);
- }
-
- if (buf->decoder_flags & BUF_FLAG_STDHEADER) { /* need to initialize */
- this->stream->video_out->open (this->stream->video_out, this->stream);
-
- if(this->buf)
- free(this->buf);
-
- bih = (xine_bmiheader *) buf->content;
- this->width = bih->biWidth;
- this->height = bih->biHeight;
- this->ratio = (double)this->width/(double)this->height;
- this->depth = bih->biBitCount;
-
- if (this->buf)
- free (this->buf);
- this->bufsize = VIDEOBUFSIZE;
- this->buf = malloc(this->bufsize);
- this->size = 0;
-
- init_yuv_planes(&this->yuv_planes, this->width, this->height);
-
- this->decoder_ok = 1;
-
- /* load the stream/meta info */
- sprintf(codec_name, "%d bpp Quicktime Animation (RLE)", this->depth & 0x1F);
- _x_meta_info_set(this->stream, XINE_META_INFO_VIDEOCODEC, codec_name);
-
- return;
- } else if (this->decoder_ok) {
-
- if (this->size + buf->size > this->bufsize) {
- this->bufsize = this->size + 2 * buf->size;
- this->buf = realloc (this->buf, this->bufsize);
- }
-
- xine_fast_memcpy (&this->buf[this->size], buf->content, buf->size);
-
- this->size += buf->size;
-
- if (buf->decoder_flags & BUF_FLAG_FRAME_END) {
-
- img = this->stream->video_out->get_frame (this->stream->video_out,
- this->width, this->height,
- this->ratio,
- XINE_IMGFMT_YUY2, VO_BOTH_FIELDS);
-
- switch (this->depth & 0x1F) {
-
- case 1:
- decode_qtrle_1(this);
- break;
-
- case 2:
- decode_qtrle_2(this);
- break;
-
- case 4:
- decode_qtrle_4(this);
- break;
-
- case 8:
- decode_qtrle_8(this);
- break;
-
- case 16:
- decode_qtrle_16(this);
- break;
-
- case 24:
- decode_qtrle_24(this);
- break;
-
- case 32:
- decode_qtrle_32(this);
- break;
-
- }
-
- yuv444_to_yuy2(&this->yuv_planes, img->base[0], img->pitches[0]);
-
- img->duration = this->video_step;
- img->pts = buf->pts;
- img->bad_frame = 0;
-
- img->draw(img, this->stream);
- img->free(img);
-
- this->size = 0;
- }
- }
-}
-
-/*
- * This function is called when xine needs to flush the system. Not
- * sure when or if this is used or even if it needs to do anything.
- */
-static void qtrle_flush (video_decoder_t *this_gen) {
-}
-
-/*
- * This function resets the video decoder.
- */
-static void qtrle_reset (video_decoder_t *this_gen) {
- qtrle_decoder_t *this = (qtrle_decoder_t *) this_gen;
-
- this->size = 0;
-}
-
-static void qtrle_discontinuity (video_decoder_t *this_gen) {
-}
-
-/*
- * This function frees the video decoder instance allocated to the decoder.
- */
-static void qtrle_dispose (video_decoder_t *this_gen) {
-
- qtrle_decoder_t *this = (qtrle_decoder_t *) this_gen;
-
- if (this->buf) {
- free (this->buf);
- this->buf = NULL;
- }
-
- if (this->decoder_ok) {
- this->decoder_ok = 0;
- this->stream->video_out->close(this->stream->video_out, this->stream);
- }
-
- free (this_gen);
-}
-
-static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stream_t *stream) {
-
- qtrle_decoder_t *this ;
-
- this = (qtrle_decoder_t *) xine_xmalloc (sizeof (qtrle_decoder_t));
-
- this->video_decoder.decode_data = qtrle_decode_data;
- this->video_decoder.flush = qtrle_flush;
- this->video_decoder.reset = qtrle_reset;
- this->video_decoder.discontinuity = qtrle_discontinuity;
- this->video_decoder.dispose = qtrle_dispose;
- this->size = 0;
-
- this->stream = stream;
- this->class = (qtrle_class_t *) class_gen;
-
- this->decoder_ok = 0;
- this->buf = NULL;
-
- return &this->video_decoder;
-}
-
-static char *get_identifier (video_decoder_class_t *this) {
- return "QT RLE";
-}
-
-static char *get_description (video_decoder_class_t *this) {
- return "Quicktime Animation (RLE) video decoder plugin";
-}
-
-static void dispose_class (video_decoder_class_t *this) {
- free (this);
-}
-
-static void *init_plugin (xine_t *xine, void *data) {
-
- qtrle_class_t *this;
-
- this = (qtrle_class_t *) xine_xmalloc (sizeof (qtrle_class_t));
-
- this->decoder_class.open_plugin = open_plugin;
- this->decoder_class.get_identifier = get_identifier;
- this->decoder_class.get_description = get_description;
- this->decoder_class.dispose = dispose_class;
-
- return this;
-}
-
-/*
- * exported plugin catalog entry
- */
-static uint32_t video_types[] = {
- BUF_VIDEO_QTRLE,
- 0
-};
-
-static decoder_info_t dec_info_video = {
- video_types, /* supported types */
- 5 /* priority */
-};
-
-plugin_info_t xine_plugin_info[] = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_VIDEO_DECODER, 18, "qtrle", XINE_VERSION_CODE, &dec_info_video, init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
diff --git a/src/libxinevdec/qtrpza.c b/src/libxinevdec/qtrpza.c
deleted file mode 100644
index f27593f5e..000000000
--- a/src/libxinevdec/qtrpza.c
+++ /dev/null
@@ -1,465 +0,0 @@
-/*
- * Copyright (C) 2000-2003 the xine project
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * QT RPZA Video Decoder by Roberto Togni <rtogni@bresciaonline.it>
- * For more information about the RPZA format, visit:
- * http://www.pcisys.net/~melanson/codecs/
- *
- * $Id: qtrpza.c,v 1.24 2004/02/09 22:04:11 jstembridge Exp $
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "buffer.h"
-#include "xine_internal.h"
-#include "video_out.h"
-#include "xineutils.h"
-#include "bswap.h"
-
-#define VIDEOBUFSIZE 128*1024
-
-typedef struct {
- video_decoder_class_t decoder_class;
-} qtrpza_class_t;
-
-typedef struct qtrpza_decoder_s {
- video_decoder_t video_decoder; /* parent video decoder structure */
-
- qtrpza_class_t *class;
- xine_stream_t *stream;
-
- /* these are traditional variables in a video decoder object */
- uint64_t video_step; /* frame duration in pts units */
- int decoder_ok; /* current decoder status */
- int skipframes;
-
- unsigned char *buf; /* the accumulated buffer data */
- int bufsize; /* the maximum size of buf */
- int size; /* the current size of buf */
-
- int width; /* the width of a video frame */
- int height; /* the height of a video frame */
- double ratio; /* the width to height ratio */
-
- yuv_planes_t yuv_planes;
-
-} qtrpza_decoder_t;
-
-/**************************************************************************
- * RPZA specific decode functions
- *************************************************************************/
-
-#define ADVANCE_BLOCK() \
-{ \
- pixel_ptr += 4; \
- if (pixel_ptr >= this->width) \
- { \
- pixel_ptr = 0; \
- row_ptr += this->width * 4; \
- } \
- total_blocks--; \
- if (total_blocks < 0) \
- { \
- printf(_("warning: block counter just went negative (this should not happen)\n")); \
- return; \
- } \
-}
-
-#define COLOR_FIX(col_out, col_in) (col_out) = ((col_in) << 3) | ((col_in) >> 2)
-
-/* r, g, and b are defined in the function from which this is called */
-#define COLOR_TO_YUV(y_val, u_val, v_val, color) \
-{ \
- unsigned short tmp; \
- tmp = (color >> 10) & 0x1f; \
- COLOR_FIX (r, tmp); \
- tmp = (color >> 5) & 0x1f; \
- COLOR_FIX (g, tmp); \
- tmp = color & 0x1f; \
- COLOR_FIX (b, tmp); \
- y_val = COMPUTE_Y(r, g, b); \
- u_val = COMPUTE_U(r, g, b); \
- v_val = COMPUTE_V(r, g, b); \
-}
-
-static void decode_qtrpza(qtrpza_decoder_t *this) {
-
- int i;
- int stream_ptr = 0;
- int chunk_size;
- unsigned char opcode;
- int n_blocks;
- unsigned short colorA = 0, colorB;
- unsigned char r, g, b;
- unsigned char y, u, v;
- unsigned char rgb4[4][3];
- unsigned char yuv4[4][3];
- unsigned char index, idx;
-
- int row_ptr = 0;
- int pixel_ptr = 0;
- int pixel_x, pixel_y;
- int row_inc = this->width - 4;
- int block_ptr;
- int total_blocks;
- unsigned short ta, tb, tt;
-
- /* First byte is always 0xe1. Warn if it's different */
- if ((unsigned char)this->buf[stream_ptr] != 0xe1)
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "First chunk byte is 0x%02x instead of 0x1e\n",
- (unsigned char)this->buf[stream_ptr]);
-
- /* Get chunk size, ingnoring first byte */
- chunk_size = BE_32(&this->buf[stream_ptr]) & 0x00FFFFFF;
- stream_ptr += 4;
-
- /* If length mismatch use size from MOV file and try to decode anyway */
- if (chunk_size != this->size)
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "MOV chunk size != encoded chunk size; using MOV chunk size\n");
-
- chunk_size = this->size;
-
- /* Number of 4x4 blocks in frame. */
- total_blocks = (this->width * this->height) / (4 * 4);
-
- /* Process chunk data */
- while (stream_ptr < chunk_size) {
- opcode = this->buf[stream_ptr++]; /* Get opcode */
-
- n_blocks = (opcode & 0x1f) +1; /* Extract block counter from opcode */
-
- /* If opcode MSbit is 0, we need more data to decide what to do */
- if ((opcode & 0x80) == 0) {
- colorA = (opcode << 8) | ((unsigned char)this->buf[stream_ptr++]);
- opcode = 0;
- if ((this->buf[stream_ptr] & 0x80) != 0) {
- /* Must behave as opcode 110xxxxx, using colorA computed above.*/
- /* Use fake opcode 0x20 to enter switch block at the right place */
- opcode = 0x20;
- n_blocks = 1;
- }
- }
-
- switch (opcode & 0xe0) {
- /* Skip blocks */
- case 0x80:
- while (n_blocks--)
- ADVANCE_BLOCK();
- break;
-
- /* Fill blocks with one color */
- case 0xa0:
- colorA = BE_16 (&this->buf[stream_ptr]);
- stream_ptr += 2;
- COLOR_TO_YUV (y, u, v, colorA);
- while (n_blocks--) {
- block_ptr = row_ptr + pixel_ptr;
- for (pixel_y = 0; pixel_y < 4; pixel_y++) {
- for (pixel_x = 0; pixel_x < 4; pixel_x++){
- this->yuv_planes.y[block_ptr] = y;
- this->yuv_planes.u[block_ptr] = u;
- this->yuv_planes.v[block_ptr] = v;
- block_ptr++;
- }
- block_ptr += row_inc;
- }
- ADVANCE_BLOCK();
- }
- break;
-
- /* Fill blocks with 4 colors */
- case 0xc0:
- colorA = BE_16 (&this->buf[stream_ptr]);
- stream_ptr += 2;
- case 0x20:
- colorB = BE_16 (&this->buf[stream_ptr]);
- stream_ptr += 2;
-
- /* sort out the colors */
- ta = (colorA >> 10) & 0x1f;
- tb = (colorB >> 10) & 0x1f;
- COLOR_FIX (rgb4[3][0], ta);
- COLOR_FIX (rgb4[0][0], tb);
- tt = (11 * ta + 21 * tb) >> 5;
- COLOR_FIX (rgb4[1][0], tt);
- tt = (21 * ta + 11 * tb) >> 5;
- COLOR_FIX (rgb4[2][0], tt);
- ta = (colorA >> 5) & 0x1f;
- tb = (colorB >> 5) & 0x1f;
- COLOR_FIX (rgb4[3][1], ta);
- COLOR_FIX (rgb4[0][1], tb);
- tt = (11 * ta + 21 * tb) >> 5;
- COLOR_FIX (rgb4[1][1], tt);
- tt = (21 * ta + 11 * tb) >> 5;
- COLOR_FIX (rgb4[2][1], tt);
- ta = colorA & 0x1f;
- tb = colorB & 0x1f;
- COLOR_FIX (rgb4[3][2], ta);
- COLOR_FIX (rgb4[0][2], tb);
- tt = (11 * ta + 21 * tb) >> 5;
- COLOR_FIX (rgb4[1][2], tt);
- tt = (21 * ta + 11 * tb) >> 5;
- COLOR_FIX (rgb4[2][2], tt);
-
- /* RGB -> YUV */
- for (i = 0; i < 4; i++) {
- yuv4[i][0] = COMPUTE_Y(rgb4[i][0], rgb4[i][1], rgb4[i][2]);
- yuv4[i][1] = COMPUTE_U(rgb4[i][0], rgb4[i][1], rgb4[i][2]);
- yuv4[i][2] = COMPUTE_V(rgb4[i][0], rgb4[i][1], rgb4[i][2]);
- }
-
- while (n_blocks--) {
- block_ptr = row_ptr + pixel_ptr;
- for (pixel_y = 0; pixel_y < 4; pixel_y++) {
- index = this->buf[stream_ptr++];
- for (pixel_x = 0; pixel_x < 4; pixel_x++){
- idx = (index >> (2 * (3 - pixel_x))) & 0x03;
- this->yuv_planes.y[block_ptr] = yuv4[idx][0];
- this->yuv_planes.u[block_ptr] = yuv4[idx][1];
- this->yuv_planes.v[block_ptr] = yuv4[idx][2];
- block_ptr++;
- }
- block_ptr += row_inc;
- }
- ADVANCE_BLOCK();
- }
- break;
-
- /* Fill block with 16 colors */
- case 0x00:
- block_ptr = row_ptr + pixel_ptr;
- for (pixel_y = 0; pixel_y < 4; pixel_y++) {
- for (pixel_x = 0; pixel_x < 4; pixel_x++){
- /* We already have color of upper left pixel */
- if ((pixel_y != 0) || (pixel_x !=0)) {
- colorA = BE_16 (&this->buf[stream_ptr]);
- stream_ptr += 2;
- }
- COLOR_TO_YUV (y, u, v, colorA);
- this->yuv_planes.y[block_ptr] = y;
- this->yuv_planes.u[block_ptr] = u;
- this->yuv_planes.v[block_ptr] = v;
- block_ptr++;
- }
- block_ptr += row_inc;
- }
- ADVANCE_BLOCK();
- break;
-
- /* Unknown opcode */
- default:
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "Unknown opcode %d in rpza chunk.Skip remaining %d bytes of chunk data.\n",
- opcode, chunk_size - stream_ptr);
- return;
- } /* Opcode switch */
-
- }
-}
-
-/**************************************************************************
- * xine video plugin functions
- *************************************************************************/
-
-/*
- * This function receives a buffer of data from the demuxer layer and
- * figures out how to handle it based on its header flags.
- */
-static void qtrpza_decode_data (video_decoder_t *this_gen,
- buf_element_t *buf) {
-
- qtrpza_decoder_t *this = (qtrpza_decoder_t *) this_gen;
- xine_bmiheader *bih;
-
- vo_frame_t *img; /* video out frame */
-
- /* a video decoder does not care about this flag (?) */
- if (buf->decoder_flags & BUF_FLAG_PREVIEW)
- return;
-
- if (buf->decoder_flags & BUF_FLAG_FRAMERATE) {
- this->video_step = buf->decoder_info[0];
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION, this->video_step);
- }
-
- if (buf->decoder_flags & BUF_FLAG_STDHEADER) { /* need to initialize */
- this->stream->video_out->open (this->stream->video_out, this->stream);
-
- if(this->buf)
- free(this->buf);
-
- bih = (xine_bmiheader *) buf->content;
- this->width = (bih->biWidth + 3) & ~0x03;
- this->height = (bih->biHeight + 3) & ~0x03;
- this->ratio = (double)this->width/(double)this->height;
-
- if (this->buf)
- free (this->buf);
- this->bufsize = VIDEOBUFSIZE;
- this->buf = malloc(this->bufsize);
- this->size = 0;
-
- init_yuv_planes(&this->yuv_planes, this->width, this->height);
-
- this->stream->video_out->open (this->stream->video_out, this->stream);
- this->decoder_ok = 1;
-
- /* load the stream/meta info */
- _x_meta_info_set(this->stream, XINE_META_INFO_VIDEOCODEC, "Quicktime Video (RPZA)");
-
- return;
- } else if (this->decoder_ok) {
-
- if (this->size + buf->size > this->bufsize) {
- this->bufsize = this->size + 2 * buf->size;
- this->buf = realloc (this->buf, this->bufsize);
- }
-
- xine_fast_memcpy (&this->buf[this->size], buf->content, buf->size);
-
- this->size += buf->size;
-
- if (buf->decoder_flags & BUF_FLAG_FRAME_END) {
-
- img = this->stream->video_out->get_frame (this->stream->video_out,
- this->width, this->height,
- this->ratio, XINE_IMGFMT_YUY2,
- VO_BOTH_FIELDS);
-
- img->duration = this->video_step;
- img->pts = buf->pts;
- img->bad_frame = 0;
-
- decode_qtrpza(this);
- yuv444_to_yuy2(&this->yuv_planes, img->base[0], img->pitches[0]);
-
- img->draw(img, this->stream);
- img->free(img);
-
- this->size = 0;
- }
- }
-}
-
-/*
- * This function is called when xine needs to flush the system. Not
- * sure when or if this is used or even if it needs to do anything.
- */
-static void qtrpza_flush (video_decoder_t *this_gen) {
-}
-
-/*
- * This function resets the video decoder.
- */
-static void qtrpza_reset (video_decoder_t *this_gen) {
- qtrpza_decoder_t *this = (qtrpza_decoder_t *) this_gen;
-
- this->size = 0;
-}
-
-static void qtrpza_discontinuity (video_decoder_t *this_gen) {
-}
-
-/*
- * This function frees the video decoder instance allocated to the decoder.
- */
-static void qtrpza_dispose (video_decoder_t *this_gen) {
-
- qtrpza_decoder_t *this = (qtrpza_decoder_t *) this_gen;
-
- if (this->buf) {
- free (this->buf);
- this->buf = NULL;
- }
-
- if (this->decoder_ok) {
- this->decoder_ok = 0;
- this->stream->video_out->close(this->stream->video_out, this->stream);
- }
-
- free (this_gen);
-}
-
-static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stream_t *stream) {
-
- qtrpza_decoder_t *this ;
-
- this = (qtrpza_decoder_t *) xine_xmalloc (sizeof (qtrpza_decoder_t));
-
- this->video_decoder.decode_data = qtrpza_decode_data;
- this->video_decoder.flush = qtrpza_flush;
- this->video_decoder.reset = qtrpza_reset;
- this->video_decoder.discontinuity = qtrpza_discontinuity;
- this->video_decoder.dispose = qtrpza_dispose;
- this->size = 0;
-
- this->stream = stream;
- this->class = (qtrpza_class_t *) class_gen;
-
- this->decoder_ok = 0;
- this->buf = NULL;
-
- return &this->video_decoder;
-}
-
-static char *get_identifier (video_decoder_class_t *this) {
- return "QT RPZA";
-}
-
-static char *get_description (video_decoder_class_t *this) {
- return "Quicktime Video (RPZA) decoder plugin";
-}
-
-static void dispose_class (video_decoder_class_t *this) {
- free (this);
-}
-
-static void *init_plugin (xine_t *xine, void *data) {
-
- qtrpza_class_t *this;
-
- this = (qtrpza_class_t *) xine_xmalloc (sizeof (qtrpza_class_t));
-
- this->decoder_class.open_plugin = open_plugin;
- this->decoder_class.get_identifier = get_identifier;
- this->decoder_class.get_description = get_description;
- this->decoder_class.dispose = dispose_class;
-
- return this;
-}
-
-/* plugin catalog information */
-static uint32_t supported_types[] = { BUF_VIDEO_RPZA, 0 };
-
-static decoder_info_t video_decoder_info = {
- supported_types, /* supported types */
- 1 /* priority */
-};
-
-plugin_info_t xine_plugin_info[] = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_VIDEO_DECODER, 18, "rpza", XINE_VERSION_CODE, &video_decoder_info, &init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
diff --git a/src/libxinevdec/qtsmc.c b/src/libxinevdec/qtsmc.c
deleted file mode 100644
index 1230062e0..000000000
--- a/src/libxinevdec/qtsmc.c
+++ /dev/null
@@ -1,698 +0,0 @@
-/*
- * Copyright (C) 2000-2003 the xine project
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * Apple Graphics (SMC) Decoder by Mike Melanson (melanson@pcisys.net)
- * Special thanks to Roberto Togni <rtogni@bresciaonline.it> for tracking
- * down the final, nagging bugs.
- * For more information on the SMC format, visit:
- * http://www.pcisys.net/~melanson/codecs/
- *
- * $Id: qtsmc.c,v 1.24 2004/02/09 22:04:11 jstembridge Exp $
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "buffer.h"
-#include "xine_internal.h"
-#include "video_out.h"
-#include "xineutils.h"
-#include "bswap.h"
-
-#define VIDEOBUFSIZE 128*1024
-
-#define COLORS_PER_TABLE 256
-#define BYTES_PER_COLOR 4
-
-#define CPAIR 2
-#define CQUAD 4
-#define COCTET 8
-
-typedef struct {
- video_decoder_class_t decoder_class;
-} qtsmc_class_t;
-
-typedef struct qtsmc_decoder_s {
- video_decoder_t video_decoder; /* parent video decoder structure */
-
- qtsmc_class_t *class;
- xine_stream_t *stream;
-
- /* these are traditional variables in a video decoder object */
- uint64_t video_step; /* frame duration in pts units */
- int decoder_ok; /* current decoder status */
- int skipframes;
-
- unsigned char *buf; /* the accumulated buffer data */
- int bufsize; /* the maximum size of buf */
- int size; /* the current size of buf */
-
- int width; /* the width of a video frame */
- int height; /* the height of a video frame */
- double ratio; /* the width to height ratio */
-
- /* SMC color tables */
- unsigned char color_pairs[COLORS_PER_TABLE * BYTES_PER_COLOR * CPAIR];
- unsigned char color_quads[COLORS_PER_TABLE * BYTES_PER_COLOR * CQUAD];
- unsigned char color_octets[COLORS_PER_TABLE * BYTES_PER_COLOR * COCTET];
-
- unsigned char yuv_palette[256 * 4];
- yuv_planes_t yuv_planes;
-
-} qtsmc_decoder_t;
-
-/**************************************************************************
- * SMC specific decode functions
- *************************************************************************/
-
-#define GET_BLOCK_COUNT \
- (opcode & 0x10) ? (1 + this->buf[stream_ptr++]) : 1 + (opcode & 0x0F);
-#define ADVANCE_BLOCK() \
-{ \
- pixel_ptr += 4; \
- if (pixel_ptr >= this->width) \
- { \
- pixel_ptr = 0; \
- row_ptr += this->width * 4; \
- } \
- total_blocks--; \
- if (total_blocks < 0) \
- { \
- printf(_("warning: block counter just went negative (this should not happen)\n")); \
- return; \
- } \
-}
-
-static void decode_qtsmc(qtsmc_decoder_t *this) {
-
- int i;
- int stream_ptr = 0;
- int chunk_size;
- unsigned char opcode;
- int n_blocks;
- unsigned int color_flags;
- unsigned int color_flags_a;
- unsigned int color_flags_b;
- unsigned int flag_mask;
-
- yuv_planes_t *yuv = &this->yuv_planes;
-
- int image_size = this->height * this->width;
- int row_ptr = 0;
- int pixel_ptr = 0;
- int pixel_x, pixel_y;
- int row_inc = this->width - 4;
- int block_ptr;
- int prev_block_ptr;
- int prev_block_ptr1, prev_block_ptr2;
- int prev_block_flag;
- int total_blocks;
- int color_table_index; /* indexes to color pair, quad, or octet tables */
- int color_index; /* indexes into palette map */
-
- int color_pair_index = 0;
- int color_quad_index = 0;
- int color_octet_index = 0;
-
- chunk_size = BE_32(&this->buf[stream_ptr]) & 0x00FFFFFF;
- stream_ptr += 4;
- if (chunk_size != this->size)
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "warning: MOV chunk size != encoded chunk size (%d != %d); using MOV chunk size\n",
- chunk_size, this->size);
-
- chunk_size = this->size;
- total_blocks = (this->width * this->height) / (4 * 4);
-
- /* traverse through the blocks */
- while (total_blocks) {
- /* sanity checks */
- /* make sure stream ptr hasn't gone out of bounds */
- if (stream_ptr > chunk_size) {
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "SMC decoder just went out of bounds (stream ptr = %d, chunk size = %d)\n",
- stream_ptr, chunk_size);
- return;
- }
- /* make sure the row pointer hasn't gone wild */
- if (row_ptr >= image_size) {
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "SMC decoder just went out of bounds (row ptr = %d, height = %d)\n",
- row_ptr, image_size);
- return;
- }
-
- opcode = this->buf[stream_ptr++];
- switch (opcode & 0xF0) {
- /* skip n blocks */
- case 0x00:
- case 0x10:
- n_blocks = GET_BLOCK_COUNT;
- while (n_blocks--)
- ADVANCE_BLOCK();
- break;
-
- /* repeat last block n times */
- case 0x20:
- case 0x30:
- n_blocks = GET_BLOCK_COUNT;
-
- /* sanity check */
- if ((row_ptr == 0) && (pixel_ptr == 0)) {
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "encountered repeat block opcode (%02X) but no blocks rendered yet\n",
- opcode & 0xF0);
- break;
- }
-
- /* figure out where the previous block started */
- if (pixel_ptr == 0)
- prev_block_ptr1 = (row_ptr - this->width * 4) + this->width - 4;
- else
- prev_block_ptr1 = row_ptr + pixel_ptr - 4;
-
- while (n_blocks--) {
- block_ptr = row_ptr + pixel_ptr;
- prev_block_ptr = prev_block_ptr1;
- for (pixel_y = 0; pixel_y < 4; pixel_y++) {
- for (pixel_x = 0; pixel_x < 4; pixel_x++) {
- yuv->y[block_ptr] = yuv->y[prev_block_ptr];
- yuv->u[block_ptr] = yuv->u[prev_block_ptr];
- yuv->v[block_ptr] = yuv->v[prev_block_ptr];
- block_ptr++;
- prev_block_ptr++;
- }
- block_ptr += row_inc;
- prev_block_ptr += row_inc;
- }
- ADVANCE_BLOCK();
- }
- break;
-
- /* repeat previous pair of blocks n times */
- case 0x40:
- case 0x50:
- n_blocks = GET_BLOCK_COUNT;
- n_blocks *= 2;
-
- /* sanity check */
- if ((row_ptr == 0) && (pixel_ptr < 2 * 4)) {
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "encountered repeat block opcode (%02X) but not enough blocks rendered yet\n",
- opcode & 0xF0);
- break;
- }
-
- /* figure out where the previous 2 blocks started */
- if (pixel_ptr == 0)
- prev_block_ptr1 = (row_ptr - this->width * 4) +
- this->width - 4 * 2;
- else if (pixel_ptr == 4)
- prev_block_ptr1 = (row_ptr - this->width * 4) + row_inc;
- else
- prev_block_ptr1 = row_ptr + pixel_ptr - 4 * 2;
-
- if (pixel_ptr == 0)
- prev_block_ptr2 = (row_ptr - this->width * 4) + row_inc;
- else
- prev_block_ptr2 = row_ptr + pixel_ptr - 4;
-
- prev_block_flag = 0;
- while (n_blocks--) {
- block_ptr = row_ptr + pixel_ptr;
- if (prev_block_flag)
- prev_block_ptr = prev_block_ptr2;
- else
- prev_block_ptr = prev_block_ptr1;
- prev_block_flag = !prev_block_flag;
-
- for (pixel_y = 0; pixel_y < 4; pixel_y++) {
- for (pixel_x = 0; pixel_x < 4; pixel_x++) {
- yuv->y[block_ptr] = yuv->y[prev_block_ptr];
- yuv->u[block_ptr] = yuv->u[prev_block_ptr];
- yuv->v[block_ptr] = yuv->v[prev_block_ptr];
- block_ptr++;
- prev_block_ptr++;
- }
- block_ptr += row_inc;
- prev_block_ptr += row_inc;
- }
- ADVANCE_BLOCK();
- }
- break;
-
- /* 1-color block encoding */
- case 0x60:
- case 0x70:
- n_blocks = GET_BLOCK_COUNT;
- color_index = this->buf[stream_ptr++] * 4;
-
- while (n_blocks--) {
- block_ptr = row_ptr + pixel_ptr;
- for (pixel_y = 0; pixel_y < 4; pixel_y++) {
- for (pixel_x = 0; pixel_x < 4; pixel_x++) {
- yuv->y[block_ptr] = this->yuv_palette[color_index + 0];
- yuv->u[block_ptr] = this->yuv_palette[color_index + 1];
- yuv->v[block_ptr] = this->yuv_palette[color_index + 2];
- block_ptr++;
- }
- block_ptr += row_inc;
- }
- ADVANCE_BLOCK();
- }
- break;
-
- /* 2-color block encoding */
- case 0x80:
- case 0x90:
- n_blocks = (opcode & 0x0F) + 1;
-
- /* figure out which color pair to use to paint the 2-color block */
- if ((opcode & 0xF0) == 0x80) {
- /* fetch the next 2 colors from bytestream and store in next
- * available entry in the color pair table */
- for (i = 0; i < CPAIR; i++) {
- color_index = this->buf[stream_ptr++] * BYTES_PER_COLOR;
- color_table_index = CPAIR * BYTES_PER_COLOR * color_pair_index +
- (i * BYTES_PER_COLOR);
- this->color_pairs[color_table_index + 0] =
- this->yuv_palette[color_index + 0];
- this->color_pairs[color_table_index + 1] =
- this->yuv_palette[color_index + 1];
- this->color_pairs[color_table_index + 2] =
- this->yuv_palette[color_index + 2];
- }
- /* this is the base index to use for this block */
- color_table_index = CPAIR * BYTES_PER_COLOR * color_pair_index;
- color_pair_index++;
- /* wraparound */
- if (color_pair_index == COLORS_PER_TABLE)
- color_pair_index = 0;
- }
- else
- color_table_index = CPAIR * BYTES_PER_COLOR * this->buf[stream_ptr++];
-
- while (n_blocks--) {
- color_flags = BE_16(&this->buf[stream_ptr]);
- stream_ptr += 2;
- flag_mask = 0x8000;
- block_ptr = row_ptr + pixel_ptr;
- for (pixel_y = 0; pixel_y < 4; pixel_y++) {
- for (pixel_x = 0; pixel_x < 4; pixel_x++) {
- if (color_flags & flag_mask)
- color_index = color_table_index + BYTES_PER_COLOR;
- else
- color_index = color_table_index;
- flag_mask >>= 1;
-
- yuv->y[block_ptr] = this->color_pairs[color_index + 0];
- yuv->u[block_ptr] = this->color_pairs[color_index + 1];
- yuv->v[block_ptr] = this->color_pairs[color_index + 2];
- block_ptr++;
- }
- block_ptr += row_inc;
- }
- ADVANCE_BLOCK();
- }
- break;
-
- /* 4-color block encoding */
- case 0xA0:
- case 0xB0:
- n_blocks = (opcode & 0x0F) + 1;
-
- /* figure out which color quad to use to paint the 4-color block */
- if ((opcode & 0xF0) == 0xA0) {
- /* fetch the next 4 colors from bytestream and store in next
- * available entry in the color quad table */
- for (i = 0; i < CQUAD; i++) {
- color_index = this->buf[stream_ptr++] * BYTES_PER_COLOR;
- color_table_index = CQUAD * BYTES_PER_COLOR * color_quad_index +
- (i * BYTES_PER_COLOR);
- this->color_quads[color_table_index + 0] =
- this->yuv_palette[color_index + 0];
- this->color_quads[color_table_index + 1] =
- this->yuv_palette[color_index + 1];
- this->color_quads[color_table_index + 2] =
- this->yuv_palette[color_index + 2];
- }
- /* this is the base index to use for this block */
- color_table_index = CQUAD * BYTES_PER_COLOR * color_quad_index;
- color_quad_index++;
- /* wraparound */
- if (color_quad_index == COLORS_PER_TABLE)
- color_quad_index = 0;
- }
- else
- color_table_index = CQUAD * BYTES_PER_COLOR * this->buf[stream_ptr++];
-
- while (n_blocks--) {
- color_flags = BE_32(&this->buf[stream_ptr]);
- stream_ptr += 4;
- /* flag mask actually acts as a bit shift count here */
- flag_mask = 30;
- block_ptr = row_ptr + pixel_ptr;
- for (pixel_y = 0; pixel_y < 4; pixel_y++) {
- for (pixel_x = 0; pixel_x < 4; pixel_x++) {
- color_index = color_table_index + (BYTES_PER_COLOR *
- ((color_flags >> flag_mask) & 0x03));
- flag_mask -= 2;
-
- yuv->y[block_ptr] = this->color_quads[color_index + 0];
- yuv->u[block_ptr] = this->color_quads[color_index + 1];
- yuv->v[block_ptr] = this->color_quads[color_index + 2];
- block_ptr++;
- }
- block_ptr += row_inc;
- }
- ADVANCE_BLOCK();
- }
- break;
-
- /* 8-color block encoding */
- case 0xC0:
- case 0xD0:
- n_blocks = (opcode & 0x0F) + 1;
-
- /* figure out which color octet to use to paint the 8-color block */
- if ((opcode & 0xF0) == 0xC0) {
- /* fetch the next 8 colors from bytestream and store in next
- * available entry in the color octet table */
- for (i = 0; i < COCTET; i++) {
- color_index = this->buf[stream_ptr++] * BYTES_PER_COLOR;
- color_table_index = COCTET * BYTES_PER_COLOR * color_octet_index +
- (i * BYTES_PER_COLOR);
- this->color_octets[color_table_index + 0] =
- this->yuv_palette[color_index + 0];
- this->color_octets[color_table_index + 1] =
- this->yuv_palette[color_index + 1];
- this->color_octets[color_table_index + 2] =
- this->yuv_palette[color_index + 2];
- }
- /* this is the base index to use for this block */
- color_table_index = COCTET * BYTES_PER_COLOR * color_octet_index;
- color_octet_index++;
- /* wraparound */
- if (color_octet_index == COLORS_PER_TABLE)
- color_octet_index = 0;
- }
- else
- color_table_index = COCTET * BYTES_PER_COLOR * this->buf[stream_ptr++];
-
- while (n_blocks--) {
- /*
- For this input of 6 hex bytes:
- 01 23 45 67 89 AB
- Mangle it to this output:
- flags_a = xx012456, flags_b = xx89A37B
- */
- /* build the color flags */
- color_flags_a = color_flags_b = 0;
- color_flags_a =
- (this->buf[stream_ptr + 0] << 16) |
- ((this->buf[stream_ptr + 1] & 0xF0) << 8) |
- ((this->buf[stream_ptr + 2] & 0xF0) << 4) |
- ((this->buf[stream_ptr + 2] & 0x0F) << 4) |
- ((this->buf[stream_ptr + 3] & 0xF0) >> 4);
- color_flags_b =
- (this->buf[stream_ptr + 4] << 16) |
- ((this->buf[stream_ptr + 5] & 0xF0) << 8) |
- ((this->buf[stream_ptr + 1] & 0x0F) << 8) |
- ((this->buf[stream_ptr + 3] & 0x0F) << 4) |
- (this->buf[stream_ptr + 5] & 0x0F);
- stream_ptr += 6;
-
- color_flags = color_flags_a;
- /* flag mask actually acts as a bit shift count here */
- flag_mask = 21;
- block_ptr = row_ptr + pixel_ptr;
- for (pixel_y = 0; pixel_y < 4; pixel_y++) {
- /* reload flags at third row (iteration pixel_y == 2) */
- if (pixel_y == 2) {
- color_flags = color_flags_b;
- flag_mask = 21;
- }
- for (pixel_x = 0; pixel_x < 4; pixel_x++) {
- color_index = color_table_index + (BYTES_PER_COLOR *
- ((color_flags >> flag_mask) & 0x07));
- flag_mask -= 3;
-
- yuv->y[block_ptr] = this->color_octets[color_index + 0];
- yuv->u[block_ptr] = this->color_octets[color_index + 1];
- yuv->v[block_ptr] = this->color_octets[color_index + 2];
- block_ptr++;
- }
- block_ptr += row_inc;
- }
- ADVANCE_BLOCK();
- }
- break;
-
- /* 16-color block encoding (every pixel is a different color) */
- case 0xE0:
- n_blocks = (opcode & 0x0F) + 1;
-
- while (n_blocks--) {
- block_ptr = row_ptr + pixel_ptr;
- for (pixel_y = 0; pixel_y < 4; pixel_y++) {
- for (pixel_x = 0; pixel_x < 4; pixel_x++) {
- color_index = this->buf[stream_ptr++] * BYTES_PER_COLOR;
- yuv->y[block_ptr] = this->yuv_palette[color_index + 0];
- yuv->u[block_ptr] = this->yuv_palette[color_index + 1];
- yuv->v[block_ptr] = this->yuv_palette[color_index + 2];
- block_ptr++;
- }
- block_ptr += row_inc;
- }
- ADVANCE_BLOCK();
- }
- break;
-
- case 0xF0:
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "0xF0 opcode seen in SMC chunk (xine developers would like to know)\n");
- break;
- }
- }
-}
-
-
-/**************************************************************************
- * xine video plugin functions
- *************************************************************************/
-
-/*
- * This function receives a buffer of data from the demuxer layer and
- * figures out how to handle it based on its header flags.
- */
-static void qtsmc_decode_data (video_decoder_t *this_gen,
- buf_element_t *buf) {
-
- qtsmc_decoder_t *this = (qtsmc_decoder_t *) this_gen;
- xine_bmiheader *bih;
- palette_entry_t *palette;
- int i;
-
- vo_frame_t *img; /* video out frame */
-
- /* a video decoder does not care about this flag (?) */
- if (buf->decoder_flags & BUF_FLAG_PREVIEW)
- return;
-
- if ((buf->decoder_flags & BUF_FLAG_SPECIAL) &&
- (buf->decoder_info[1] == BUF_SPECIAL_PALETTE)) {
- palette = (palette_entry_t *)buf->decoder_info_ptr[2];
- for (i = 0; i < buf->decoder_info[2]; i++) {
- this->yuv_palette[i * 4 + 0] =
- COMPUTE_Y(palette[i].r, palette[i].g, palette[i].b);
- this->yuv_palette[i * 4 + 1] =
- COMPUTE_U(palette[i].r, palette[i].g, palette[i].b);
- this->yuv_palette[i * 4 + 2] =
- COMPUTE_V(palette[i].r, palette[i].g, palette[i].b);
- }
- }
-
- if (buf->decoder_flags & BUF_FLAG_FRAMERATE) {
- this->video_step = buf->decoder_info[0];
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION, this->video_step);
- }
-
- if (buf->decoder_flags & BUF_FLAG_STDHEADER) { /* need to initialize */
- this->stream->video_out->open (this->stream->video_out, this->stream);
-
- if(this->buf)
- free(this->buf);
-
- bih = (xine_bmiheader *) buf->content;
- this->width = (bih->biWidth + 3) & ~0x03;
- this->height = (bih->biHeight + 3) & ~0x03;
- this->ratio = (double)this->width/(double)this->height;
-
- if (this->buf)
- free (this->buf);
- this->bufsize = VIDEOBUFSIZE;
- this->buf = malloc(this->bufsize);
- this->size = 0;
-
- init_yuv_planes(&this->yuv_planes, this->width, this->height);
-
- this->stream->video_out->open (this->stream->video_out, this->stream);
- this->decoder_ok = 1;
-
- /* load the stream/meta info */
- _x_meta_info_set(this->stream, XINE_META_INFO_VIDEOCODEC, "Quicktime Graphics (SMC)");
-
- return;
- } else if (this->decoder_ok) {
-
- if (this->size + buf->size > this->bufsize) {
- this->bufsize = this->size + 2 * buf->size;
- this->buf = realloc (this->buf, this->bufsize);
- }
-
- xine_fast_memcpy (&this->buf[this->size], buf->content, buf->size);
-
- this->size += buf->size;
-
- if (buf->decoder_flags & BUF_FLAG_FRAME_END) {
-
- img = this->stream->video_out->get_frame (this->stream->video_out,
- this->width, this->height,
- this->ratio, XINE_IMGFMT_YUY2,
- VO_BOTH_FIELDS);
-
- img->duration = this->video_step;
- img->pts = buf->pts;
- img->bad_frame = 0;
-
- decode_qtsmc(this);
- yuv444_to_yuy2(&this->yuv_planes, img->base[0], img->pitches[0]);
-
- img->draw(img, this->stream);
- img->free(img);
-
- this->size = 0;
- }
- }
-}
-
-/*
- * This function is called when xine needs to flush the system. Not
- * sure when or if this is used or even if it needs to do anything.
- */
-static void qtsmc_flush (video_decoder_t *this_gen) {
-}
-
-/*
- * This function resets the video decoder.
- */
-static void qtsmc_reset (video_decoder_t *this_gen) {
- qtsmc_decoder_t *this = (qtsmc_decoder_t *) this_gen;
-
- this->size = 0;
-}
-
-static void qtsmc_discontinuity (video_decoder_t *this_gen) {
-}
-
-/*
- * This function frees the video decoder instance allocated to the decoder.
- */
-static void qtsmc_dispose (video_decoder_t *this_gen) {
-
- qtsmc_decoder_t *this = (qtsmc_decoder_t *) this_gen;
-
- if (this->buf) {
- free (this->buf);
- this->buf = NULL;
- }
-
- if (this->decoder_ok) {
- this->decoder_ok = 0;
- this->stream->video_out->close(this->stream->video_out, this->stream);
- }
-
- free (this_gen);
-}
-
-static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stream_t *stream) {
-
- qtsmc_decoder_t *this ;
-
- this = (qtsmc_decoder_t *) xine_xmalloc (sizeof (qtsmc_decoder_t));
-
- this->video_decoder.decode_data = qtsmc_decode_data;
- this->video_decoder.flush = qtsmc_flush;
- this->video_decoder.reset = qtsmc_reset;
- this->video_decoder.discontinuity = qtsmc_discontinuity;
- this->video_decoder.dispose = qtsmc_dispose;
- this->size = 0;
-
- this->stream = stream;
- this->class = (qtsmc_class_t *) class_gen;
-
- this->decoder_ok = 0;
- this->buf = NULL;
-
- return &this->video_decoder;
-}
-
-static char *get_identifier (video_decoder_class_t *this) {
- return "QT SMC";
-}
-
-static char *get_description (video_decoder_class_t *this) {
- return "Quicktime Graphics (SMC) video decoder plugin";
-}
-
-static void dispose_class (video_decoder_class_t *this) {
- free (this);
-}
-
-static void *init_plugin (xine_t *xine, void *data) {
-
- qtsmc_class_t *this;
-
- this = (qtsmc_class_t *) xine_xmalloc (sizeof (qtsmc_class_t));
-
- this->decoder_class.open_plugin = open_plugin;
- this->decoder_class.get_identifier = get_identifier;
- this->decoder_class.get_description = get_description;
- this->decoder_class.dispose = dispose_class;
-
- return this;
-}
-
-/* plugin catalog information */
-static uint32_t supported_types[] = { BUF_VIDEO_SMC, 0 };
-
-static decoder_info_t video_decoder_info = {
- supported_types, /* supported types */
- 9 /* priority */
-};
-
-plugin_info_t xine_plugin_info[] = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_VIDEO_DECODER, 18, "smc", XINE_VERSION_CODE, &video_decoder_info, &init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
-
diff --git a/src/libxinevdec/roqvideo.c b/src/libxinevdec/roqvideo.c
deleted file mode 100644
index 7a316bfd6..000000000
--- a/src/libxinevdec/roqvideo.c
+++ /dev/null
@@ -1,578 +0,0 @@
-/*
- * Copyright (C) 2000-2003 the xine project
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * $Id: roqvideo.c,v 1.28 2004/02/09 22:04:11 jstembridge Exp $
- */
-
-/* And this is the header that came with the RoQ video decoder: */
-/* ------------------------------------------------------------------------
- * Id Software's RoQ video file format decoder
- *
- * Dr. Tim Ferguson, 2001.
- * For more details on the algorithm:
- * http://www.csse.monash.edu.au/~timf/videocodec.html
- *
- * This is a simple decoder for the Id Software RoQ video format. In
- * this format, audio samples are DPCM coded and the video frames are
- * coded using motion blocks and vector quantisation.
- *
- * Note: All information on the RoQ file format has been obtained through
- * pure reverse engineering. This was achieved by giving known input
- * audio and video frames to the roq.exe encoder and analysing the
- * resulting output text and RoQ file. No decompiling of the Quake III
- * Arena game was required.
- *
- * You may freely use this source code. I only ask that you reference its
- * source in your projects documentation:
- * Tim Ferguson: http://www.csse.monash.edu.au/~timf/
- * ------------------------------------------------------------------------ */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "xine_internal.h"
-#include "video_out.h"
-#include "buffer.h"
-#include "xineutils.h"
-
-#define VIDEOBUFSIZE 128*1024
-
-#define RoQ_INFO 0x1001
-#define RoQ_QUAD_CODEBOOK 0x1002
-#define RoQ_QUAD_VQ 0x1011
-#define RoQ_SOUND_MONO 0x1020
-#define RoQ_SOUND_STEREO 0x1021
-
-#define RoQ_ID_MOT 0x00
-#define RoQ_ID_FCC 0x01
-#define RoQ_ID_SLD 0x02
-#define RoQ_ID_CCC 0x03
-
-#define get_byte(in_buffer) *(in_buffer++)
-#define get_word(in_buffer) ((unsigned short)(in_buffer += 2, \
- (in_buffer[-1] << 8 | in_buffer[-2])))
-#define get_long(in_buffer) ((unsigned long)(in_buffer += 4, \
- (in_buffer[-1] << 24 | in_buffer[-2] << 16 | in_buffer[-3] << 8 | in_buffer[-4])))
-
-typedef struct {
- unsigned char y0, y1, y2, y3, u, v;
-} roq_cell;
-
-typedef struct {
- int idx[4];
-} roq_qcell;
-
-typedef struct {
- video_decoder_class_t decoder_class;
-} roqvideo_class_t;
-
-typedef struct roq_decoder_s {
- video_decoder_t video_decoder;
-
- roqvideo_class_t *class;
- xine_stream_t *stream;
-
-
- int video_step;
- int skipframes;
- unsigned char *buf;
- int bufsize;
- int size;
- int width;
- int height;
- double ratio;
-
- roq_cell cells[256];
- roq_qcell qcells[256];
- long roq_start, aud_pos, vid_pos;
- long *frame_offset;
- unsigned long num_frames, num_audio_bytes;
- unsigned char *y[2], *u[2], *v[2];
- int y_size;
- int c_size;
-
- unsigned char *cur_y, *cur_u, *cur_v;
- unsigned char *prev_y, *prev_u, *prev_v;
-
- /* this is either 0 or 1 indicating the cur_y points to y[0] or y[1],
- * same for u and v */
- int current_planes;
-
-} roqvideo_decoder_t;
-
-/**************************************************************************
- * RoQ video specific decode functions
- *************************************************************************/
-
-static void apply_vector_2x2(roqvideo_decoder_t *ri, int x, int y, roq_cell *cell) {
- unsigned char *yptr;
-
- yptr = ri->cur_y + (y * ri->width) + x;
- *yptr++ = cell->y0;
- *yptr++ = cell->y1;
- yptr += (ri->width - 2);
- *yptr++ = cell->y2;
- *yptr++ = cell->y3;
- ri->cur_u[(y/2) * (ri->width/2) + x/2] = cell->u;
- ri->cur_v[(y/2) * (ri->width/2) + x/2] = cell->v;
-}
-
-static void apply_vector_4x4(roqvideo_decoder_t *ri, int x, int y, roq_cell *cell) {
- unsigned long row_inc, c_row_inc;
- register unsigned char y0, y1, u, v;
- unsigned char *yptr, *uptr, *vptr;
-
- yptr = ri->cur_y + (y * ri->width) + x;
- uptr = ri->cur_u + (y/2) * (ri->width/2) + x/2;
- vptr = ri->cur_v + (y/2) * (ri->width/2) + x/2;
-
- row_inc = ri->width - 4;
- c_row_inc = (ri->width/2) - 2;
- *yptr++ = y0 = cell->y0; *uptr++ = u = cell->u; *vptr++ = v = cell->v;
- *yptr++ = y0;
- *yptr++ = y1 = cell->y1; *uptr++ = u; *vptr++ = v;
- *yptr++ = y1;
-
- yptr += row_inc;
-
- *yptr++ = y0;
- *yptr++ = y0;
- *yptr++ = y1;
- *yptr++ = y1;
-
- yptr += row_inc; uptr += c_row_inc; vptr += c_row_inc;
-
- *yptr++ = y0 = cell->y2; *uptr++ = u; *vptr++ = v;
- *yptr++ = y0;
- *yptr++ = y1 = cell->y3; *uptr++ = u; *vptr++ = v;
- *yptr++ = y1;
-
- yptr += row_inc;
-
- *yptr++ = y0;
- *yptr++ = y0;
- *yptr++ = y1;
- *yptr++ = y1;
-}
-
-static void apply_motion_4x4(roqvideo_decoder_t *ri, int x, int y, unsigned char mv,
- char mean_x, char mean_y)
-{
- int i, mx, my;
- unsigned char *pa, *pb;
-
- mx = x + 8 - (mv >> 4) - mean_x;
- my = y + 8 - (mv & 0xf) - mean_y;
-
- pa = ri->cur_y + (y * ri->width) + x;
- pb = ri->prev_y + (my * ri->width) + mx;
- for(i = 0; i < 4; i++) {
- pa[0] = pb[0];
- pa[1] = pb[1];
- pa[2] = pb[2];
- pa[3] = pb[3];
- pa += ri->width;
- pb += ri->width;
- }
-
- pa = ri->cur_u + (y/2) * (ri->width/2) + x/2;
- pb = ri->prev_u + (my/2) * (ri->width/2) + (mx + 1)/2;
- for(i = 0; i < 2; i++) {
- pa[0] = pb[0];
- pa[1] = pb[1];
- pa += ri->width/2;
- pb += ri->width/2;
- }
-
- pa = ri->cur_v + (y/2) * (ri->width/2) + x/2;
- pb = ri->prev_v + (my/2) * (ri->width/2) + (mx + 1)/2;
- for(i = 0; i < 2; i++) {
- pa[0] = pb[0];
- pa[1] = pb[1];
- pa += ri->width/2;
- pb += ri->width/2;
- }
-}
-
-static void apply_motion_8x8(roqvideo_decoder_t *ri, int x, int y,
- unsigned char mv, char mean_x, char mean_y) {
-
- int mx, my, i;
- unsigned char *pa, *pb;
-
- mx = x + 8 - (mv >> 4) - mean_x;
- my = y + 8 - (mv & 0xf) - mean_y;
-
- pa = ri->cur_y + (y * ri->width) + x;
- pb = ri->prev_y + (my * ri->width) + mx;
- for(i = 0; i < 8; i++) {
- pa[0] = pb[0];
- pa[1] = pb[1];
- pa[2] = pb[2];
- pa[3] = pb[3];
- pa[4] = pb[4];
- pa[5] = pb[5];
- pa[6] = pb[6];
- pa[7] = pb[7];
- pa += ri->width;
- pb += ri->width;
- }
-
- pa = ri->cur_u + (y/2) * (ri->width/2) + x/2;
- pb = ri->prev_u + (my/2) * (ri->width/2) + (mx + 1)/2;
- for(i = 0; i < 4; i++) {
- pa[0] = pb[0];
- pa[1] = pb[1];
- pa[2] = pb[2];
- pa[3] = pb[3];
- pa += ri->width/2;
- pb += ri->width/2;
- }
-
- pa = ri->cur_v + (y/2) * (ri->width/2) + x/2;
- pb = ri->prev_v + (my/2) * (ri->width/2) + (mx + 1)/2;
- for(i = 0; i < 4; i++) {
- pa[0] = pb[0];
- pa[1] = pb[1];
- pa[2] = pb[2];
- pa[3] = pb[3];
- pa += ri->width/2;
- pb += ri->width/2;
- }
-}
-
-static void roqvideo_decode_frame(roqvideo_decoder_t *ri) {
- unsigned int chunk_id = 0, chunk_arg = 0;
- unsigned long chunk_size = 0;
- int i, j, k, nv1, nv2, vqflg = 0, vqflg_pos = -1;
- int vqid, bpos, xpos, ypos, xp, yp, x, y;
- int frame_stats[2][4] = {{0},{0}};
- roq_qcell *qcell;
- unsigned char *buf = ri->buf;
- unsigned char *buf_end = ri->buf + ri->size;
-
- while (buf < buf_end) {
- chunk_id = get_word(buf);
- chunk_size = get_long(buf);
- chunk_arg = get_word(buf);
-
- if(chunk_id == RoQ_QUAD_VQ)
- break;
- if(chunk_id == RoQ_QUAD_CODEBOOK) {
- if((nv1 = chunk_arg >> 8) == 0)
- nv1 = 256;
- if((nv2 = chunk_arg & 0xff) == 0 && nv1 * 6 < chunk_size)
- nv2 = 256;
- for(i = 0; i < nv1; i++) {
- ri->cells[i].y0 = get_byte(buf);
- ri->cells[i].y1 = get_byte(buf);
- ri->cells[i].y2 = get_byte(buf);
- ri->cells[i].y3 = get_byte(buf);
- ri->cells[i].u = get_byte(buf);
- ri->cells[i].v = get_byte(buf);
- }
- for(i = 0; i < nv2; i++)
- for(j = 0; j < 4; j++)
- ri->qcells[i].idx[j] = get_byte(buf);
- }
- }
-
- bpos = xpos = ypos = 0;
- while(bpos < chunk_size) {
- for (yp = ypos; yp < ypos + 16; yp += 8)
- for (xp = xpos; xp < xpos + 16; xp += 8) {
- if (vqflg_pos < 0) {
- vqflg = buf[bpos++]; vqflg |= (buf[bpos++] << 8);
- vqflg_pos = 7;
- }
- vqid = (vqflg >> (vqflg_pos * 2)) & 0x3;
- frame_stats[0][vqid]++;
- vqflg_pos--;
-
- switch(vqid) {
- case RoQ_ID_MOT:
- apply_motion_8x8(ri, xp, yp, 0, 8, 8);
- break;
- case RoQ_ID_FCC:
- apply_motion_8x8(ri, xp, yp, buf[bpos++], chunk_arg >> 8,
- chunk_arg & 0xff);
- break;
- case RoQ_ID_SLD:
- qcell = ri->qcells + buf[bpos++];
- apply_vector_4x4(ri, xp, yp, ri->cells + qcell->idx[0]);
- apply_vector_4x4(ri, xp+4, yp, ri->cells + qcell->idx[1]);
- apply_vector_4x4(ri, xp, yp+4, ri->cells + qcell->idx[2]);
- apply_vector_4x4(ri, xp+4, yp+4, ri->cells + qcell->idx[3]);
- break;
- case RoQ_ID_CCC:
- for (k = 0; k < 4; k++) {
- x = xp; y = yp;
- if(k & 0x01) x += 4;
- if(k & 0x02) y += 4;
-
- if (vqflg_pos < 0) {
- vqflg = buf[bpos++];
- vqflg |= (buf[bpos++] << 8);
- vqflg_pos = 7;
- }
- vqid = (vqflg >> (vqflg_pos * 2)) & 0x3;
- frame_stats[1][vqid]++;
- vqflg_pos--;
- switch(vqid) {
- case RoQ_ID_MOT:
- apply_motion_4x4(ri, x, y, 0, 8, 8);
- break;
- case RoQ_ID_FCC:
- apply_motion_4x4(ri, x, y, buf[bpos++], chunk_arg >> 8,
- chunk_arg & 0xff);
- break;
- case RoQ_ID_SLD:
- qcell = ri->qcells + buf[bpos++];
- apply_vector_2x2(ri, x, y, ri->cells + qcell->idx[0]);
- apply_vector_2x2(ri, x+2, y, ri->cells + qcell->idx[1]);
- apply_vector_2x2(ri, x, y+2, ri->cells + qcell->idx[2]);
- apply_vector_2x2(ri, x+2, y+2, ri->cells + qcell->idx[3]);
- break;
- case RoQ_ID_CCC:
- apply_vector_2x2(ri, x, y, ri->cells + buf[bpos]);
- apply_vector_2x2(ri, x+2, y, ri->cells + buf[bpos+1]);
- apply_vector_2x2(ri, x, y+2, ri->cells + buf[bpos+2]);
- apply_vector_2x2(ri, x+2, y+2, ri->cells + buf[bpos+3]);
- bpos += 4;
- break;
- }
- }
- break;
- default:
- xprintf(ri->stream->xine, XINE_VERBOSITY_DEBUG, "Unknown vq code: %d\n", vqid);
- }
- }
-
- xpos += 16;
- if (xpos >= ri->width) {
- xpos -= ri->width;
- ypos += 16;
- }
- if(ypos >= ri->height)
- break;
- }
-}
-
-/**************************************************************************
- * xine video plugin functions
- *************************************************************************/
-
-static void roqvideo_decode_data (video_decoder_t *this_gen,
- buf_element_t *buf) {
-
- roqvideo_decoder_t *this = (roqvideo_decoder_t *) this_gen;
- vo_frame_t *img; /* video out frame */
-
- if (buf->decoder_flags & BUF_FLAG_PREVIEW)
- return;
-
- if (buf->decoder_flags & BUF_FLAG_STDHEADER) { /* need to initialize */
- xine_bmiheader *bih = (xine_bmiheader *)buf->content;
-
- this->stream->video_out->open (this->stream->video_out, this->stream);
-
- if(this->buf)
- free(this->buf);
-
- this->buf = xine_xmalloc(VIDEOBUFSIZE);
- this->bufsize = VIDEOBUFSIZE;
- this->size = 0;
- this->width = bih->biWidth;
- this->height = bih->biHeight;
- this->ratio = (double)this->width/(double)this->height;
- this->skipframes = 0;
- this->current_planes = 0;
-
- this->y_size = this->width * this->height;
- this->c_size = (this->width * this->height) / 4;
-
- this->y[0] = xine_xmalloc(this->y_size);
- this->y[1] = xine_xmalloc(this->y_size);
- memset(this->y[0], 0x00, this->y_size);
- memset(this->y[1], 0x00, this->y_size);
-
- this->u[0] = xine_xmalloc(this->c_size);
- this->u[1] = xine_xmalloc(this->c_size);
- memset(this->u[0], 0x80, this->c_size);
- memset(this->u[1], 0x80, this->c_size);
-
- this->v[0] = xine_xmalloc(this->c_size);
- this->v[1] = xine_xmalloc(this->c_size);
- memset(this->v[0], 0x80, this->c_size);
- memset(this->v[1], 0x80, this->c_size);
-
- /* load the stream/meta info */
- _x_meta_info_set(this->stream, XINE_META_INFO_VIDEOCODEC, "RoQ VQ Video");
-
- return;
- }
-
- if( this->size + buf->size > this->bufsize ) {
- this->bufsize = this->size + 2 * buf->size;
- xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
- "RoQ: increasing source buffer to %d to avoid overflow.\n", this->bufsize);
- this->buf = realloc( this->buf, this->bufsize );
- }
-
- xine_fast_memcpy (&this->buf[this->size], buf->content, buf->size);
- this->size += buf->size;
-
- if (buf->decoder_flags & BUF_FLAG_FRAMERATE) {
- this->video_step = buf->decoder_info[0];
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION, this->video_step);
- }
-
- if (buf->decoder_flags & BUF_FLAG_FRAME_END) { /* time to decode a frame */
- img = this->stream->video_out->get_frame (this->stream->video_out,
- this->width, this->height, this->ratio, XINE_IMGFMT_YV12,
- VO_BOTH_FIELDS);
-
- img->pts = buf->pts;
- img->duration = this->video_step;
-
- if (this->current_planes == 0) {
- this->cur_y = this->y[0];
- this->cur_u = this->u[0];
- this->cur_v = this->v[0];
- this->prev_y = this->y[1];
- this->prev_u = this->u[1];
- this->prev_v = this->v[1];
- this->current_planes = 1;
- } else {
- this->cur_y = this->y[1];
- this->cur_u = this->u[1];
- this->cur_v = this->v[1];
- this->prev_y = this->y[0];
- this->prev_u = this->u[0];
- this->prev_v = this->v[0];
- this->current_planes = 0;
- }
- roqvideo_decode_frame(this);
- xine_fast_memcpy(img->base[0], this->cur_y, this->y_size);
- xine_fast_memcpy(img->base[1], this->cur_u, this->c_size);
- xine_fast_memcpy(img->base[2], this->cur_v, this->c_size);
-
- this->skipframes = img->draw(img, this->stream);
- if( this->skipframes < 0 )
- this->skipframes = 0;
- img->free(img);
-
- this->size = 0;
- }
-}
-
-static void roqvideo_flush (video_decoder_t *this_gen) {
-}
-
-static void roqvideo_reset (video_decoder_t *this_gen) {
-}
-
-static void roqvideo_discontinuity (video_decoder_t *this_gen) {
-}
-
-static void roqvideo_dispose (video_decoder_t *this_gen) {
-
- roqvideo_decoder_t *this = (roqvideo_decoder_t *) this_gen;
-
- this->stream->video_out->close(this->stream->video_out, this->stream);
-
- free(this->y[0]);
- free(this->y[1]);
- free(this->u[0]);
- free(this->u[1]);
- free(this->v[0]);
- free(this->v[1]);
-
- free (this_gen);
-}
-
-static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stream_t *stream) {
-
- roqvideo_decoder_t *this ;
-
- this = (roqvideo_decoder_t *) xine_xmalloc (sizeof (roqvideo_decoder_t));
-
- this->video_decoder.decode_data = roqvideo_decode_data;
- this->video_decoder.flush = roqvideo_flush;
- this->video_decoder.reset = roqvideo_reset;
- this->video_decoder.discontinuity = roqvideo_discontinuity;
- this->video_decoder.dispose = roqvideo_dispose;
- this->size = 0;
-
- this->stream = stream;
- this->class = (roqvideo_class_t *) class_gen;
-
- this->buf = NULL;
-
- return &this->video_decoder;
-}
-
-static char *get_identifier (video_decoder_class_t *this) {
- return "RoQ Video";
-}
-
-static char *get_description (video_decoder_class_t *this) {
- return "Id RoQ video decoder plugin";
-}
-
-static void dispose_class (video_decoder_class_t *this) {
- free (this);
-}
-
-static void *init_plugin (xine_t *xine, void *data) {
-
- roqvideo_class_t *this;
-
- this = (roqvideo_class_t *) xine_xmalloc (sizeof (roqvideo_class_t));
-
- this->decoder_class.open_plugin = open_plugin;
- this->decoder_class.get_identifier = get_identifier;
- this->decoder_class.get_description = get_description;
- this->decoder_class.dispose = dispose_class;
-
- return this;
-}
-
-/*
- * exported plugin catalog entry
- */
-
-static uint32_t video_types[] = {
- BUF_VIDEO_ROQ,
- 0
- };
-
-static decoder_info_t dec_info_video = {
- video_types, /* supported types */
- 1 /* priority */
-};
-
-plugin_info_t xine_plugin_info[] = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_VIDEO_DECODER, 18, "roq", XINE_VERSION_CODE, &dec_info_video, init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
diff --git a/src/libxinevdec/svq1.c b/src/libxinevdec/svq1.c
deleted file mode 100644
index 6c93eb1ab..000000000
--- a/src/libxinevdec/svq1.c
+++ /dev/null
@@ -1,1507 +0,0 @@
-/*
- * Copyright (C) 2002-2003 the xine project
- *
- * This file is part of xine, a unix video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * $Id: svq1.c,v 1.32 2004/02/09 22:04:11 jstembridge Exp $
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "xine_internal.h"
-#include "video_out.h"
-#include "buffer.h"
-#include "bswap.h"
-#include "xineutils.h"
-
-#include "svq1_codebooks.h"
-
-#define VIDEOBUFSIZE 128 * 1024
-
-#define MEDIAN(a,b,c) ((a < b != b >= c) ? b : ((a < c != c > b) ? c : a))
-
-#define SVQ1_BLOCK_SKIP 0
-#define SVQ1_BLOCK_INTER 1
-#define SVQ1_BLOCK_INTER_4V 2
-#define SVQ1_BLOCK_INTRA 3
-
-#define SVQ1_FRAME_INTRA 0
-#define SVQ1_FRAME_INTER 1
-#define SVQ1_FRAME_DROPPABLE 2
-
-
-/* memory bit stream */
-typedef struct bit_buffer_s {
- uint8_t *buffer;
- unsigned int bitpos;
- unsigned int length;
-} bit_buffer_t;
-
-/* variable length (bit) code */
-typedef struct vlc_code_s {
- int16_t value :10,
- length :6;
-} vlc_code_t;
-
-/* motion vector (prediction) */
-typedef struct svq1_pmv_s {
- int x;
- int y;
-} svq1_pmv_t;
-
-typedef struct svq1_s {
- int frame_code;
- int frame_type;
- int frame_width;
- int frame_height;
- int luma_width;
- int luma_height;
- int chroma_width;
- int chroma_height;
- svq1_pmv_t *motion;
- uint8_t *current;
- uint8_t *previous;
- int offsets[3];
- int reference_frame;
-
- uint8_t *base[3];
- int width;
- int height;
- double ratio;
-} svq1_t;
-
-typedef struct {
- video_decoder_class_t decoder_class;
-} svq1_class_t;
-
-typedef struct svq1dec_decoder_s {
- video_decoder_t video_decoder;
-
- svq1_class_t *class;
- xine_stream_t *stream;
-
- int64_t video_step;
- int decoder_ok;
-
- unsigned char *buf;
- int bufsize;
- int size;
-
- svq1_t *svq1;
-} svq1dec_decoder_t;
-
-
-/* standard video sizes */
-static struct { int width; int height; } frame_size_table[8] = {
- { 160, 120 }, { 128, 96 }, { 176, 144 }, { 352, 288 },
- { 704, 576 }, { 240, 180 }, { 320, 240 }, { -1, -1 }
-};
-
-/* block type, codes 000 .. 1xx */
-static vlc_code_t block_type_table[8] = {
- { SVQ1_BLOCK_INTRA, 3 }, { SVQ1_BLOCK_INTER_4V, 3 },
- { SVQ1_BLOCK_INTER, 2 }, { SVQ1_BLOCK_INTER, 2 },
- { SVQ1_BLOCK_SKIP, 1 }, { SVQ1_BLOCK_SKIP, 1 },
- { SVQ1_BLOCK_SKIP, 1 }, { SVQ1_BLOCK_SKIP, 1 }
-};
-
-/* motion vector, codes 0000011 .. 011xxxx */
-static vlc_code_t motion_table_0[61] = {
- { 7, 8 }, { 6, 8 }, { 5, 8 }, { 4, 7 }, { 4, 7 },
- { 3, 5 }, { 3, 5 }, { 3, 5 }, { 3, 5 }, { 3, 5 }, { 3, 5 }, { 3, 5 }, { 3, 5 },
- { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 },
- { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }
-};
-
-/* motion vector, codes 000000000010 ... 0000010111xx */
-static vlc_code_t motion_table_1[94] = {
- {32, 13}, {31, 13}, {30, 12}, {30, 12}, {29, 12}, {29, 12},
- {28, 12}, {28, 12}, {27, 12}, {27, 12}, {26, 12}, {26, 12}, {25, 12}, {25, 12},
- {24, 11}, {24, 11}, {24, 11}, {24, 11}, {23, 11}, {23, 11}, {23, 11}, {23, 11},
- {22, 11}, {22, 11}, {22, 11}, {22, 11}, {21, 11}, {21, 11}, {21, 11}, {21, 11},
- {20, 11}, {20, 11}, {20, 11}, {20, 11}, {19, 11}, {19, 11}, {19, 11}, {19, 11},
- {18, 11}, {18, 11}, {18, 11}, {18, 11}, {17, 11}, {17, 11}, {17, 11}, {17, 11},
- {16, 11}, {16, 11}, {16, 11}, {16, 11}, {15, 11}, {15, 11}, {15, 11}, {15, 11},
- {14, 11}, {14, 11}, {14, 11}, {14, 11}, {13, 11}, {13, 11}, {13, 11}, {13, 11},
- {12, 11}, {12, 11}, {12, 11}, {12, 11}, {11, 11}, {11, 11}, {11, 11}, {11, 11},
- {10, 10}, {10, 10}, {10, 10}, {10, 10}, {10, 10}, {10, 10}, {10, 10}, {10, 10},
- { 9, 10}, { 9, 10}, { 9, 10}, { 9, 10}, { 9, 10}, { 9, 10}, { 9, 10}, { 9, 10},
- { 8, 10}, { 8, 10}, { 8, 10}, { 8, 10}, { 8, 10}, { 8, 10}, { 8, 10}, { 8, 10},
-};
-
-/* inter-coded vector codebook count tables, codes 000000 ... 111111 */
-static vlc_code_t inter_vector_tables[6][64] = {
- /* 4x2 vector, codes 0000xxx ... 11xxxxx */
- { { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 },
- { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 },
- { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 },
- { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 },
- {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 },
- {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 } },
-
- /* 4x4 vector, codes 0000xxx ... 11xxxxx */
- { { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 },
- { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 },
- { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 },
- { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 },
- {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 },
- {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 }, {-1, 2 } },
-
- /* 8x4 vector, codes 00000xx ... 1xxxxxx */
- { { 6, 5 }, { 6, 5 }, { 5, 5 }, { 5, 5 }, { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 },
- { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 } },
-
- /* 8x8 vector, codes 00000xx ... 1xxxxxx */
- { { 6, 5 }, { 6, 5 }, { 5, 5 }, { 5, 5 }, { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 },
- { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 } },
-
- /* 16x8 vector, codes 00000xx ... 1xxxxxx */
- { { 6, 5 }, { 6, 5 }, { 5, 5 }, { 5, 5 }, { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 },
- { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 }, { 2, 4 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 }, { 0, 3 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 } },
-
- /* 16x16 vector, codes 000000x ... 1xxxxxx */
- { { 6, 6 }, { 5, 6 }, { 4, 5 }, { 4, 5 }, { 3, 5 }, { 3, 5 }, { 2, 5 }, { 2, 5 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 },
- { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 },
- {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 }, {-1, 1 } }
-};
-
-/* vector codebook count tables, codes 0000000 ... 1111111 */
-static vlc_code_t intra_vector_tables[6][128] = {
- /* 4x2 vector, codes 00000xx ... 1xxxxxx */
- { { 5, 5 }, { 5, 5 }, { 5, 5 }, { 5, 5 }, {-1, 5 }, {-1, 5 }, {-1, 5 }, {-1, 5 },
- { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 },
- { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 },
- { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 },
- { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 },
- { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 } },
-
- /* 4x4 vector, codes 0000xxx ... 11xxxxx */
- { { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 },
- {-1, 4 }, {-1, 4 }, {-1, 4 }, {-1, 4 }, {-1, 4 }, {-1, 4 }, {-1, 4 }, {-1, 4 },
- { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 },
- { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 },
- { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 },
- { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 },
- { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 },
- { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 }, { 3, 3 },
- { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 },
- { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 },
- { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 },
- { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 },
- { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 2 } },
-
- /* 8x4 vector, codes 00000xx ... 1xxxxxx */
- { { 2, 5 }, { 2, 5 }, { 2, 5 }, { 2, 5 }, {-1, 5 }, {-1, 5 }, {-1, 5 }, {-1, 5 },
- { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 },
- { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 }, { 5, 4 },
- { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 },
- { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 },
- { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 }, { 4, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 } },
-
- /* 8x8 vector, codes 000000x ... 1xxxxxx */
- { { 2, 6 }, { 2, 6 }, {-1, 6 }, {-1, 6 }, { 5, 5 }, { 5, 5 }, { 5, 5 }, { 5, 5 },
- { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 }, { 6, 4 },
- { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 }, { 4, 4 },
- { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 } },
-
- /* 16x8 vector, codes 000000x ... 1xxxxxx */
- { { 4, 6 }, { 4, 6 }, {-1, 6 }, {-1, 6 }, { 5, 5 }, { 5, 5 }, { 5, 5 }, { 5, 5 },
- { 3, 5 }, { 3, 5 }, { 3, 5 }, { 3, 5 }, { 2, 5 }, { 2, 5 }, { 2, 5 }, { 2, 5 },
- { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 },
- { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 }, { 6, 3 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 } },
-
- /* 16x16 vector, codes 0000000 ... 1xxxxxx */
- { { 5, 7 }, {-1, 7 }, { 4, 6 }, { 4, 6 }, { 6, 5 }, { 6, 5 }, { 6, 5 }, { 6, 5 },
- { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 }, { 3, 4 },
- { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 },
- { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 }, { 2, 3 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 }, { 1, 2 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 } }
-};
-
-/* intra mean value, codes 00100101 ... 1111xxxx */
-static vlc_code_t intra_mean_table_0[219] = {
- {135, 8 }, {136, 8 }, {165, 8 },
- {134, 8 }, {129, 8 }, {164, 8 }, {163, 8 }, {133, 8 }, {162, 8 }, {174, 8 }, {175, 8 },
- {161, 8 }, {160, 8 }, {159, 8 }, {158, 8 }, {157, 8 }, {156, 8 }, {155, 8 }, {154, 8 },
- {153, 8 }, {151, 8 }, {152, 8 }, {132, 8 }, {110, 8 }, {131, 8 }, {108, 8 }, {130, 8 },
- {166, 8 }, {105, 8 }, {104, 8 }, {103, 8 }, {127, 8 }, {101, 8 }, {167, 8 }, {168, 8 },
- { 98, 8 }, {128, 8 }, { 48, 8 }, { 95, 8 }, { 62, 8 }, { 93, 8 }, { 92, 8 }, { 91, 8 },
- { 90, 8 }, { 89, 8 }, { 60, 8 }, { 87, 8 }, { 86, 8 }, { 57, 8 }, { 84, 8 }, { 83, 8 },
- { 82, 8 }, { 81, 8 }, { 80, 8 }, { 79, 8 }, { 78, 8 }, { 77, 8 }, { 76, 8 }, { 75, 8 },
- { 74, 8 }, { 73, 8 }, { 72, 8 }, { 71, 8 }, { 70, 8 }, { 69, 8 }, { 68, 8 }, { 67, 8 },
- { 66, 8 }, { 65, 8 }, { 56, 8 }, { 63, 8 }, { 23, 8 }, { 61, 8 }, { 30, 8 }, { 59, 8 },
- { 58, 8 }, { 52, 8 }, { 29, 8 }, { 55, 8 }, { 54, 8 }, { 53, 8 }, { 50, 8 }, { 51, 8 },
- { 22, 8 }, { 49, 8 }, { 85, 7 }, { 85, 7 }, { 97, 7 }, { 97, 7 }, { 88, 7 }, { 88, 7 },
- { 64, 7 }, { 64, 7 }, { 94, 7 }, { 94, 7 }, {106, 7 }, {106, 7 }, {107, 7 }, {107, 7 },
- {109, 7 }, {109, 7 }, {111, 7 }, {111, 7 }, {112, 7 }, {112, 7 }, {113, 7 }, {113, 7 },
- {114, 7 }, {114, 7 }, {115, 7 }, {115, 7 }, {116, 7 }, {116, 7 }, {117, 7 }, {117, 7 },
- {118, 7 }, {118, 7 }, {119, 7 }, {119, 7 }, {120, 7 }, {120, 7 }, { 99, 7 }, { 99, 7 },
- {102, 7 }, {102, 7 }, { 28, 7 }, { 28, 7 }, {100, 7 }, {100, 7 }, { 96, 7 }, { 96, 7 },
- {139, 7 }, {139, 7 }, { 24, 7 }, { 24, 7 }, { 1, 7 }, { 1, 7 }, {138, 7 }, {138, 7 },
- {121, 7 }, {121, 7 }, {122, 7 }, {122, 7 }, {123, 7 }, {123, 7 }, {124, 7 }, {124, 7 },
- {125, 7 }, {125, 7 }, {126, 7 }, {126, 7 }, {137, 7 }, {137, 7 }, {140, 7 }, {140, 7 },
- {150, 7 }, {150, 7 }, {144, 7 }, {144, 7 }, {141, 7 }, {141, 7 }, {142, 7 }, {142, 7 },
- {143, 7 }, {143, 7 }, {145, 7 }, {145, 7 }, {147, 7 }, {147, 7 }, {146, 7 }, {146, 7 },
- { 27, 6 }, { 27, 6 }, { 27, 6 }, { 27, 6 }, {148, 6 }, {148, 6 }, {148, 6 }, {148, 6 },
- {149, 6 }, {149, 6 }, {149, 6 }, {149, 6 }, { 0, 6 }, { 0, 6 }, { 0, 6 }, { 0, 6 },
- { 26, 4 }, { 26, 4 }, { 26, 4 }, { 26, 4 }, { 26, 4 }, { 26, 4 }, { 26, 4 }, { 26, 4 },
- { 26, 4 }, { 26, 4 }, { 26, 4 }, { 26, 4 }, { 26, 4 }, { 26, 4 }, { 26, 4 }, { 26, 4 },
- { 25, 4 }, { 25, 4 }, { 25, 4 }, { 25, 4 }, { 25, 4 }, { 25, 4 }, { 25, 4 }, { 25, 4 },
- { 25, 4 }, { 25, 4 }, { 25, 4 }, { 25, 4 }, { 25, 4 }, { 25, 4 }, { 25, 4 }, { 25, 4 }
-};
-
-/* intra mean value, codes 0000001101 ... 001001001x */
-static vlc_code_t intra_mean_table_1[135] = {
- {218, 10}, {219, 10}, {220, 10},
- {221, 10}, {222, 10}, {217, 10}, {230, 10}, {215, 10}, {208, 10}, {207, 10}, {206, 10},
- {214, 10}, {204, 10}, {223, 10}, {224, 10}, {225, 10}, {226, 10}, {227, 10}, {228, 10},
- {229, 10}, {213, 10}, {212, 10}, {231, 10}, {232, 10}, {211, 10}, {210, 10}, {236, 10},
- {209, 10}, {216, 10}, {205, 10}, { 18, 10}, {186, 9 }, {186, 9 }, {185, 9 }, {185, 9 },
- {184, 9 }, {184, 9 }, {182, 9 }, {182, 9 }, {183, 9 }, {183, 9 }, {180, 9 }, {180, 9 },
- {181, 9 }, {181, 9 }, {178, 9 }, {178, 9 }, {187, 9 }, {187, 9 }, {176, 9 }, {176, 9 },
- {188, 9 }, {188, 9 }, {179, 9 }, {179, 9 }, {173, 9 }, {173, 9 }, {172, 9 }, {172, 9 },
- {171, 9 }, {171, 9 }, {170, 9 }, {170, 9 }, {169, 9 }, {169, 9 }, {189, 9 }, {189, 9 },
- {190, 9 }, {190, 9 }, {191, 9 }, {191, 9 }, {192, 9 }, {192, 9 }, {193, 9 }, {193, 9 },
- {194, 9 }, {194, 9 }, {195, 9 }, {195, 9 }, {196, 9 }, {196, 9 }, {197, 9 }, {197, 9 },
- {198, 9 }, {198, 9 }, {200, 9 }, {200, 9 }, {201, 9 }, {201, 9 }, {202, 9 }, {202, 9 },
- {203, 9 }, {203, 9 }, {199, 9 }, {199, 9 }, {177, 9 }, {177, 9 }, { 40, 9 }, { 40, 9 },
- { 39, 9 }, { 39, 9 }, { 38, 9 }, { 38, 9 }, { 37, 9 }, { 37, 9 }, { 36, 9 }, { 36, 9 },
- { 35, 9 }, { 35, 9 }, { 34, 9 }, { 34, 9 }, { 33, 9 }, { 33, 9 }, { 32, 9 }, { 32, 9 },
- { 31, 9 }, { 31, 9 }, { 21, 9 }, { 21, 9 }, { 11, 9 }, { 11, 9 }, { 41, 9 }, { 41, 9 },
- { 45, 9 }, { 45, 9 }, { 44, 9 }, { 44, 9 }, { 42, 9 }, { 42, 9 }, { 43, 9 }, { 43, 9 },
- { 47, 9 }, { 47, 9 }, { 46, 9 }, { 46, 9 }
-};
-
-/* intra mean value, codes 00000000000001 ... 00000011001xxx */
-static vlc_code_t intra_mean_table_2[207] = {
- {255, 14}, { 14, 14}, { 13, 14}, { 17, 12}, { 17, 12}, { 17, 12}, { 17, 12},
- {243, 11}, {243, 11}, {243, 11}, {243, 11}, {243, 11}, {243, 11}, {243, 11}, {243, 11},
- {242, 11}, {242, 11}, {242, 11}, {242, 11}, {242, 11}, {242, 11}, {242, 11}, {242, 11},
- {241, 11}, {241, 11}, {241, 11}, {241, 11}, {241, 11}, {241, 11}, {241, 11}, {241, 11},
- {240, 11}, {240, 11}, {240, 11}, {240, 11}, {240, 11}, {240, 11}, {240, 11}, {240, 11},
- {237, 11}, {237, 11}, {237, 11}, {237, 11}, {237, 11}, {237, 11}, {237, 11}, {237, 11},
- {239, 11}, {239, 11}, {239, 11}, {239, 11}, {239, 11}, {239, 11}, {239, 11}, {239, 11},
- {235, 11}, {235, 11}, {235, 11}, {235, 11}, {235, 11}, {235, 11}, {235, 11}, {235, 11},
- {234, 11}, {234, 11}, {234, 11}, {234, 11}, {234, 11}, {234, 11}, {234, 11}, {234, 11},
- {233, 11}, {233, 11}, {233, 11}, {233, 11}, {233, 11}, {233, 11}, {233, 11}, {233, 11},
- {244, 11}, {244, 11}, {244, 11}, {244, 11}, {244, 11}, {244, 11}, {244, 11}, {244, 11},
- {238, 11}, {238, 11}, {238, 11}, {238, 11}, {238, 11}, {238, 11}, {238, 11}, {238, 11},
- { 20, 11}, { 20, 11}, { 20, 11}, { 20, 11}, { 20, 11}, { 20, 11}, { 20, 11}, { 20, 11},
- {248, 11}, {248, 11}, {248, 11}, {248, 11}, {248, 11}, {248, 11}, {248, 11}, {248, 11},
- {249, 11}, {249, 11}, {249, 11}, {249, 11}, {249, 11}, {249, 11}, {249, 11}, {249, 11},
- {250, 11}, {250, 11}, {250, 11}, {250, 11}, {250, 11}, {250, 11}, {250, 11}, {250, 11},
- {251, 11}, {251, 11}, {251, 11}, {251, 11}, {251, 11}, {251, 11}, {251, 11}, {251, 11},
- {252, 11}, {252, 11}, {252, 11}, {252, 11}, {252, 11}, {252, 11}, {252, 11}, {252, 11},
- {253, 11}, {253, 11}, {253, 11}, {253, 11}, {253, 11}, {253, 11}, {253, 11}, {253, 11},
- {254, 11}, {254, 11}, {254, 11}, {254, 11}, {254, 11}, {254, 11}, {254, 11}, {254, 11},
- { 12, 11}, { 12, 11}, { 12, 11}, { 12, 11}, { 12, 11}, { 12, 11}, { 12, 11}, { 12, 11},
- { 10, 11}, { 10, 11}, { 10, 11}, { 10, 11}, { 10, 11}, { 10, 11}, { 10, 11}, { 10, 11},
- {245, 11}, {245, 11}, {245, 11}, {245, 11}, {245, 11}, {245, 11}, {245, 11}, {245, 11},
- {247, 11}, {247, 11}, {247, 11}, {247, 11}, {247, 11}, {247, 11}, {247, 11}, {247, 11},
- { 19, 11}, { 19, 11}, { 19, 11}, { 19, 11}, { 19, 11}, { 19, 11}, { 19, 11}, { 19, 11},
- {246, 11}, {246, 11}, {246, 11}, {246, 11}, {246, 11}, {246, 11}, {246, 11}, {246, 11}
-};
-
-/* intra mean value, codes 00000000000000000000 ... 000000000000001xxxxx */
-static vlc_code_t intra_mean_table_3[64] = {
- { 6, 20}, { 3, 20}, { 4, 20}, { 5, 20}, { 7, 20}, { 8, 20}, { 9, 19}, { 9, 19},
- { 2, 17}, { 2, 17}, { 2, 17}, { 2, 17}, { 2, 17}, { 2, 17}, { 2, 17}, { 2, 17},
- { 16, 16}, { 16, 16}, { 16, 16}, { 16, 16}, { 16, 16}, { 16, 16}, { 16, 16}, { 16, 16},
- { 16, 16}, { 16, 16}, { 16, 16}, { 16, 16}, { 16, 16}, { 16, 16}, { 16, 16}, { 16, 16},
- { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15},
- { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15},
- { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15},
- { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}, { 15, 15}
-};
-
-/* inter mean value, codes 00001011 ... 1xxxxxxx */
-static vlc_code_t inter_mean_table_0[245] = {
- { 10, 8 }, { 12, 8 }, { 11, 8 }, {-11, 8 }, {-12, 8 },
- {-10, 8 }, { -9, 8 }, { -7, 7 }, { -7, 7 }, { -6, 7 }, { -6, 7 }, { 8, 7 }, { 8, 7 },
- { -8, 7 }, { -8, 7 }, { 9, 7 }, { 9, 7 }, { 6, 7 }, { 6, 7 }, { 7, 7 }, { 7, 7 },
- { -5, 6 }, { -5, 6 }, { -5, 6 }, { -5, 6 }, { -4, 6 }, { -4, 6 }, { -4, 6 }, { -4, 6 },
- { 5, 6 }, { 5, 6 }, { 5, 6 }, { 5, 6 }, { 4, 6 }, { 4, 6 }, { 4, 6 }, { 4, 6 },
- { 3, 5 }, { 3, 5 }, { 3, 5 }, { 3, 5 }, { 3, 5 }, { 3, 5 }, { 3, 5 }, { 3, 5 },
- { 2, 5 }, { 2, 5 }, { 2, 5 }, { 2, 5 }, { 2, 5 }, { 2, 5 }, { 2, 5 }, { 2, 5 },
- { -2, 5 }, { -2, 5 }, { -2, 5 }, { -2, 5 }, { -2, 5 }, { -2, 5 }, { -2, 5 }, { -2, 5 },
- { -3, 5 }, { -3, 5 }, { -3, 5 }, { -3, 5 }, { -3, 5 }, { -3, 5 }, { -3, 5 }, { -3, 5 },
- { -1, 4 }, { -1, 4 }, { -1, 4 }, { -1, 4 }, { -1, 4 }, { -1, 4 }, { -1, 4 }, { -1, 4 },
- { -1, 4 }, { -1, 4 }, { -1, 4 }, { -1, 4 }, { -1, 4 }, { -1, 4 }, { -1, 4 }, { -1, 4 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 }, { 1, 3 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }
-};
-
-/* inter mean value, codes 000000010010 ... 00001011xxxx */
-static vlc_code_t inter_mean_table_1[158] = {
- {-30, 12}, {-31, 12}, {-32, 12}, {-33, 12}, { 31, 12}, {-34, 12},
- {-35, 12}, { 29, 12}, { 30, 12}, { 33, 12}, { 34, 12}, { 32, 12}, {-29, 11}, {-29, 11},
- {-28, 11}, {-28, 11}, { 28, 11}, { 28, 11}, {-27, 11}, {-27, 11}, {-26, 11}, {-26, 11},
- { 27, 11}, { 27, 11}, { 26, 11}, { 26, 11}, { 25, 11}, { 25, 11}, { 24, 11}, { 24, 11},
- { 23, 11}, { 23, 11}, { 22, 11}, { 22, 11}, {-24, 11}, {-24, 11}, {-25, 11}, {-25, 11},
- {-23, 10}, {-23, 10}, {-23, 10}, {-23, 10}, {-21, 10}, {-21, 10}, {-21, 10}, {-21, 10},
- {-20, 10}, {-20, 10}, {-20, 10}, {-20, 10}, {-19, 10}, {-19, 10}, {-19, 10}, {-19, 10},
- {-18, 10}, {-18, 10}, {-18, 10}, {-18, 10}, {-22, 10}, {-22, 10}, {-22, 10}, {-22, 10},
- { 19, 10}, { 19, 10}, { 19, 10}, { 19, 10}, { 21, 10}, { 21, 10}, { 21, 10}, { 21, 10},
- { 20, 10}, { 20, 10}, { 20, 10}, { 20, 10}, { 18, 10}, { 18, 10}, { 18, 10}, { 18, 10},
- {-14, 9 }, {-14, 9 }, {-14, 9 }, {-14, 9 }, {-14, 9 }, {-14, 9 }, {-14, 9 }, {-14, 9 },
- {-17, 9 }, {-17, 9 }, {-17, 9 }, {-17, 9 }, {-17, 9 }, {-17, 9 }, {-17, 9 }, {-17, 9 },
- { 16, 9 }, { 16, 9 }, { 16, 9 }, { 16, 9 }, { 16, 9 }, { 16, 9 }, { 16, 9 }, { 16, 9 },
- { 13, 9 }, { 13, 9 }, { 13, 9 }, { 13, 9 }, { 13, 9 }, { 13, 9 }, { 13, 9 }, { 13, 9 },
- { 14, 9 }, { 14, 9 }, { 14, 9 }, { 14, 9 }, { 14, 9 }, { 14, 9 }, { 14, 9 }, { 14, 9 },
- { 15, 9 }, { 15, 9 }, { 15, 9 }, { 15, 9 }, { 15, 9 }, { 15, 9 }, { 15, 9 }, { 15, 9 },
- { 17, 9 }, { 17, 9 }, { 17, 9 }, { 17, 9 }, { 17, 9 }, { 17, 9 }, { 17, 9 }, { 17, 9 },
- {-13, 9 }, {-13, 9 }, {-13, 9 }, {-13, 9 }, {-13, 9 }, {-13, 9 }, {-13, 9 }, {-13, 9 },
- {-16, 9 }, {-16, 9 }, {-16, 9 }, {-16, 9 }, {-16, 9 }, {-16, 9 }, {-16, 9 }, {-16, 9 },
- {-15, 9 }, {-15, 9 }, {-15, 9 }, {-15, 9 }, {-15, 9 }, {-15, 9 }, {-15, 9 }, {-15, 9 }
-};
-
-/* inter mean value, codes 000000000010111 ... 0000000100011xx */
-static vlc_code_t inter_mean_table_2[121] = {
- { 61, 15},
- { 52, 15}, { 58, 15}, {-56, 15}, {-57, 15}, { 59, 15}, {-55, 15}, { 60, 15}, {-54, 15},
- { 53, 15}, {-62, 15}, {-60, 15}, {-59, 15}, {-58, 15}, { 57, 15}, { 56, 15}, {-53, 15},
- { 55, 15}, { 54, 15}, { 50, 14}, { 50, 14}, { 45, 14}, { 45, 14}, {-52, 14}, {-52, 14},
- {-51, 14}, {-51, 14}, {-50, 14}, {-50, 14}, { 46, 14}, { 46, 14}, {-49, 14}, {-49, 14},
- {-48, 14}, {-48, 14}, { 48, 14}, { 48, 14}, {-47, 14}, {-47, 14}, { 49, 14}, { 49, 14},
- {-45, 14}, {-45, 14}, {-44, 14}, {-44, 14}, { 47, 14}, { 47, 14}, { 51, 14}, { 51, 14},
- { 44, 14}, { 44, 14}, {-46, 14}, {-46, 14}, {-43, 13}, {-43, 13}, {-43, 13}, {-43, 13},
- {-42, 13}, {-42, 13}, {-42, 13}, {-42, 13}, {-41, 13}, {-41, 13}, {-41, 13}, {-41, 13},
- {-40, 13}, {-40, 13}, {-40, 13}, {-40, 13}, {-39, 13}, {-39, 13}, {-39, 13}, {-39, 13},
- {-38, 13}, {-38, 13}, {-38, 13}, {-38, 13}, {-37, 13}, {-37, 13}, {-37, 13}, {-37, 13},
- {-36, 13}, {-36, 13}, {-36, 13}, {-36, 13}, { 42, 13}, { 42, 13}, { 42, 13}, { 42, 13},
- { 36, 13}, { 36, 13}, { 36, 13}, { 36, 13}, { 43, 13}, { 43, 13}, { 43, 13}, { 43, 13},
- { 41, 13}, { 41, 13}, { 41, 13}, { 41, 13}, { 40, 13}, { 40, 13}, { 40, 13}, { 40, 13},
- { 35, 13}, { 35, 13}, { 35, 13}, { 35, 13}, { 39, 13}, { 39, 13}, { 39, 13}, { 39, 13},
- { 38, 13}, { 38, 13}, { 38, 13}, { 38, 13}, { 37, 13}, { 37, 13}, { 37, 13}, { 37, 13}
-};
-
-/* inter mean value, codes 000000000000100101 ... 0000000000101101xx */
-static vlc_code_t inter_mean_table_3[147] = {
- {111, 18}, {102, 18}, { 99, 18},
- {-86, 18}, { 97, 18}, {-97, 18}, { 96, 18}, {-95, 18}, {-76, 18}, {-77, 18}, {-78, 18},
- {-85, 18}, {-80, 18}, {-81, 18}, { 89, 18}, { 90, 18}, {-84, 18}, {-89, 18}, { 80, 18},
- {-90, 18}, {-88, 18}, { 92, 18}, { 93, 18}, { 95, 18}, {-109,18}, {-79, 17}, {-79, 17},
- {-83, 17}, {-83, 17}, {-75, 17}, {-75, 17}, {-74, 17}, {-74, 17}, {-73, 17}, {-73, 17},
- {-72, 17}, {-72, 17}, { 87, 17}, { 87, 17}, { 86, 17}, { 86, 17}, { 75, 17}, { 75, 17},
- { 85, 17}, { 85, 17}, { 84, 17}, { 84, 17}, { 81, 17}, { 81, 17}, { 79, 17}, { 79, 17},
- { 74, 17}, { 74, 17}, { 72, 17}, { 72, 17}, { 82, 17}, { 82, 17}, { 78, 17}, { 78, 17},
- { 83, 17}, { 83, 17}, { 76, 17}, { 76, 17}, { 73, 17}, { 73, 17}, { 77, 17}, { 77, 17},
- { 70, 16}, { 70, 16}, { 70, 16}, { 70, 16}, { 69, 16}, { 69, 16}, { 69, 16}, { 69, 16},
- { 64, 16}, { 64, 16}, { 64, 16}, { 64, 16}, {-68, 16}, {-68, 16}, {-68, 16}, {-68, 16},
- {-66, 16}, {-66, 16}, {-66, 16}, {-66, 16}, { 68, 16}, { 68, 16}, { 68, 16}, { 68, 16},
- {-69, 16}, {-69, 16}, {-69, 16}, {-69, 16}, { 65, 16}, { 65, 16}, { 65, 16}, { 65, 16},
- { 71, 16}, { 71, 16}, { 71, 16}, { 71, 16}, {-70, 16}, {-70, 16}, {-70, 16}, {-70, 16},
- {-65, 16}, {-65, 16}, {-65, 16}, {-65, 16}, {-67, 16}, {-67, 16}, {-67, 16}, {-67, 16},
- {-63, 16}, {-63, 16}, {-63, 16}, {-63, 16}, {-71, 16}, {-71, 16}, {-71, 16}, {-71, 16},
- { 67, 16}, { 67, 16}, { 67, 16}, { 67, 16}, {-61, 16}, {-61, 16}, {-61, 16}, {-61, 16},
- {-64, 16}, {-64, 16}, {-64, 16}, {-64, 16}, { 63, 16}, { 63, 16}, { 63, 16}, { 63, 16},
- { 62, 16}, { 62, 16}, { 62, 16}, { 62, 16}, { 66, 16}, { 66, 16}, { 66, 16}, { 66, 16}
-};
-
-/* inter mean value, codes 00000000000001001001 ... 0000000000001001001x */
-static vlc_code_t inter_mean_table_4[75] = {
- {142, 20}, {135, 20}, {125, 20}, {123, 20}, {122, 20}, {119, 20}, {117, 20},
- {113, 20}, {104, 20}, {103, 20}, {-120,20}, {-114,20}, {-108,20}, {-104,20}, {-102,20},
- {-101,20}, {-93, 20}, {-91, 19}, {-91, 19}, {-96, 19}, {-96, 19}, { 88, 19}, { 88, 19},
- { 91, 19}, { 91, 19}, { 94, 19}, { 94, 19}, {121, 19}, {121, 19}, {120, 19}, {120, 19},
- {-110,19}, {-110,19}, {118, 19}, {118, 19}, {115, 19}, {115, 19}, {114, 19}, {114, 19},
- {112, 19}, {112, 19}, {107, 19}, {107, 19}, {110, 19}, {110, 19}, {109, 19}, {109, 19},
- {108, 19}, {108, 19}, {-103,19}, {-103,19}, {106, 19}, {106, 19}, {105, 19}, {105, 19},
- {-100,19}, {-100,19}, {101, 19}, {101, 19}, {100, 19}, {100, 19}, {-99, 19}, {-99, 19},
- {-82, 19}, {-82, 19}, {-87, 19}, {-87, 19}, {-94, 19}, {-94, 19}, {-98, 19}, {-98, 19},
- { 98, 19}, { 98, 19}, {-92, 19}, {-92, 19}
-};
-
-/* inter mean value, codes 0000000000000000000000 ... 000000000000010010001x */
-static vlc_code_t inter_mean_table_5[292] = {
- {255, 22}, {254, 22}, {253, 22}, {252, 22}, {251, 22}, {250, 22}, {249, 22}, {248, 22},
- {247, 22}, {246, 22}, {245, 22}, {244, 22}, {243, 22}, {242, 22}, {241, 22}, {240, 22},
- {239, 22}, {238, 22}, {237, 22}, {236, 22}, {235, 22}, {234, 22}, {233, 22}, {232, 22},
- {231, 22}, {230, 22}, {229, 22}, {228, 22}, {227, 22}, {226, 22}, {225, 22}, {224, 22},
- {223, 22}, {222, 22}, {221, 22}, {220, 22}, {219, 22}, {218, 22}, {217, 22}, {216, 22},
- {215, 22}, {214, 22}, {213, 22}, {212, 22}, {211, 22}, {210, 22}, {209, 22}, {208, 22},
- {207, 22}, {206, 22}, {205, 22}, {204, 22}, {203, 22}, {202, 22}, {201, 22}, {200, 22},
- {199, 22}, {198, 22}, {197, 22}, {196, 22}, {195, 22}, {194, 22}, {193, 22}, {192, 22},
- {191, 22}, {190, 22}, {189, 22}, {188, 22}, {187, 22}, {186, 22}, {185, 22}, {184, 22},
- {183, 22}, {182, 22}, {181, 22}, {180, 22}, {179, 22}, {178, 22}, {177, 22}, {176, 22},
- {175, 22}, {174, 22}, {173, 22}, {172, 22}, {171, 22}, {170, 22}, {169, 22}, {168, 22},
- {167, 22}, {166, 22}, {-256,22}, {164, 22}, {-211,22}, {162, 22}, {161, 22}, {160, 22},
- {-210,22}, {-168,22}, {157, 22}, {156, 22}, {155, 22}, {154, 22}, {153, 22}, {152, 22},
- {151, 22}, {150, 22}, {149, 22}, {148, 22}, {147, 22}, {146, 22}, {145, 22}, {144, 22},
- {143, 22}, {-208,22}, {141, 22}, {140, 22}, {139, 22}, {-200,22}, {137, 22}, {136, 22},
- {-198,22}, {134, 22}, {133, 22}, {-196,22}, {-201,22}, {130, 22}, {129, 22}, {128, 22},
- {127, 22}, {126, 22}, {-195,22}, {124, 22}, {-167,22}, {-166,22}, {-165,22}, {-164,22},
- {-163,22}, {-162,22}, {-161,22}, {-180,22}, {-160,22}, {-159,22}, {-158,22}, {-157,22},
- {-156,22}, {-155,22}, {-154,22}, {-153,22}, {-152,22}, {-151,22}, {-150,22}, {-149,22},
- {-148,22}, {-147,22}, {-146,22}, {-145,22}, {-144,22}, {-143,22}, {-142,22}, {-141,22},
- {-140,22}, {-139,22}, {-138,22}, {-137,22}, {-136,22}, {-135,22}, {-134,22}, {-133,22},
- {-132,22}, {-131,22}, {-130,22}, {-129,22}, {-126,22}, {-125,22}, {-124,22}, {-123,22},
- {-122,22}, {-121,22}, {-118,22}, {-116,22}, {-115,22}, {-113,22}, {-112,22}, {-107,22},
- {-106,22}, {-169,22}, {-170,22}, {-171,22}, {-172,22}, {-173,22}, {-174,22}, {-175,22},
- {-176,22}, {-177,22}, {-178,22}, {-187,22}, {-179,22}, {-181,22}, {-182,22}, {-183,22},
- {-184,22}, {-185,22}, {-186,22}, {-235,22}, {-188,22}, {-189,22}, {-190,22}, {-191,22},
- {-192,22}, {-193,22}, {-194,22}, {-197,22}, {-255,22}, {-254,22}, {-253,22}, {-252,22},
- {-251,22}, {-250,22}, {-249,22}, {-248,22}, {-247,22}, {-246,22}, {-245,22}, {-244,22},
- {-243,22}, {-242,22}, {-241,22}, {-240,22}, {-239,22}, {-238,22}, {-237,22}, {-232,22},
- {-236,22}, {-234,22}, {-233,22}, {-217,22}, {-231,22}, {-230,22}, {-229,22}, {-228,22},
- {-227,22}, {-226,22}, {-225,22}, {-224,22}, {-223,22}, {-222,22}, {-221,22}, {-220,22},
- {-219,22}, {-216,22}, {-202,22}, {-205,22}, {-215,22}, {-214,22}, {-213,22}, {-204,22},
- {-212,22}, {-209,22}, {-218,22}, {-199,22}, {-207,22}, {-206,22}, {165, 21}, {165, 21},
- {131, 21}, {131, 21}, {163, 21}, {163, 21}, {-203,21}, {-203,21}, {116, 21}, {116, 21},
- {159, 21}, {159, 21}, {138, 21}, {138, 21}, {158, 21}, {158, 21}, {-105,21}, {-105,21},
- {-111,21}, {-111,21}, {132, 21}, {132, 21}, {128, 21}, {128, 21}, {-127,21}, {-127,21},
- {-119,21}, {-119,21}, {-117,21}, {-117,21}
-};
-
-
-static uint32_t get_bits (bit_buffer_t *bitbuf, int count) {
- uint32_t result;
-
- /* avoid buffer overflow */
- if ((bitbuf->bitpos + 24) >= bitbuf->length) {
- int i;
-
- /* load upto 24 bits of data on sub-byte offset */
- result = 0;
-
- for (i=(bitbuf->bitpos & ~0x7); i < bitbuf->length; i+=8) {
- result |= bitbuf->buffer[i >> 3] << (24 + (bitbuf->bitpos - i));
- }
- } else {
- /* load 32 bits of data (byte-aligned) */
- result = BE_32 (&bitbuf->buffer[bitbuf->bitpos >> 3]);
-
- /* compensate for sub-byte offset */
- result <<= (bitbuf->bitpos & 0x7);
- }
-
- /* flush num bits */
- bitbuf->bitpos += count;
-
- /* return num bits */
- return result >> (32 - count);
-}
-
-/*
- * Return next 32 bits (left aligned).
- */
-static uint32_t get_bit_cache(bit_buffer_t *bitbuf) {
- uint32_t result;
-
- /* avoid buffer overflow */
- if ((bitbuf->bitpos + 24) >= bitbuf->length) {
- int i;
-
- /* load upto 24 bits of data on sub-byte offset */
- result = 0;
-
- for (i=(bitbuf->bitpos & ~0x7); i < bitbuf->length; i+=8) {
- result |= bitbuf->buffer[i >> 3] << (24 + (bitbuf->bitpos - i));
- }
- } else {
- /* load 32 bits of data (byte-aligned) */
- result = BE_32 (&bitbuf->buffer[bitbuf->bitpos >> 3]);
-
- /* compensate for sub-byte offset */
- result <<= (bitbuf->bitpos & 0x7);
- }
-
- return result;
-}
-
-static int decode_svq1_block (bit_buffer_t *bitbuf, uint8_t *pixels, int pitch, int intra) {
- uint32_t bit_cache;
- vlc_code_t *vlc;
- uint8_t *list[63];
- uint32_t *dst;
- uint32_t *codebook;
- int entries[6];
- int i, j, m, n;
- int mean, stages;
- int x, y, width, height, level;
- uint32_t n1, n2, n3, n4;
-
- /* initialize list for breadth first processing of vectors */
- list[0] = pixels;
-
- /* recursively process vector */
- for (i=0, m=1, n=1, level=5; i < n; i++) {
- for (; level > 0; i++) {
-
- /* process next depth */
- if (i == m) {
- m = n;
-
- if (--level == 0)
- break;
- }
-
- /* divide block if next bit set */
- if (get_bits (bitbuf, 1) == 0)
- break;
-
- /* add child nodes */
- list[n++] = list[i];
- list[n++] = list[i] + (((level & 1) ? pitch : 1) << ((level / 2) + 1));
- }
-
- /* destination address and vector size */
- dst = (uint32_t *) list[i];
- width = 1 << ((4 + level) /2);
- height = 1 << ((3 + level) /2);
-
- /* get number of stages (-1 skips vector, 0 for mean only) */
- bit_cache = get_bit_cache (bitbuf);
-
- if (intra)
- vlc = &intra_vector_tables[level][bit_cache >> (32 - 7)];
- else
- vlc = &inter_vector_tables[level][bit_cache >> (32 - 6)];
-
- /* flush bits */
- stages = vlc->value;
- bitbuf->bitpos += vlc->length;
-
- if (stages == -1) {
- if (intra) {
- for (y=0; y < height; y++) {
- memset (&dst[y*(pitch / 4)], 0, width);
- }
- }
- continue; /* skip vector */
- }
-
- if ((stages > 0) && (level >= 4)) {
- return -1; /* invalid vector */
- }
-
- /* get mean value for vector */
- bit_cache = get_bit_cache (bitbuf);
-
- if (intra) {
- if (bit_cache >= 0x25000000)
- vlc = &intra_mean_table_0[(bit_cache >> (32 - 8)) - 37];
- else if (bit_cache >= 0x03400000)
- vlc = &intra_mean_table_1[(bit_cache >> (32 - 10)) - 13];
- else if (bit_cache >= 0x00040000)
- vlc = &intra_mean_table_2[(bit_cache >> (32 - 14)) - 1];
- else
- vlc = &intra_mean_table_3[bit_cache >> (32 - 20)];
- } else {
- if (bit_cache >= 0x0B000000)
- vlc = &inter_mean_table_0[(bit_cache >> (32 - 8)) - 11];
- else if (bit_cache >= 0x01200000)
- vlc = &inter_mean_table_1[(bit_cache >> (32 - 12)) - 18];
- else if (bit_cache >= 0x002E0000)
- vlc = &inter_mean_table_2[(bit_cache >> (32 - 15)) - 23];
- else if (bit_cache >= 0x00094000)
- vlc = &inter_mean_table_3[(bit_cache >> (32 - 18)) - 37];
- else if (bit_cache >= 0x00049000)
- vlc = &inter_mean_table_4[(bit_cache >> (32 - 20)) - 73];
- else
- vlc = &inter_mean_table_5[bit_cache >> (32 - 22)];
- }
-
- /* flush bits */
- mean = vlc->value;
- bitbuf->bitpos += vlc->length;
-
- if (intra && stages == 0) {
- for (y=0; y < height; y++) {
- memset (&dst[y*(pitch / 4)], mean, width);
- }
- } else {
- codebook = (uint32_t *) (intra ? intra_codebooks[level] : inter_codebooks[level]);
- bit_cache = get_bits (bitbuf, 4*stages);
-
- /* calculate codebook entries for this vector */
- for (j=0; j < stages; j++) {
- entries[j] = (((bit_cache >> (4*(stages - j - 1))) & 0xF) + 16*j) << (level + 1);
- }
-
- mean -= (stages * 128);
- n4 = ((mean + (mean >> 31)) << 16) | (mean & 0xFFFF);
-
- for (y=0; y < height; y++) {
- for (x=0; x < (width / 4); x++, codebook++) {
- if (intra) {
- n1 = n4;
- n2 = n4;
- } else {
- n3 = dst[x];
-
- /* add mean value to vector */
- n1 = ((n3 & 0xFF00FF00) >> 8) + n4;
- n2 = (n3 & 0x00FF00FF) + n4;
- }
-
- /* add codebook entries to vector */
- for (j=0; j < stages; j++) {
- n3 = codebook[entries[j]] ^ 0x80808080;
- n1 += ((n3 & 0xFF00FF00) >> 8);
- n2 += (n3 & 0x00FF00FF);
- }
-
- /* clip to [0..255] */
- if (n1 & 0xFF00FF00) {
- n3 = ((( n1 >> 15) & 0x00010001) | 0x01000100) - 0x00010001;
- n1 += 0x7F007F00;
- n1 |= (((~n1 >> 15) & 0x00010001) | 0x01000100) - 0x00010001;
- n1 &= (n3 & 0x00FF00FF);
- }
-
- if (n2 & 0xFF00FF00) {
- n3 = ((( n2 >> 15) & 0x00010001) | 0x01000100) - 0x00010001;
- n2 += 0x7F007F00;
- n2 |= (((~n2 >> 15) & 0x00010001) | 0x01000100) - 0x00010001;
- n2 &= (n3 & 0x00FF00FF);
- }
-
- /* store result */
- dst[x] = (n1 << 8) | n2;
- }
-
- dst += (pitch / 4);
- }
- }
- }
-
- return 0;
-}
-
-static int decode_motion_vector (bit_buffer_t *bitbuf, svq1_pmv_t *mv, svq1_pmv_t **pmv) {
- uint32_t bit_cache;
- vlc_code_t *vlc;
- int diff, sign;
- int i;
-
- for (i=0; i < 2; i++) {
-
- /* get motion code */
- bit_cache = get_bit_cache (bitbuf);
-
- if (!(bit_cache & 0xFFE00000))
- return -1; /* invalid vlc code */
-
- if (bit_cache & 0x80000000) {
- diff = 0;
-
- /* flush bit */
- bitbuf->bitpos++;
-
- } else {
- if (bit_cache >= 0x06000000) {
- vlc = &motion_table_0[(bit_cache >> (32 - 7)) - 3];
- } else {
- vlc = &motion_table_1[(bit_cache >> (32 - 12)) - 2];
- }
-
- /* decode motion vector differential */
- sign = (int) (bit_cache << (vlc->length - 1)) >> 31;
- diff = (vlc->value ^ sign) - sign;
-
- /* flush bits */
- bitbuf->bitpos += vlc->length;
- }
-
- /* add median of motion vector predictors and clip result */
- if (i == 1)
- mv->y = ((diff + MEDIAN(pmv[0]->y, pmv[1]->y, pmv[2]->y)) << 26) >> 26;
- else
- mv->x = ((diff + MEDIAN(pmv[0]->x, pmv[1]->x, pmv[2]->x)) << 26) >> 26;
- }
-
- return 0;
-}
-
-static void clip_motion_vector (int x, int y, int width, int height, svq1_pmv_t *mv) {
-
- if (mv->x < -2*x)
- mv->x = -2*x;
- else if (mv->x > 2*(width - x))
- mv->x = 2*(width - x);
-
- if (mv->y < -2*y)
- mv->y = -2*y;
- else if (mv->y > 2*(height - y))
- mv->y = 2*(height - y);
-}
-
-static void skip_block (uint8_t *current, uint8_t *previous, int pitch, int x, int y) {
- uint8_t *src;
- uint8_t *dst;
- int i;
-
- src = &previous[x + y*pitch];
- dst = current;
-
- for (i=0; i < 16; i++) {
- memcpy (dst, src, 16);
- src += pitch;
- dst += pitch;
- }
-}
-
-static int motion_inter_block (bit_buffer_t *bitbuf,
- uint8_t *current, uint8_t *previous, int pitch,
- svq1_pmv_t *motion,
- unsigned int x, unsigned int y,
- unsigned int width, unsigned int height) {
- uint8_t *src;
- uint8_t *dst;
- svq1_pmv_t mv;
- svq1_pmv_t *pmv[3];
- int sx, sy;
- int result;
-
- /* predict and decode motion vector */
- pmv[0] = &motion[0];
- pmv[1] = &motion[(x / 8) + 2];
- pmv[2] = &motion[(x / 8) + 4];
-
- if (y == 0) {
- pmv[1] = pmv[0];
- pmv[2] = pmv[0];
- }
-
- result = decode_motion_vector (bitbuf, &mv, pmv);
-
- if (result != 0)
- return result;
-
- motion[0].x = mv.x;
- motion[0].y = mv.y;
- motion[(x / 8) + 2].x = mv.x;
- motion[(x / 8) + 2].y = mv.y;
- motion[(x / 8) + 3].x = mv.x;
- motion[(x / 8) + 3].y = mv.y;
-
- /* clip motion vector to frame border */
- clip_motion_vector (x, y, (width - 16), (height - 16), &mv);
-
- src = &previous[(x + (mv.x >> 1)) + (y + (mv.y >> 1))*pitch];
- dst = current;
-
- /* form prediction */
- if (mv.y & 0x1) {
- if (mv.x & 0x1) {
- for (sy=0; sy < 16; sy++) {
- for (sx=0; sx < 16; sx++) {
- dst[sx] = (src[sx] + src[sx + 1] + src[sx + pitch] + src[sx + pitch + 1] + 2) >> 2;
- }
- src += pitch;
- dst += pitch;
- }
- } else {
- for (sy=0; sy < 16; sy++) {
- for (sx=0; sx < 16; sx++) {
- dst[sx] = (src[sx] + src[sx + pitch] + 1) >> 1;
- }
- src += pitch;
- dst += pitch;
- }
- }
- } else {
- if (mv.x & 0x1) {
- for (sy=0; sy < 16; sy++) {
- for (sx=0; sx < 16; sx++) {
- dst[sx] = (src[sx] + src[sx + 1] + 1) >> 1;
- }
- src += pitch;
- dst += pitch;
- }
- } else {
- for (sy=0; sy < 16; sy++) {
- memcpy (dst, src, 16);
- src += pitch;
- dst += pitch;
- }
- }
- }
-
- return 0;
-}
-
-static int motion_inter_4v_block (bit_buffer_t *bitbuf,
- uint8_t *current, uint8_t *previous, int pitch,
- svq1_pmv_t *motion,
- unsigned int x, unsigned int y,
- unsigned int width, unsigned int height) {
- uint8_t *src;
- uint8_t *dst;
- svq1_pmv_t mv;
- svq1_pmv_t *pmv[4];
- int sx, sy;
- int i, result;
-
- /* predict and decode motion vector (0) */
- pmv[0] = &motion[0];
- pmv[1] = &motion[(x / 8) + 2];
- pmv[2] = &motion[(x / 8) + 4];
-
- if (y == 0) {
- pmv[1] = pmv[0];
- pmv[2] = pmv[0];
- }
-
- result = decode_motion_vector (bitbuf, &mv, pmv);
-
- if (result != 0)
- return result;
-
- /* predict and decode motion vector (1) */
- pmv[0] = &mv;
- pmv[1] = &motion[(x / 8) + 3];
-
- if (y == 0) {
- pmv[1] = pmv[0];
- pmv[2] = pmv[0];
- }
-
- result = decode_motion_vector (bitbuf, &motion[0], pmv);
-
- if (result != 0)
- return result;
-
- /* predict and decode motion vector (2) */
- pmv[1] = &motion[0];
- pmv[2] = &motion[(x / 8) + 1];
-
- result = decode_motion_vector (bitbuf, &motion[(x / 8) + 2], pmv);
-
- if (result != 0)
- return result;
-
- /* predict and decode motion vector (3) */
- pmv[2] = &motion[(x / 8) + 2];
- pmv[3] = &motion[(x / 8) + 3];
-
- result = decode_motion_vector (bitbuf, pmv[3], pmv);
-
- if (result != 0)
- return result;
-
- /* clip motion vectors to frame border */
- clip_motion_vector (x, y, (width - 8), (height - 8), pmv[0]);
- clip_motion_vector ((x + 8), y, (width - 8), (height - 8), pmv[1]);
- clip_motion_vector (x, (y + 8), (width - 8), (height - 8), pmv[2]);
- clip_motion_vector ((x + 8), (y + 8), (width - 8), (height - 8), pmv[3]);
-
- /* form predictions */
- for (i=0; i < 4; i++) {
- src = &previous[(x + (pmv[i]->x >> 1)) + (y + (pmv[i]->y >> 1))*pitch];
- dst = current;
-
- if (pmv[i]->y & 0x1) {
- if (pmv[i]->x & 0x1) {
- for (sy=0; sy < 8; sy++) {
- for (sx=0; sx < 8; sx++) {
- dst[sx] = (src[sx] + src[sx + 1] + src[sx + pitch] + src[sx + pitch + 1] + 2) >> 2;
- }
- src += pitch;
- dst += pitch;
- }
- } else {
- for (sy=0; sy < 8; sy++) {
- for (sx=0; sx < 8; sx++) {
- dst[sx] = (src[sx] + src[sx + pitch] + 1) >> 1;
- }
- src += pitch;
- dst += pitch;
- }
- }
- } else {
- if (pmv[i]->x & 0x1) {
- for (sy=0; sy < 8; sy++) {
- for (sx=0; sx < 8; sx++) {
- dst[sx] = (src[sx] + src[sx + 1] + 1) >> 1;
- }
- src += pitch;
- dst += pitch;
- }
- } else {
- for (sy=0; sy < 8; sy++) {
- memcpy (dst, src, 8);
- src += pitch;
- dst += pitch;
- }
- }
- }
-
- /* select next block */
- if (i & 1) {
- current += 8*(pitch - 1);
- previous += 8*(pitch - 1);
- } else {
- current += 8;
- previous += 8;
- }
- }
-
- return 0;
-}
-
-static int decode_delta_block (bit_buffer_t *bitbuf,
- uint8_t *current, uint8_t *previous, int pitch,
- svq1_pmv_t *motion,
- unsigned int x, unsigned int y,
- unsigned int width, unsigned int height) {
- uint32_t bit_cache;
- uint32_t block_type;
- int result = 0;
-
- /* get block type */
- bit_cache = get_bit_cache (bitbuf);
-
- bit_cache >>= (32 - 3);
- block_type = block_type_table[bit_cache].value;
- bitbuf->bitpos += block_type_table[bit_cache].length;
-
- /* reset motion vectors */
- if (block_type == SVQ1_BLOCK_SKIP || block_type == SVQ1_BLOCK_INTRA) {
- motion[0].x = 0;
- motion[0].y = 0;
- motion[(x / 8) + 2].x = 0;
- motion[(x / 8) + 2].y = 0;
- motion[(x / 8) + 3].x = 0;
- motion[(x / 8) + 3].y = 0;
- }
-
- switch (block_type) {
- case SVQ1_BLOCK_SKIP:
- skip_block (current, previous, pitch, x, y);
- break;
-
- case SVQ1_BLOCK_INTER:
- result = motion_inter_block (bitbuf, current, previous, pitch, motion, x, y, width, height);
-
- if (result != 0)
- break;
-
- result = decode_svq1_block (bitbuf, current, pitch, 0);
- break;
-
- case SVQ1_BLOCK_INTER_4V:
- result = motion_inter_4v_block (bitbuf, current, previous, pitch, motion, x, y, width, height);
-
- if (result != 0)
- break;
-
- result = decode_svq1_block (bitbuf, current, pitch, 0);
- break;
-
- case SVQ1_BLOCK_INTRA:
- result = decode_svq1_block (bitbuf, current, pitch, 1);
- break;
- }
-
- return result;
-}
-
-static int decode_frame_header (bit_buffer_t *bitbuf, svq1_t *svq1) {
- int frame_size_code;
-
- /* unknown field */
- get_bits (bitbuf, 8);
-
- /* frame type */
- svq1->frame_type = get_bits (bitbuf, 2);
-
- if (svq1->frame_type == 3)
- return -1;
-
- if (svq1->frame_type == SVQ1_FRAME_INTRA) {
-
- /* unknown fields */
- if (svq1->frame_code == 0x50 || svq1->frame_code == 0x60) {
- get_bits (bitbuf, 16);
- }
-
- if ((svq1->frame_code ^ 0x10) >= 0x50) {
- bitbuf->bitpos += 8*get_bits (bitbuf, 8);
- }
-
- get_bits (bitbuf, 2);
- get_bits (bitbuf, 2);
- get_bits (bitbuf, 1);
-
- /* load frame size */
- frame_size_code = get_bits (bitbuf, 3);
-
- if (frame_size_code == 7) {
- /* load width, height (12 bits each) */
- svq1->frame_width = get_bits (bitbuf, 12);
- svq1->frame_height = get_bits (bitbuf, 12);
-
- if (!svq1->frame_width || !svq1->frame_height)
- return -1;
- } else {
- /* get width, height from table */
- svq1->frame_width = frame_size_table[frame_size_code].width;
- svq1->frame_height = frame_size_table[frame_size_code].height;
- }
- }
-
- /* unknown fields */
- if (get_bits (bitbuf, 1) == 1) {
- get_bits (bitbuf, 1);
- get_bits (bitbuf, 1);
-
- if (get_bits (bitbuf, 2) != 0)
- return -1;
- }
-
- if (get_bits (bitbuf, 1) == 1) {
- get_bits (bitbuf, 1);
- get_bits (bitbuf, 4);
- get_bits (bitbuf, 1);
- get_bits (bitbuf, 2);
-
- while (get_bits (bitbuf, 1) == 1) {
- get_bits (bitbuf, 8);
- }
- }
-
- return 0;
-}
-
-static int svq1_decode_frame (svq1_t *svq1, uint8_t *buffer, int length) {
- bit_buffer_t bitbuf;
- uint8_t *current, *previous;
- int result, i, x, y, width, height;
- int luma_size, chroma_size;
-
- /* initialize bit buffer */
- bitbuf.buffer = buffer;
- bitbuf.bitpos = 0;
- bitbuf.length = 8*length;
-
- /* decode frame header */
- svq1->frame_code = get_bits (&bitbuf, 22);
-
- if ((svq1->frame_code & ~0x70) || !(svq1->frame_code & 0x60))
- return -1;
-
- /* swap some header bytes (why?) */
- if (svq1->frame_code != 0x20) {
- uint32_t *src = (uint32_t *) (buffer + 4);
-
- for (i=0; i < 4; i++) {
- src[i] = ((src[i] << 16) | (src[i] >> 16)) ^ src[7 - i];
- }
- }
-
- result = decode_frame_header (&bitbuf, svq1);
-
- if (result != 0 || bitbuf.bitpos > bitbuf.length)
- return result;
-
- /* check frame size (changed?) */
- if (((svq1->frame_width + 3) & ~0x3) != svq1->width ||
- ((svq1->frame_height + 3) & ~0x3) != svq1->height) {
-
- /* free current buffers */
- free (svq1->current);
- free (svq1->previous);
- free (svq1->motion);
-
- svq1->width = (svq1->frame_width + 3) & ~0x3;
- svq1->height = (svq1->frame_height + 3) & ~0x3;
- svq1->ratio = (double)svq1->width/(double)svq1->height;
- svq1->luma_width = (svq1->width + 15) & ~0xF;
- svq1->luma_height = (svq1->height + 15) & ~0xF;
- svq1->chroma_width = ((svq1->width / 4) + 15) & ~0xF;
- svq1->chroma_height = ((svq1->height / 4) + 15) & ~0xF;
-
- /* allocate new pixel and motion buffers for updated frame size */
- luma_size = svq1->luma_width * svq1->luma_height;
- chroma_size = svq1->chroma_width * svq1->chroma_height;
-
- svq1->motion = (svq1_pmv_t *) malloc (((svq1->luma_width / 8) + 3) * sizeof(svq1_pmv_t));
- svq1->current = (uint8_t *) malloc (luma_size + 2*chroma_size);
- svq1->previous = (uint8_t *) malloc (luma_size + 2*chroma_size);
- svq1->offsets[0] = 0;
- svq1->offsets[1] = luma_size;
- svq1->offsets[2] = luma_size + chroma_size;
-
- for (i=0; i < 3; i++) {
- svq1->base[i] = svq1->current + svq1->offsets[i];
- }
-
- svq1->reference_frame = 0;
- }
-
- /* delta frame requires reference frame */
- if (svq1->frame_type != SVQ1_FRAME_INTRA && !svq1->reference_frame)
- return -1;
-
- /* decode y, u and v components */
- for (i=0; i < 3; i++) {
- if (i == 0) {
- width = svq1->luma_width;
- height = svq1->luma_height;
- } else {
- width = svq1->chroma_width;
- height = svq1->chroma_height;
- }
-
- current = svq1->current + svq1->offsets[i];
- previous = svq1->previous + svq1->offsets[i];
-
- if (svq1->frame_type == SVQ1_FRAME_INTRA) {
- /* keyframe */
- for (y=0; y < height; y+=16) {
- for (x=0; x < width; x+=16) {
- result = decode_svq1_block (&bitbuf, &current[x], width, 1);
-
- if (result != 0 || bitbuf.bitpos > bitbuf.length)
- return result;
- }
-
- current += 16*width;
- }
- } else {
- /* delta frame */
- memset (svq1->motion, 0, ((width / 8) + 3) * sizeof(svq1_pmv_t));
-
- for (y=0; y < height; y+=16) {
- for (x=0; x < width; x+=16) {
- result = decode_delta_block (&bitbuf, &current[x], previous,
- width, svq1->motion, x, y, width, height);
-
- if (result != 0 || bitbuf.bitpos > bitbuf.length)
- return result;
- }
-
- svq1->motion[0].x = 0;
- svq1->motion[0].y = 0;
-
- current += 16*width;
- }
- }
- }
-
- /* update pixel buffers for frame copy */
- for (i=0; i < 3; i++) {
- svq1->base[i] = svq1->current + svq1->offsets[i];
- }
-
- /* update backward reference frame */
- if (svq1->frame_type != SVQ1_FRAME_DROPPABLE) {
- uint8_t *tmp = svq1->previous;
- svq1->previous = svq1->current;
- svq1->current = tmp;
- svq1->reference_frame = 1;
- }
-
- return 0;
-}
-
-static void svq1dec_decode_data (video_decoder_t *this_gen, buf_element_t *buf) {
- svq1dec_decoder_t *this = (svq1dec_decoder_t *) this_gen;
-
- if (buf->decoder_flags & BUF_FLAG_PREVIEW)
- return;
-
- if (buf->decoder_flags & BUF_FLAG_FRAMERATE) {
- this->video_step = buf->decoder_info[0];
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION, this->video_step);
- }
-
- if (buf->decoder_flags & BUF_FLAG_STDHEADER) {
- if (this->buf)
- free (this->buf);
- this->bufsize = VIDEOBUFSIZE;
- this->buf = malloc(this->bufsize);
- this->size = 0;
-
- this->stream->video_out->open (this->stream->video_out, this->stream);
- this->decoder_ok = 1;
-
- /* load the stream/meta info */
- _x_meta_info_set(this->stream, XINE_META_INFO_VIDEOCODEC, "Sorenson Video 1");
-
- } else if (this->decoder_ok) {
-
- if (this->size + buf->size > this->bufsize) {
- this->bufsize = this->size + 2 * buf->size;
- this->buf = realloc (this->buf, this->bufsize);
- }
-
- xine_fast_memcpy (&this->buf[this->size], buf->content, buf->size);
-
- this->size += buf->size;
-
- if (buf->decoder_flags & BUF_FLAG_FRAME_END) {
-
- vo_frame_t *img;
- int result;
-
- result = svq1_decode_frame (this->svq1, this->buf, this->size);
-
- if (this->svq1->width > 0 && this->svq1->height > 0) {
-
- img = this->stream->video_out->get_frame (this->stream->video_out,
- this->svq1->width,
- this->svq1->height,
- this->svq1->ratio,
- XINE_IMGFMT_YV12,
- VO_BOTH_FIELDS);
-
- img->duration = this->video_step;
- img->pts = buf->pts;
- img->bad_frame = (result != 0);
-
- if (result == 0) {
- yuv9_to_yv12 (this->svq1->base[0], this->svq1->luma_width,
- img->base[0], img->pitches[0],
- this->svq1->base[1], this->svq1->chroma_width,
- img->base[1], img->pitches[1],
- this->svq1->base[2], this->svq1->chroma_width,
- img->base[2], img->pitches[2],
- this->svq1->width, this->svq1->height);
- }
-
- img->draw(img, this->stream);
- img->free(img);
- }
-
- this->size = 0;
- }
- }
-}
-
-static void svq1dec_flush (video_decoder_t *this_gen) {
-}
-
-static void svq1dec_reset (video_decoder_t *this_gen) {
- svq1dec_decoder_t *this = (svq1dec_decoder_t *) this_gen;
-
- if (this->svq1) {
- this->svq1->reference_frame = 0;
- }
-
- this->size = 0;
-}
-
-static void svq1dec_discontinuity (video_decoder_t *this_gen) {
-}
-
-static void svq1dec_dispose (video_decoder_t *this_gen) {
-
- svq1dec_decoder_t *this = (svq1dec_decoder_t *) this_gen;
-
- if (this->svq1) {
- free (this->svq1->current);
- free (this->svq1->previous);
- free (this->svq1->motion);
- free (this->svq1);
- this->svq1 = NULL;
- }
-
- if (this->buf) {
- free (this->buf);
- this->buf = NULL;
- }
-
- if (this->decoder_ok) {
- this->decoder_ok = 0;
- this->stream->video_out->close(this->stream->video_out, this->stream);
- }
-
- free (this_gen);
-}
-
-static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stream_t *stream) {
-
- svq1dec_decoder_t *this ;
-
- this = (svq1dec_decoder_t *) xine_xmalloc (sizeof (svq1dec_decoder_t));
-
- this->video_decoder.decode_data = svq1dec_decode_data;
- this->video_decoder.flush = svq1dec_flush;
- this->video_decoder.reset = svq1dec_reset;
- this->video_decoder.discontinuity = svq1dec_discontinuity;
- this->video_decoder.dispose = svq1dec_dispose;
- this->size = 0;
-
- this->stream = stream;
- this->class = (svq1_class_t *) class_gen;
-
- this->svq1 = (svq1_t *) xine_xmalloc (sizeof(svq1_t));
-
- this->decoder_ok = 0;
- this->buf = NULL;
-
- return &this->video_decoder;
-}
-
-static char *get_identifier (video_decoder_class_t *this) {
- return "SVQ1";
-}
-
-static char *get_description (video_decoder_class_t *this) {
- return "Sorenson Video v1 decoder plugin";
-}
-
-static void dispose_class (video_decoder_class_t *this) {
- free (this);
-}
-
-static void *init_plugin (xine_t *xine, void *data) {
-
- svq1_class_t *this;
-
- this = (svq1_class_t *) xine_xmalloc (sizeof (svq1_class_t));
-
- this->decoder_class.open_plugin = open_plugin;
- this->decoder_class.get_identifier = get_identifier;
- this->decoder_class.get_description = get_description;
- this->decoder_class.dispose = dispose_class;
-
- return this;
-}
-
-/*
- * exported plugin catalog entry
- */
-
-static uint32_t video_types[] = {
- BUF_VIDEO_SORENSON_V1,
- 0
- };
-
-static decoder_info_t dec_info_video = {
- video_types, /* supported types */
- 6 /* priority */
-};
-
-plugin_info_t xine_plugin_info[] = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_VIDEO_DECODER, 18, "svq1", XINE_VERSION_CODE, &dec_info_video, init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
diff --git a/src/libxinevdec/svq1_codebooks.h b/src/libxinevdec/svq1_codebooks.h
deleted file mode 100644
index 062ed2721..000000000
--- a/src/libxinevdec/svq1_codebooks.h
+++ /dev/null
@@ -1,1506 +0,0 @@
-/*
- * Copyright (C) 2002-2003 the xine project
- *
- * This file is part of xine, a unix video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * $Id: svq1_codebooks.h,v 1.2 2003/12/09 00:02:34 f1rmb Exp $
- */
-
-#include <inttypes.h>
-
-
-/* 6x16-entry codebook for inter-coded 4x2 vectors */
-static int8_t inter_codebook_4x2[768] = {
- 7, 2, -6, -7, 7, 3, -3, -4, -7, -2, 7, 8, -8, -4, 3, 4,
- 19, 17, 9, 3,-14,-16,-12, -8,-18,-16, -8, -3, 11, 14, 12, 8,
- 7,-16,-10, 20, 7,-17,-10, 20, -6, 18, 8,-21, -7, 18, 9,-20,
- 25, 3,-20,-14, 29, 7,-18,-13,-29, -4, 21, 14,-31, -6, 20, 14,
- -19,-26,-28,-24, 31, 32, 22, 10, 15, 24, 31, 28,-32,-32,-22,-13,
- 2, -8,-23,-26, -9, 3, 27, 35, 3, 11, 21, 21, 8, -4,-27,-34,
- -30,-31, 12, 47,-29,-30, 13, 47, 38, 30,-17,-46, 34, 26,-19,-46,
- -42,-50,-51,-43, 34, 48, 55, 48, 48, 54, 51, 42,-44,-52,-53,-47,
- 4, 5, 0, -6, -2, -2, 0, 1,-11, -6, -1, -2, 1, 8, 9, 1,
- 0, 1, -6, 5, 8, 1,-12, 2, 7,-14, -7, 8, 5, -8, 0, 8,
- 1, 4, 11, 8,-12, -8, 0, -5, -1, 1, 0, 4,-15, -8, 3, 16,
- 17, 8, -4, -6, 9, -4,-13, -8, 2, 6, 1,-18, -1, 11, 11,-12,
- 6, 0, 2, 0, 14, 6, -7,-21, 1, -1,-13,-20, 1, 1, 10, 21,
- -22, -5, 7, 13,-11, -1, 4, 12, -7, 0, 14, 19, -4, 3, -5,-19,
- -26,-14, 10, 15, 18, 4, -6, -2, 25, 19, -5,-18,-20, -7, 4, 2,
- -13, -6, -1, -4, 25, 37, -2,-35, 5, 4, 1, 1,-21,-36, 2, 43,
- 2, -2, -1, 3, 8, -2, -6, -1, -2, -3, 2, 12, -5, -2, -2, -1,
- -3, -1, -1, -5, -1, 7, 8, -2, 2, 7, 5, -3, 1, 1, -3, -8,
- -3, -1, -3, -2, -2, -3, 2, 13, 15, 0,-11, -6, 3, 0, 0, 0,
- -6, -9, -5, -4, 18, 4, 1, 3, 12, 3, 0, 4,-16, -3, 3, -3,
- -17, 3, 18, 2, -1, -3, -1, -1, -6, 16, -8, 0, -9, 14, -7, 0,
- 3,-13, 14, -5, 3,-13, 14, -4, -7, 20, 14,-23, 8, -7, -8, 4,
- 8,-15,-19, 16,-10, 13, 11, -3, 9, -1, 1, 26, 5,-15,-27, 2,
- -20, 7, 16, -4,-40, 9, 31, 1, 26,-12,-30, -7, 40, -2,-19, 4,
- 6, 0, 0, 0, -6, -2, 1, 2, 0, -1, 0, -6, 9, 0, -2, -1,
- -7, 8, 2, -3, -1, 2, -3, 2, 7, -4, -2, 4, 2, 0, 0, -6,
- -3, -2, 9, 2, -2, -1, 0, -4, -3, -3, 0, -3, -6, 2, 10, 4,
- 3, 0,-10, 8, 0, 0, -4, 4, -1, 1, 4, 2, 3, -7, -9, 7,
- 2, 1, -9, -4, -1, 12, 0, 0, 3, -1, 7, -4, 3,-14, 4, 2,
- -12, -9, 1, 11, 2, 5, 1, 0, 3, 1, 0, 2, 0, 8, 6,-19,
- -6,-10, -7, -4, 9, 7, 5, 7, 6, 21, 3, -3,-11, -9, -5, -2,
- -4, -9,-16, -1, -2, -5, 1, 36, 8, 11, 19, 0, 2, 5, -4,-41,
- -1, -1, -2, -1, -2, -2, 1, 6, 0, 4, 1, -8, 1, 1, 1, 0,
- -2, -3, 4, 0, 2, -1, 3, -3, 1, 3, -4, 1, -1, 3, 0, -5,
- 3, 4, 2, 3, -2, -3, -6, -1, -2, -3, -2, 2, -4, 8, 1, 0,
- -7, 4, 2, 6, -7, -1, 1, 0, -2, 2, -4, 1, 8, -6, 2, -1,
- -6, 2, 0, 2, 5, 4, -8, -1, -1,-11, 0, 9, 0, -2, 2, 2,
- 17, -5, -4, -1, -1, -4, -2, -2, 0,-13, 9, -3, -1, 12, -7, 2,
- 0, -2, -5, 2, -7, -5, 20, -3, 7, 7, -1,-30, 3, 5, 8, 1,
- -6, 3, -1, -4, 2, -2,-11, 18, 0, -7, 3, 14, 20, -3,-18, -9,
- 7, -2, 0, -1, -2, 0, 0, -1, -4, -1, 1, 0, -2, 2, 0, 4,
- 1, -3, 2, 1, 3, 1, -5, 1, -3, 0, -1, -2, 7, 1, 0, -3,
- 2, 5, 0, -2, 2, -5, -1, 1, -1, -2, 4, -1, 0, -3, 5, 0,
- 0, 3, -1, -2, -4, 1, 5, -1, -1, 0, -1, 9, -1, -2, -1, -1,
- -2, 5, 5, -1, -2, 2, -3, -2, 1, 2,-11, 1, 2, 1, 3, 2,
- 2,-10, -1, -2, 4, 2, 4, 1, 4, 5, -5, 1, 0, 6,-11, 1,
- 1, 0, 6, 6, 0, 2, 1,-15, 7, 3, 5, 9,-30, 2, 2, 2,
- -34, 1, 9, 2, 5, 8, 8, 2, 7, 2, 6, 6, 2,-27, 1, 4
-};
-
-/* 6x16-entry codebook for inter-coded 4x4 vectors */
-static int8_t inter_codebook_4x4[1536] = {
- 4, 0, -6, -7, -4, -8,-13, -9, -8, -8, -1, 6, -2, 5, 22, 27,
- -16, -7, 11, 10,-18, -7, 13, 10,-15, -4, 12, 8, -9, -1, 9, 5,
- -2, 2, 15,-16, -3, 2, 19,-19, -3, 2, 19,-19, -2, 3, 15,-14,
- 17, 22, 22, 16, -6, -7, -5, -2,-12,-16,-16,-12, 1, 1, -1, -3,
- 11,-17, 0, 8, 14,-21, -1, 9, 14,-21, -2, 8, 11,-16, -2, 6,
- 7, -2,-16, 11, 9, -2,-21, 14, 10, -1,-22, 14, 8, -1,-18, 10,
- -10, 16, 3, -9,-13, 20, 4,-11,-14, 21, 4,-10,-11, 16, 3, -8,
- 11, 4, -9, -9, 15, 6,-12,-14, 17, 8,-12,-14, 16, 10, -7,-11,
- 4, 10, 14, 13, -1, 7, 15, 16,-12, -7, 3, 8,-20,-23,-18,-10,
- -10,-18,-26,-25, 4, 1, -6,-11, 13, 15, 11, 3, 12, 15, 13, 8,
- -16,-19,-16,-11, 7, 12, 15, 11, 11, 16, 16, 11, -6, -9,-11,-10,
- 18, 19, 12, 5, 18, 16, 5, -4, 6, 0,-10,-15, -9,-17,-23,-22,
- -10,-14, -1, 21,-11,-17, 0, 29,-11,-16, 1, 30,-10,-14, 0, 23,
- -16,-17,-12, -6,-19,-19,-14, -7, -3, -1, 1, 2, 27, 35, 29, 19,
- -37, -8, 23, 23,-42, -9, 28, 29,-43,-10, 26, 28,-38,-11, 19, 22,
- 32, 16,-16,-33, 39, 20,-18,-37, 38, 19,-19,-38, 32, 15,-17,-34,
- 24, 9, -6, -4, -1,-10, -6, 3, -8, -9, -1, 3, 3, 7, 2, -6,
- -1, -3, -1, 0, -1, 4, 2, -7, -3, 11, 3,-16, 1, 20, 9,-18,
- -3, -8, 6, 12, -5,-10, 7, 13, -6, -9, 5, 7, -5, -5, 2, -1,
- -8, 12, -3, -1,-10, 15, -3, 1,-11, 13, -4, 1,-11, 8, -3, 2,
- 9, 6, -5,-12, 3, 0, -8,-13, -4, -4, -1, -1, -4, 1, 15, 18,
- 9, 13, 14, 12, 4, 3, -1, -2, -2, -5, -8, -5, -7,-11, -9, -4,
- 7, -5, -7, -4, 14, -2, -7, -4, 17, 0, -8, -5, 15, 1, -7, -5,
- -10, -1, 6, 4,-15, -9, 2, 4, 2, -1, -3, 0, 25, 13, -8,-10,
- 7, 11, -3,-16, 7, 11, -3,-15, 6, 7, -2, -9, 4, 2, -3, -5,
- -7, -1, -1, 0, -9, -2, 2, 6,-12, -4, 6, 14,-13, -6, 8, 19,
- -18,-18,-11, -5, -3, 0, 3, 4, 6, 8, 6, 6, 6, 6, 6, 6,
- -5, 3, 13,-10, -6, 1, 15, -9, -6, -3, 15, -6, -6, -6, 10, -3,
- 9, 1, -9, -9, 11, 9, 6, 5, 0, 3, 8, 7,-15,-14, -6, -5,
- -11, -6, 11, 19, -2, -5, -9, -8, 6, 2, -9,-10, 6, 5, 4, 5,
- -7, -3, 8, 15, -1, 3, 10, 15, 5, 5, -1, -2, 4, -2,-21,-25,
- 6, -6, -6, 5, 8, -9, -7, 9, 8,-12, -7, 13, 4,-14, -7, 14,
- -4, -3, 1, 1, -3, -5, -2, -3, 7, 0, -2, -4, 20, 7, -4, -4,
- -3,-20, -6, 10, 6, 0, 0, 1, 5, 8, 5, -1, -3, 0, 0, -2,
- 13, 6, -1, 2, 5, 3, 2, 3, -3, 0, 3, 0,-16, -8, -2, -5,
- -2, -7, -6, 0, -3, -6, -3, 1, -5, -1, 2, -1, -1, 12, 16, 5,
- -7, 1, 9, 8,-10, -2, 5, 3, -6, 2, 7, 3, -4, 0, -1, -7,
- 3, 4, -9,-24, 0, 2, 6, 3, -1, -1, 4, 7, 5, 3, -1, -2,
- 3, 6, -9, 2, 1, 6,-13, 1, 1, 8,-10, 2, 1, 8, -7, 1,
- -3, -3, 2, 22, -2, -3, -5, 12, -2, -3,-10, 2, -3, -1, -4, 2,
- 11, 12, 8, 2, -5, -5, -5, -8, -6, -4, 0, -3, -2, -1, 3, 3,
- 12, -6, -2, -1, 12, -8, -2, -2, 9, -7, 0, -3, 4, -6, 2, -2,
- -19, 1, 12, -3, -4, 4, 5, -4, 6, 1, -2, -1, 4, -4, -2, 7,
- -3, -4, -7, -8, -4, -4, -2, 0, -1, 2, 14, 16, -4, -2, 4, 4,
- -1, 7, 2, -5, -2, 0, -1, 1, 4, -3, -1, 13, 6,-12,-14, 8,
- -1, 5, 4, -5, -2, 5, 3, -9, -2, 7, 4,-12, -1, 7, 4, -9,
- -6, -3, 1, 1, 11, 11, 0, -6, 6, 4, -2, -7,-12,-10, 3, 10,
- -2, -3, -3, -2, 6, 11, 14, 10, -9,-11,-10,-10, 2, 2, 3, 2,
- -7, -5, -7, -1, -1, 2, 0, 7, -1, 1, 0, 9, 3, 4, -5, -1,
- 10, -1,-15, -1, 4, 1, -5, 2, -3, 1, -1, 1, -3, 1, 4, 4,
- 2, -1, 4, 10, 6, 2, -1, 0, 2, 2, -7,-12, -4, 2, 0, -3,
- -1, -4, -1, -8, 3, -1, 2, -9, 4, 0, 5, -5, 2, 0, 8, 3,
- 3, 2, 1, 1, 4, -2, 0, 3, 2, -1, 4, 1, 0, 6, -1,-25,
- -1, -2, -2, -4, -3, 0, -1, -4, -1, -1, -4, 2, 0, -6, 2, 25,
- -11, -1, 5, 0, 7, 0, -2, 2, 10, -1, -3, 4, -5, -5, -2, -1,
- 0, 6, 3, -1, -2, -1, -1, 1, -1, -7,-12, -5, 8, 6, 2, 4,
- 2, 6, -1, -6, 9, 10, -1, -4, 1, 0, -4, 0, 3, -2, -9, -5,
- -4, 3, 4, 0, -4, 3, 3, 0,-11, 0, 3, 2,-11, 3, 7, 2,
- 2, -4, 7, 3, 1, -8, 7, 1, -1,-12, 4, 1, 3, -9, 2, 2,
- 2, -2, -2, 9,-17, -3, 3, 1, -4, 7, 1, -6, 5, 4, -1, 3,
- -1, 2, 0, -4, -7, 8, 12, -1, -2, 5, 4, -5, 3, -5, -8, -2,
- 0, 0, -5, -2, -2, -8, 3, 27, -1, -4, -3, 6, -3, 1, -2, -7,
- 4, 4, 1, -1, -7,-10, -7, -3, 10, 10, 5, 3, -2, -2, -4, -3,
- 0, 1, 5, 7, 4, -2,-16,-20, 0, 4, 7, 8, 2, 0, -2, -1,
- -2, 1, 3, 17, -3, 1, -2, -1, -1, -2, -1, -2, -1, -5, -1, 0,
- 5, -3, 1, 0, 6, -2, 0, 0, -1, -2, 0, -3,-11, 1, 8, -1,
- 3, 0, 0, 0, 0, 2, 4, 1, 2, 0, 6, 1, -2,-18, -3, 2,
- -14, 0, 6, 1, -5, -2, -1, 1, -1, 1, 0, 1, 1, 7, 4, 0,
- -1, 0, 1, -4, 1, 8, 3, -4, -3, 4, 1, 3, -6, 1, -4, 1,
- 1,-12, 3, 3, -1,-10, 0, -1, 2, 0, 2, 1, 3, 2, 2, 4,
- 3, 0, 0, 3, 2, 0, -2, 1, 5, 2, -5, 0, 6, -1,-14, -1,
- -2, -6, -3, -3, 2, -1, 4, 5, 6, -1, -2, 0, 4, 4, -1, -5,
- -4, 1,-11, 0, -1, 2, -4, 1, 2, -3, 3, -1, 1, -2, 15, 0,
- 1, -1, 0, -2, 1, -4, -7, 1, -2, -6, -1, 21, -2, 2, -1, 1,
- 21, -1, -2, 0, -1, -3, 1, -2, -9, -2, 2, -1, 2, 1, -4, -1,
- 1, 8, 2, -6,-10, -1, 4, 0, -4, -3, 3, 3, 5, 0, -1, -1,
- 3, 2, 1, -2, -2, -2, 4, 3, 5, 2, -4,-17, 0, -2, 4, 3,
- -7, -4, 0, 3, 9, 9, 2, -1,-11, -6, 0, -1, 5, 1, 0, 1,
- 0, 17, 5,-11, 3, -2, -6, 0, 2, -2, -4, 1, -4, 1, 2, -1,
- -5, -1, -5, -3, -3, 5, -3, -2, 4, 16, 2, -5, -2, 5, -1, -1,
- 0, 0, -4, 1, -1, 2, 5, 11, -1, -1, -2, 1, -4, -2, -3, -1,
- -5, -1, 10, 0, 6, 1, 0, -3, 0, -4, 1, 0, -2, -4, 3, -1,
- 6, 9, 3, 0, -2, 1, -2, 0, -2, -3, -2, -2, 1, 0, 1, -6,
- 1, 0, 2, 1, -1, 3, -2, 1, 0, -1,-15, 0, -1, 5, 2, 6,
- 2, 0, 2, 2, 0,-12, -4, 6, 0, 1, 4, -1, 1, 2, 1, -4,
- 1, -2, -7, 0, 0, 0, 0, -1, -5, 2, 11, 3, 1, 3, 0, -6,
- 0, -3, -9, -4, 1, 3, -1, 0, 4, 1, -2, 0, 7, -3, -1, 6,
- 1, -2, 6, 2, 0, -1, 3, -2, -2, 4, 0, 2, -1, 2,-14, 2,
- 2, 2, 0, -1, -2, 3, -3,-14, 0, 2, 3, -3, 5, 1, 3, 2,
- 1, -3, 4,-14, 1, -2, 11, -1, 0, -1, 3, 0, -1, 1, 0, 2,
- -2, 3, -3, 2, -4, -1, -4, 3, -1, 2, 1, 3, -6, -2, 2, 7,
- -2, 1, 2, 0, -2, 0, 0, -1, 12, 5, -1, 2, -8, -1, 1, -7,
- 2, -2, -4, 2, 11, 0,-11, -2, 3, 1, -3, -1, 0, 3, 1, -1,
- 0, 3, 0, -2, 0, -6, -1, -3, 12, -7, -2, 0, 7, -2, 1, 1,
- 1, 2, 2, 2, -1, 2, 0, 2,-23, 0, 4, 0, 3, 2, 1, 3,
- -4, -5, -1, 5, -3, 5, 10, -1, 0, 0, 3, -4, 1, -1, 2, -5
-};
-
-/* 6x16-entry codebook for inter-coded 8x4 vectors */
-static int8_t inter_codebook_8x4[3072] = {
- 9, 8, 4, 0, -3, -4, -4, -3, 9, 8, 4, -1, -4, -5, -5, -3,
- 8, 7, 3, -2, -5, -5, -5, -4, 6, 4, 1, -2, -4, -5, -4, -3,
- -12,-14,-11, -4, 1, 5, 6, 6, -8,-10, -7, -5, -2, 1, 1, 1,
- 5, 4, 3, 1, 0, 0, -1, -1, 13, 13, 9, 6, 3, 0, -1, -2,
- -4, -4, -3, -1, 1, 4, 8, 11, -5, -6, -4, -2, 0, 3, 8, 12,
- -7, -7, -6, -4, -2, 2, 7, 10, -7, -7, -5, -4, -2, 1, 5, 8,
- -3, -2, -1, 1, 3, 6, 7, 6, 2, 3, 5, 7, 8, 8, 6, 4,
- 4, 5, 4, 3, 1, -2, -6, -7, 1, 0, -2, -7,-10,-14,-17,-16,
- -5, -4, 1, 8, 9, 3, -3, -7, -7, -6, 1, 11, 12, 5, -3, -8,
- -8, -7, 0, 9, 11, 5, -3, -7, -8, -6, -1, 5, 8, 4, -2, -6,
- -4, -5, -7, -8, -9, -9, -8, -6, -4, -5, -6, -7, -7, -6, -4, -2,
- 0, 1, 2, 3, 5, 8, 10, 9, 1, 2, 3, 6, 9, 12, 14, 13,
- 5, 6, 6, 5, 4, 3, 2, 1, 5, 6, 7, 7, 6, 6, 6, 4,
- -1, 0, 1, 1, 3, 5, 5, 5,-13,-16,-17,-17,-14,-10, -6, -4,
- 9, 11, 13, 16, 15, 13, 12, 10, -4, -5, -6, -7, -7, -7, -6, -5,
- -6, -6, -7, -7, -7, -7, -6, -5, -2, -1, 0, 0, 0, 0, 0, -1,
- -11,-13,-15,-16,-16,-14,-12,-10, 2, 3, 4, 5, 4, 3, 3, 3,
- 6, 7, 8, 8, 8, 7, 6, 5, 3, 4, 3, 3, 3, 3, 3, 3,
- 3, 4, 4, 1, -2, -7,-13,-17, 5, 7, 7, 5, 1, -5,-13,-19,
- 6, 8, 9, 8, 5, -1, -9,-16, 6, 8, 10, 10, 7, 2, -4,-11,
- 18, 9, -1,-10,-13, -9, -4, 0, 22, 12, -1,-12,-15,-10, -4, 2,
- 23, 13, 0,-10,-13, -9, -3, 2, 20, 12, 2, -6, -9, -6, -2, 2,
- -6, -6, -6, -7, -7, -7, -7, -6, -6, -7, -8, -8, -9, -9, -9, -8,
- -3, -3, -3, -3, -3, -3, -3, -3, 12, 15, 18, 21, 21, 19, 17, 14,
- 14, 16, 18, 18, 18, 16, 15, 13, 5, 6, 6, 5, 5, 4, 4, 3,
- -6, -7, -9,-10,-10,-10, -9, -7,-10,-11,-13,-14,-14,-13,-12,-10,
- -27,-17, -4, 5, 9, 10, 10, 7,-32,-19, -3, 7, 11, 12, 11, 8,
- -30,-16, -2, 8, 12, 12, 10, 7,-23,-12, 0, 7, 10, 11, 9, 6,
- 16, 17, 16, 12, 6, -1, -8,-12, 17, 18, 15, 10, 1, -8,-15,-18,
- 15, 14, 10, 4, -5,-14,-20,-23, 10, 8, 4, -1, -9,-16,-21,-22,
- -10,-12,-12,-11, -5, 4, 14, 20,-11,-13,-15,-12, -4, 7, 19, 27,
- -11,-13,-14,-11, -3, 8, 21, 28,-10,-11,-12, -9, -2, 8, 18, 25,
- -1, -1, -1, 1, 4, 6, 6, 5, 0, 0, 0, 2, 4, 3, 1, -2,
- 0, 0, 2, 4, 4, -1, -7,-10, 0, 0, 3, 5, 3, -3,-11,-15,
- -14,-13, -8, -1, 3, 3, -1, -4, -5, -4, -1, 4, 8, 8, 3, 0,
- 3, 2, 2, 3, 4, 5, 3, 1, 5, 3, 0, -2, -2, -1, -1, -1,
- 9, 1, -6, -6, -5, -3, -2, -1, 12, 1, -6, -6, -4, -2, -1, 0,
- 14, 4, -4, -4, -2, -2, -1, -1, 14, 6, -1, -1, -1, -1, -1, -1,
- 4, 6, 8, 10, 11, 9, 7, 5, -1, -1, -1, 0, 0, -1, -1, -2,
- -2, -4, -4, -5, -5, -5, -5, -4, -2, -3, -3, -4, -4, -3, -2, -1,
- 2, 3, 4, 4, 3, 1, 0, 0, -1, 1, 4, 5, 6, 5, 4, 3,
- -8, -6, -2, 2, 3, 4, 4, 3,-14,-13, -9, -5, -2, -1, 0, 0,
- -3, -4, -5, -4, 0, 7, 12, 13, -3, -4, -5, -5, -2, 4, 9, 10,
- -2, -3, -4, -5, -4, -1, 3, 4, -1, -1, -2, -3, -3, -2, 0, 1,
- 9, 5, -2, -8,-11,-10, -7, -4, 12, 10, 6, 2, 0, -1, 0, 0,
- 2, 2, 3, 4, 3, 1, 1, 1, -9, -8, -4, 0, 1, 2, 1, 0,
- 6, 8, 8, 5, 1, -5,-11,-13, 0, 1, 2, 2, -1, -4, -8,-11,
- -3, -2, 1, 3, 3, 1, -1, -4, -2, -1, 2, 5, 6, 6, 4, 1,
- 3, 4, 5, 5, 4, 1, -3, -6, 5, 6, 4, 2, 2, 2, 0, -3,
- 6, 5, 0, -5, -5, -2, -1, -2, 7, 4, -3,-11,-12, -7, -3, -2,
- 1, 0, -1, -1, -1, 0, 0, 0, 2, 3, 4, 4, 5, 5, 4, 3,
- -7, -9, -9,-10,-10, -9, -7, -6, 3, 4, 5, 6, 5, 5, 5, 5,
- -7, -7, -7, -7, -6, -6, -5, -4, -5, -4, -3, -1, -1, -1, 0, 0,
- -3, -2, 1, 4, 5, 5, 5, 5, -2, -1, 3, 6, 9, 10, 10, 9,
- -14, 1, 10, 3, -2, 0, 1, 1,-16, 2, 13, 3, -3, -1, 1, 0,
- -15, 2, 12, 3, -4, -2, 1, 1,-10, 3, 10, 2, -3, -1, 1, 1,
- 0, 1, 4, 2, -5,-10, -3, 11, -1, 1, 4, 2, -6,-13, -2, 15,
- -1, 0, 3, 1, -6,-12, -1, 15, -1, 1, 2, 1, -4, -8, 0, 11,
- 10, 5, -2, -2, 2, 5, 1, -4, 7, 0, -8, -6, 1, 5, 2, -4,
- 2, -5,-12, -7, 2, 7, 4, -1, -1, -7,-10, -4, 4, 9, 7, 2,
- -5, -5, -4, -6, -6, -5, -5, -3, -1, -2, -2, -4, -5, -6, -5, -4,
- 6, 7, 7, 4, 0, -2, -3, -3, 13, 14, 13, 10, 5, 1, -1, -2,
- 1, 1, 2, 2, 2, 2, 2, 2, -5, -6, -8, -9, -9, -8, -7, -6,
- 7, 9, 10, 11, 11, 9, 7, 5, -1, -2, -3, -3, -4, -4, -4, -3,
- -1, -1, 0, 0, 0, 0, -1, -1, -3, -3, -4, -5, -4, -3, -3, -2,
- 2, 1, -1, -3, -3, -2, -1, 0, 12, 12, 8, 3, 1, 0, 0, 1,
- -6, -8, -8, -6, -2, 2, 6, 8, 1, 1, -1, -2, 0, 3, 5, 7,
- 3, 3, 1, -1, -1, 0, 0, 2, 0, 1, 0, -1, -1, -1, -2, -1,
- 1, 0, 0, 0, 0, 0, 2, 4, 2, 1, 3, 4, 3, 1, 0, 2,
- 2, 1, 0, 0, -1, -1, 0, 3, 5, 1, -6,-12,-13, -8, -1, 4,
- -2, 0, -1, -2, -1, 0, 2, 3, -6, -3, -2, 0, 1, 1, 1, 1,
- -9, -5, 0, 4, 5, 3, 1, 0, -8, -3, 3, 7, 8, 4, 1, 0,
- 1, 2, 2, 3, 3, 1, -1, -3, 4, 5, 5, 6, 6, 5, 2, 0,
- 0, 0, 0, 0, 1, 0, -2, -4, -3, -3, -4, -3, -3, -4, -7, -8,
- 14, 12, 6, -1, -3, -3, 0, 0, 7, 5, 1, -3, -5, -4, -2, -1,
- -2, -2, -2, -2, -2, -2, -1, -1, -6, -4, -1, 1, 1, 1, 0, -1,
- 2, 2, 1, -3, -6, -7, -6, -3, 1, 0, -1, -3, -2, 1, 4, 6,
- 0, 0, 1, 2, 4, 7, 8, 7, 0, 0, 0, 0, -1, -4, -7, -8,
- 0, 2, 1, -2, -3, -3, -2, -1, -1, 1, 0, -3, -5, -2, 0, 2,
- -2, -1, -2, -5, -4, 1, 6, 9, -3, -2, -3, -4, -2, 5, 11, 13,
- -4, -2, 2, 6, 4, -3,-10,-14, -2, -1, 1, 4, 4, 1, -1, -2,
- 0, 0, -1, -2, -2, 0, 4, 6, 2, 2, 0, -3, -3, 0, 5, 9,
- -4, -4, -2, 1, 6, 9, 3, -7, -2, -2, -2, -1, 4, 8, 0,-11,
- 1, 1, 0, 0, 2, 6, -1,-10, 2, 2, 1, 0, 2, 4, 0, -7,
- -1, -2, -3, -6, -7, -8, -8, -8, 2, 3, 3, 1, -1, -2, -3, -4,
- 5, 5, 5, 4, 3, 2, 0, -1, 3, 3, 3, 3, 2, 2, 1, 1,
- 3, 3, 2, -2, -3, 0, 7, 10, 1, 2, 2, -2, -5, -4, 0, 3,
- 0, 3, 4, 2, -3, -5, -6, -4, 0, 2, 4, 4, 1, -4, -7, -7,
- 2, 4, 5, 5, 5, 5, 6, 6, -4, -4, -3, -5, -5, -3, -3, -2,
- -3, -4, -4, -5, -4, -2, -2, -2, 1, 1, 0, 0, 2, 4, 5, 4,
- -2, 0, 3, 4, 4, 3, 2, 2, -9, -7, -4, 0, 3, 6, 6, 6,
- -5, -5, -3, -2, 0, 1, 3, 4, 5, 5, 2, -2, -4, -6, -5, -3,
- 1, -6, -4, 7, 5, -2, -2, 1, 5, -5, -4, 6, 4, -5, -4, 1,
- 5, -5, -4, 6, 4, -5, -3, 1, 1, -7, -3, 8, 7, -1, -3, 1,
- -8, -7, -4, 0, 2, 4, 5, 5, 5, 6, 5, 2, -1, -5, -7, -7,
- 5, 6, 4, 1, -3, -5, -6, -5, -7, -7, -5, -2, 1, 6, 9, 10,
- 6, 3, 0, 1, 3, 0, -8,-14, 3, 0, -1, 1, 4, 3, 0, -4,
- 1, 0, 0, 1, 2, 1, 1, 1, -1, -1, 1, 2, 1, -1, -1, 0,
- 1, 1, 1, 1, 0, -2, -3, 0, 1, 2, 1, 0, -2, -8, -9, -4,
- 1, 3, 3, 2, 1, -3, -3, 1, 0, 1, 1, 1, 1, 1, 4, 8,
- 2, 5, 9, 7, 2, -1, -1, 1, -4, -1, 1, 0, -3, -4, -1, 2,
- -3, 0, 3, 3, 0, -1, 0, 2, -4, -1, 1, 1, -2, -4, -5, -4,
- 1, -1, -2, -2, -1, 2, 4, 5, 2, 1, 1, 0, -1, -1, 0, 0,
- 2, 3, 4, 5, 4, 2, 1, 0, -9, -9, -6, -3, -1, -1, -1, -1,
- -6, -6, 4, 7, 0, -2, -1, -2, -1, -2, 5, 6, -1, -2, 0, -1,
- 4, -1, 1, 0, -4, -2, 0, -2, 7, 1, -1, -2, -3, 1, 3, 1,
- 4, 2, 1, 3, 3, 1, 1, 2, 2, -2, -4, 0, 3, 1, 0, 0,
- 1, -4, -8, -4, 1, 2, 1, 0, 2, -3, -9, -6, 0, 3, 3, 2,
- -1, -1, 0, -1, -1, 0, 1, 2, 3, 1, -4, -8, -7, -3, 1, 2,
- 2, -1, -3, -2, -1, 0, 1, 0, -1, 0, 5, 11, 9, 3, -1, -3,
- -1, -2, -2, -1, 1, 1, 1, 1, 0, -1, 0, 3, 6, 6, 5, 5,
- 2, 1, -1, -1, -2, -5, -6, -4, 2, 2, 2, 1, -1, -4, -5, -5,
- -1, -3, -6, -7, -6, -4, -1, 1, 5, 5, 3, 4, 4, 3, 4, 5,
- -1, -2, -3, -2, -2, -2, 0, 1, 0, 0, 0, 0, 0, 1, 2, 3,
- -6, -6, -4, -1, 2, 2, 2, 2, -6, -7, -5, -2, 0, -1, -1, 0,
- 2, 2, 2, 4, 4, 3, 3, 4, 2, 1, 0, -1, 0, 0, 2, 4,
- 12, 5, -5, -8, -5, 0, 2, 2, 2, -3, -6, -3, 0, 0, -1, -2,
- -2, -3, -1, 3, 4, 1, -2, -3, 2, 2, 3, 4, 3, 1, -1, -1,
- 3, 2, 1, 0, 1, 4, 3, 0, 4, 3, 0, -5, -6, 0, 3, 3,
- 2, 3, 1, -7,-12, -6, 1, 3, 1, 3, 4, -1, -6, -4, 0, 1,
- -9, -4, 2, 6, 7, 4, 1, 0, -7, -1, 4, 6, 4, 0, -3, -3,
- -6, 0, 4, 4, 1, -2, -3, -2, -4, 1, 3, 2, 0, -2, -1, 0,
- 0, 5, 2, -5, -3, 3, 1, -4, -2, 4, 2, -6, -3, 6, 4, -3,
- -1, 5, 3, -5, -1, 7, 3, -4, -1, 2, 0, -6, -3, 5, 3, -3,
- -8, -3, 3, 5, 3, 1, -2, -2, 2, 4, 4, -2, -4, -3, 1, 3,
- 2, 1, -3, -5, -3, 3, 4, 3, -5, -6, -5, 3, 10, 8, -1, -5,
- 0, 3, 2, -4, -9, -7, 0, 6, -5, -1, 5, 7, 4, -1, -3, -3,
- -5, -5, -2, 3, 6, 5, -1, -4, 9, 6, 0, -4, -2, 1, 1, -1,
- -1, -1, -1, 1, 1, 0, -1, 0, -1, 0, 0, 0, 0, -1, -1, 0,
- 2, 1, -2, -1, 1, 1, 0, 0, 12, 8, 2, -1, -1, -4, -7, -7,
- 2, 1, 3, 6, 7, 4, 2, 0, 1, 0, -1, 0, -1, -4, -7, -8,
- 0, 0, -1, 0, 0, 0, -1, -3, 0, 0, 0, 0, 1, 1, 0, -2,
- -1, 0, 1, 1, 0, 0, -1, -2, 0, 0, -1, -3, -4, -3, -1, 1,
- -1, 0, 0, 0, 1, 4, 10, 12, -1, 0, -2, -2, -3, -3, -1, 1,
- -3, -1, -2, -4, 2, 9, 9, 7, -3, 0, -1, -3, 0, 2, -1, 1,
- -1, 1, -2, -3, 0, -1, -3, 0, 0, 0, -3, -2, 0, -1, -1, 1,
- -1, -2, -1, -1, -2, -1, -1, -2, 2, -1, -2, -1, 0, 1, 0, -2,
- 3, -1, -2, 2, 5, 3, -1, -3, 1, -5, -5, 1, 6, 6, 2, 0,
- 1, 2, 0, -1, 0, 1, 0, -2, -5, -3, -1, 0, 1, 2, 1, -2,
- -7, -5, -2, -2, -2, -2, 0, 1, -1, 0, 1, 1, 0, 3, 9, 12,
- 0, 6, 5, 1, -2, -3, 0, 3, 0, 6, 5, 1, 1, 1, 2, 3,
- -5, -2, -2, -3, 0, 0, 0, 0, -6, -3, -3, -2, 0, 0, -1, -2,
- 4, 4, 2, 1, 0, -1, -1, 0, -2, -2, 0, 1, 2, 1, 1, 0,
- 2, 2, 1, -1, -3, -5, -9,-10, 2, 1, -1, -1, 1, 4, 4, 1,
- 4, 0, -2, -2, -2, -2, -1, 0, 7, 1, -4, -3, -2, 0, 1, 1,
- 10, 5, -1, -2, 0, 1, 1, 0, 5, 1, -3, -4, -3, -1, -1, -2,
- 2, 1, -1, -3, -3, 1, 1, -1, -2, -1, 3, 0, -1, 1, 1, 0,
- -3, 1, 7, 2, -3, -2, -1, 0, -2, 4, 8, -1, -8, -5, 0, 2,
- -4, -1, 1, 2, 1, -3, -4, -2, -5, -3, -2, 1, 4, 4, 4, 6,
- -3, -2, -4, -3, 0, 1, 1, 2, 2, 2, 2, 1, 2, 1, -1, -1,
- -4, -1, 0, -1, -3, -3, -1, -1, 1, 4, 4, 2, 0, -1, -2, -3,
- 4, 6, 5, 3, 2, 1, -2, -4, 0, 1, 1, 1, 1, -1, -4, -6,
- 1, 2, 2, -1, -6, -5, -1, 2, -3, -2, 1, 1, -4, -3, 2, 5,
- -2, -1, 2, 2, -3, -4, 0, 3, -2, -2, 2, 6, 5, 2, 1, 2,
- 2, -3, -3, 0, 0, 2, 3, 1, 3, -1, 1, 3, 1, 2, -1, -5,
- -5, -7, -4, -2, 1, 8, 8, 1, -1, 0, 2, 0, -3, 0, 1, -3,
- -2, -5, -5, -2, -3, -1, 0, -2, -1, -4, 0, 4, 0, 2, 4, 0,
- 0, 0, 8, 10, 2, 1, 3, -1, -4, -3, 2, 3, -3, -3, 1, -1,
- 1, -2, -4, 2, 7, 3, -2, -1, 6, 4, -2, -1, 2, 0, -1, 3,
- 1, 1, -2, -2, -2, -5, -3, 4, -6, -2, 1, 1, -1, -4, -2, 4,
- -2, -1, -2, -2, 0, 1, 0, -2, -1, 1, 0, -1, 0, 0, -1, -3,
- 0, 1, -2, -4, -3, -1, 0, 0, 6, 8, 5, 0, 0, 1, 2, 3,
- -2, -2, 2, 5, 2, 0, 0, 1, 2, -2, -2, -1, -1, 1, 2, 4,
- 2, -1, 0, 1, 0, 0, 0, 1, -8, -7, -1, 1, -1, -1, 1, 3,
- 0, 3, 6, 2, -2, 1, 2, 0,-10, -7, -1, 0, -3, -1, 2, 1,
- 0, 0, 2, 2, 1, 1, 1, -1, 3, 0, -2, -2, 0, 2, 1, 0,
- 8, 1, 0, 0, -2, -3, -1, 0, 2, -2, 2, 5, 1, -2, -1, 1,
- -3, -6, -3, -1, -3, -3, -1, 2, 2, 0, 1, 2, 2, 1, 0, 0,
- 1, -1, -1, -2, -1, 0, 1, 0, 15, 9, 2, -1, -2, -3, -3, -3,
- 0, -3, -2, 0, 0, -1, -1, -1, 1, 0, 1, 0, 0, -1, -1, -1,
- 0, 2, 2, -2, -3, -3, -7, -8, 0, 2, 2, 0, 1, 2, 1, 1,
- 1, 2, 2, 2, 3, 1, 0, 3, 1, 0, -1, -2, -1, -2, 0, 5,
- -11, -6, -1, 1, 2, 3, 1, -3, 1, 4, 3, -1, -2, 1, 2, -1,
- 2, 2, 1, -1, -2, 0, 1, -1, 0, 0, -1, -1, 0, 2, 3, 2,
- 1, 1, 2, 1, -1, 1, 0, -4, 0, 0, 0, -2, -2, 2, 4, -2,
- -2, -3, 0, 0, -1, 2, 1, -6, 0, 2, 5, 5, 3, 2, -1, -7,
- 4, 2, 0, 0, 3, 3, 1, -1, 0, -1, -1, 3, 6, 4, 1, -1,
- -2, -2, 0, 2, 2, 0, -2, -2, -1, 0, -1, -5, -7, -5, -1, 1,
- 5, -1, -2, 0, 2, 4, 2, -5, 0, -5, -2, 2, 1, 2, 0, -6,
- 6, 1, 0, 1, -2, -1, 4, 2, 2, -3, -3, 0, -1, -2, 0, 0,
- 1, -1, 0, 2, 0, 0, 6, 11, 2, -1, -1, 0, -3, -2, 3, 5,
- 0, -2, -1, 0, -1, 0, 0, -3, 1, -1, -1, -1, -2, -1, -3, -7,
- 1, 1, -2, -2, 1, 3, 1, -2, -1, 2, 0, -1, -1, 1, 0, 0,
- -4, 2, 3, -1, -2, -2, 0, 1,-11, -2, 4, 5, 6, 2, -1, -2,
- -6, -2, 1, -1, -3, -4, 1, 9, -3, 0, 3, 3, 2, -3, -3, 3,
- 1, 1, 0, 0, 1, -1, -2, 3, 2, 0, -3, -3, 0, -1, -1, 3,
- 1, -1, -3, 1, 2, -6, -4, 6, 0, -2, -5, -2, 0, -3, -2, 3,
- 2, 2, 1, -2, -2, 1, 2, -1, -1, 1, 1, -2, -1, 6, 7, -1,
- 1, 0, -4, -2, 1, -2, -3, 1, -4, 0, -3, -2, 2, 0, -3, 0,
- -3, 4, 3, 1, 8, 7, 0, -1, -3, 4, 1, -4, 2, 3, -2, -3,
- -3, 6, 1, -4, 1, 1, -1, -1, -2, 4, -3, -3, 3, 0, -1, -1,
- 1, 2, -4, 2, 4, -3, -1, 2, 3, -1, -4, 5, 4, -6, -3, 2
-};
-
-/* 6x16-entry codebook for inter-coded 8x8 vectors */
-static int8_t inter_codebook_8x8[6144] = {
- -4, -3, 4, 5, 2, 1, 1, 0, -5, -3, 5, 5, 2, 1, 0, 0,
- -6, -4, 5, 5, 2, 1, 0, 0, -7, -4, 4, 5, 2, 1, 0, 0,
- -8, -5, 3, 4, 2, 1, 0, 0, -8, -6, 3, 4, 1, 1, 1, 0,
- -8, -6, 2, 4, 2, 1, 1, 0, -8, -6, 2, 4, 1, 1, 1, 1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2, -2, -2, -2, -2, -2,
- -2, -3, -3, -3, -3, -3, -3, -3, -2, -3, -3, -3, -3, -3, -4, -3,
- -2, -2, -2, -2, -2, -3, -3, -2, 1, 1, 1, 1, 1, 0, -1, -1,
- 4, 5, 5, 5, 4, 3, 3, 2, 7, 7, 8, 8, 8, 7, 6, 5,
- 2, 1, 2, 4, 4, 0, -4, -6, 1, 1, 2, 5, 5, 1, -5, -7,
- 1, 2, 1, 4, 5, 1, -5, -8, 1, 1, 1, 5, 5, 0, -6, -8,
- 0, 1, 1, 5, 6, 1, -6, -9, 0, 0, 1, 4, 5, 0, -5, -8,
- 0, 0, 1, 4, 5, 0, -5, -7, 0, 0, 1, 4, 4, 1, -4, -7,
- 1, 2, 3, 0, -3, -4, -3, -1, 1, 3, 4, 0, -3, -4, -3, -1,
- 2, 4, 5, 1, -3, -4, -3, -2, 2, 5, 6, 1, -3, -5, -4, -2,
- 3, 6, 6, 1, -3, -5, -4, -2, 3, 6, 6, 1, -3, -5, -4, -2,
- 3, 6, 6, 1, -3, -5, -4, -2, 3, 5, 5, 1, -3, -4, -4, -2,
- 2, 2, 2, 2, 1, 0, 0, -1, 4, 4, 4, 3, 2, 1, 1, 0,
- 4, 5, 4, 4, 3, 3, 2, 1, 4, 4, 4, 4, 4, 3, 2, 2,
- 2, 3, 3, 3, 3, 3, 2, 1, -1, -1, -1, -1, 0, 0, 0, 0,
- -5, -6, -6, -5, -5, -4, -3, -3, -7, -9, -9, -8, -7, -6, -6, -5,
- 6, 6, 6, 6, 6, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 2,
- 0, -1, -1, -1, -2, -2, -1, -1, -3, -5, -6, -6, -6, -6, -5, -4,
- -3, -5, -6, -7, -6, -6, -5, -4, -1, -2, -2, -2, -2, -2, -1, -1,
- 0, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3,
- 2, 1, -2, -5, -4, 0, 2, 5, 2, 1, -2, -6, -5, 0, 3, 5,
- 2, 1, -2, -6, -6, -1, 3, 6, 3, 2, -2, -7, -6, 0, 4, 7,
- 2, 1, -2, -7, -5, 0, 5, 7, 2, 1, -2, -6, -5, 0, 4, 7,
- 2, 1, -2, -6, -4, 0, 4, 6, 1, 1, -2, -5, -4, 0, 3, 6,
- -10, -9, -6, -4, -1, 2, 3, 2,-10, -9, -5, -3, 0, 4, 4, 3,
- -9, -7, -3, -1, 2, 5, 5, 3, -7, -5, -2, 0, 3, 5, 5, 3,
- -6, -3, 0, 1, 4, 6, 5, 3, -4, -2, 1, 2, 3, 5, 4, 2,
- -2, 0, 1, 2, 2, 4, 3, 1, -1, 1, 2, 2, 2, 3, 3, 1,
- -4, -5, -5, -6, -6, -6, -6, -5, -3, -3, -4, -4, -4, -4, -4, -4,
- 0, 0, 0, 0, -1, -1, -1, -1, 5, 5, 6, 5, 5, 4, 3, 2,
- 5, 6, 7, 7, 7, 6, 5, 4, 3, 3, 4, 4, 4, 4, 3, 2,
- 0, -1, 0, 0, -1, -1, 0, -1, -3, -3, -4, -4, -4, -4, -3, -3,
- 1, -2, -5, 1, 5, 4, 2, 0, 1, -3, -6, 1, 6, 5, 2, 0,
- 0, -4, -7, 0, 6, 6, 2, 1, -1, -5, -9, -1, 6, 6, 3, 1,
- -1, -6,-10, -2, 6, 6, 3, 1, -1, -6, -9, -2, 5, 6, 3, 1,
- -2, -6, -9, -2, 5, 5, 3, 1, -2, -6, -7, -2, 4, 4, 2, 1,
- -5, -7, -8, -9, -9, -8, -7, -6, -5, -6, -6, -7, -7, -6, -6, -5,
- -3, -3, -3, -4, -5, -5, -4, -4, -1, 0, 0, -1, -1, -1, -1, -1,
- 0, 1, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 5, 5, 5, 4,
- 3, 4, 5, 6, 8, 8, 8, 7, 3, 4, 5, 6, 7, 7, 7, 6,
- 5, 6, 7, 8, 9, 10, 10, 9, 3, 4, 6, 7, 8, 9, 9, 8,
- 0, 1, 2, 3, 4, 5, 5, 5, -1, -2, -1, -1, 0, 1, 2, 2,
- -2, -3, -3, -3, -3, -2, -1, 0, -3, -4, -5, -5, -5, -5, -5, -4,
- -4, -5, -5, -6, -7, -7, -6, -5, -3, -4, -5, -6, -7, -7, -6, -6,
- 13, 7, 0, -3, -3, -4, -4, -5, 14, 7, 0, -3, -3, -4, -4, -4,
- 15, 8, -1, -4, -4, -4, -5, -4, 15, 8, -1, -4, -4, -5, -4, -3,
- 15, 7, -1, -4, -5, -5, -5, -4, 14, 7, -1, -4, -4, -4, -4, -3,
- 12, 6, -1, -4, -4, -4, -4, -3, 11, 5, -1, -4, -4, -4, -4, -3,
- -17, -4, 5, 4, 4, 4, 3, 3,-18, -5, 5, 4, 4, 4, 3, 3,
- -19, -5, 6, 4, 4, 4, 3, 2,-20, -5, 6, 4, 4, 4, 3, 3,
- -20, -4, 6, 4, 4, 5, 3, 3,-19, -5, 6, 4, 4, 5, 3, 3,
- -18, -4, 5, 4, 4, 4, 3, 2,-17, -5, 4, 3, 4, 4, 3, 3,
- -6, -6, -6, -4, -2, 1, 6, 11, -6, -7, -7, -4, -2, 2, 8, 13,
- -8, -8, -7, -4, -2, 3, 9, 14, -8, -8, -7, -5, -1, 4, 10, 16,
- -8, -8, -7, -5, -1, 4, 10, 17, -8, -8, -7, -4, 0, 5, 10, 16,
- -8, -8, -6, -3, 0, 4, 9, 15, -7, -7, -5, -3, 0, 4, 8, 12,
- 8, 7, 7, 5, 2, -2, -8,-14, 8, 8, 7, 5, 2, -2, -8,-15,
- 8, 8, 7, 5, 1, -3, -9,-16, 8, 8, 7, 5, 1, -3,-10,-17,
- 8, 9, 8, 5, 1, -3,-10,-17, 8, 8, 7, 4, 1, -4,-10,-16,
- 7, 7, 7, 4, 1, -3, -9,-14, 6, 7, 6, 3, 0, -3, -9,-13,
- 5, 1, -4, -4, -3, -1, 0, 0, 7, 2, -3, -3, -2, -1, 1, 0,
- 7, 1, -3, -3, -1, 0, 1, 1, 6, 1, -3, -2, -1, 1, 1, 0,
- 6, 0, -4, -2, -1, 0, 1, 0, 5, 0, -4, -3, -1, 0, 0, -1,
- 5, 0, -3, -1, 0, 0, 0, -2, 4, 1, -2, -1, 0, 1, 0, -1,
- 2, 2, 1, 1, -2, -6, -8, -8, 1, 1, 1, 1, -2, -5, -8, -8,
- 1, 1, 1, 0, -1, -3, -5, -5, 0, 0, 0, 0, -1, -1, -1, -2,
- 0, -1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 2, 3, 2,
- 2, 1, 1, 1, 2, 3, 4, 3, 3, 3, 3, 3, 4, 4, 5, 4,
- -4, -4, -3, -2, 0, 0, 1, 1, -4, -4, -3, -2, -1, 0, 0, 1,
- -2, -2, -2, -1, -1, -1, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1,
- 2, 2, 2, 2, 2, 2, 1, 1, 3, 4, 4, 4, 4, 4, 4, 3,
- 1, 1, 1, 3, 3, 4, 3, 3, -5, -6, -5, -4, -3, -3, -2, -2,
- -4, -2, -1, -1, -1, -1, 0, 1, -4, -2, -1, -1, -1, -1, 0, 1,
- -3, -2, -1, -1, -1, 0, 1, 2, -4, -3, -2, -1, -1, 1, 3, 3,
- -4, -3, -3, -1, -1, 1, 4, 5, -4, -3, -2, -2, -1, 1, 4, 7,
- -2, -2, -1, -1, 0, 2, 6, 8, -1, 0, 0, 1, 1, 4, 7, 8,
- -3, -3, -3, -2, -2, -1, -1, 0, -1, -1, 0, 1, 2, 2, 3, 3,
- 0, 1, 2, 4, 5, 6, 6, 5, -1, 0, 2, 3, 5, 6, 5, 3,
- -1, -1, 0, 2, 3, 3, 2, 1, -2, -2, -1, 0, -1, -3, -4, -4,
- 0, 0, -1, -1, -2, -4, -8, -7, 1, 2, 1, 0, -1, -4, -6, -7,
- -2, 4, 1, -6, 0, 3, 0, 0, -2, 5, 1, -7, 0, 3, 0, 0,
- -3, 5, 1, -8, 0, 3, -1, -1, -2, 6, 1, -9, 0, 3, 0, -1,
- -2, 6, 2, -8, 0, 4, 0, -1, -3, 5, 1, -7, 1, 4, 0, 0,
- -2, 4, 1, -7, 0, 4, 1, 0, -1, 4, 1, -6, 0, 3, 1, 0,
- 0, 0, 0, 3, 4, 5, 4, 1, 1, 1, 1, 2, 3, 3, 2, 0,
- 2, 2, 1, 2, 2, 1, -1, -2, 4, 3, 1, 1, 0, -1, -3, -5,
- 5, 3, 1, -1, -2, -3, -4, -6, 5, 3, 0, -2, -3, -5, -6, -7,
- 4, 3, 0, -2, -3, -4, -5, -5, 4, 3, 0, -1, -2, -2, -3, -3,
- 0, 0, 0, 0, -1, -5, -2, 6, 0, 0, 0, 1, -1, -6, -2, 8,
- 0, 0, 0, 2, 0, -6, -3, 9, 0, -1, 0, 2, 0, -7, -2, 10,
- 0, -1, 0, 2, -1, -8, -3, 10, 0, -1, -1, 2, -1, -7, -3, 9,
- 0, -1, 0, 1, -1, -6, -3, 8, 0, 0, 0, 1, 0, -5, -2, 7,
- 2, 3, 3, 2, 1, 0, -1, -1, 3, 4, 3, 2, 1, 0, -1, -2,
- 3, 4, 4, 2, 1, -1, -2, -3, 2, 3, 3, 2, 0, -1, -2, -3,
- -1, 0, 1, 1, 0, -1, -2, -2, -5, -4, -3, -1, 0, 1, 1, 1,
- -8, -8, -5, -1, 1, 3, 4, 3,-10, -9, -5, 0, 3, 5, 6, 5,
- -5, -1, 4, 5, 3, 1, 0, 0, -6, -1, 4, 5, 2, 0, -1, -2,
- -6, -1, 5, 4, 2, -1, -2, -2, -7, -1, 4, 4, 1, -2, -3, -3,
- -6, -1, 5, 4, 1, -2, -3, -3, -5, 0, 4, 4, 1, -1, -2, -2,
- -4, 0, 5, 4, 1, -1, -1, -2, -3, 1, 4, 3, 1, -1, -1, -2,
- -2, -3, -2, 1, 4, 6, 5, 3, -3, -4, -4, 0, 3, 5, 4, 2,
- -3, -5, -5, -1, 2, 4, 3, 1, -4, -6, -4, -1, 2, 4, 2, -1,
- -2, -4, -3, 1, 2, 4, 2, -1, -2, -4, -2, 1, 3, 3, 1, -2,
- -2, -3, -2, 1, 3, 3, 1, -2, -2, -2, -1, 1, 3, 3, 0, -2,
- -4, -4, -3, -2, -1, 2, 5, 7, -4, -4, -3, -3, -2, 1, 5, 7,
- -2, -3, -2, -3, -3, -1, 3, 5, -1, -1, 0, -2, -3, -2, 2, 4,
- 1, 1, 1, -1, -4, -3, 1, 3, 4, 3, 2, -1, -4, -3, -1, 1,
- 6, 4, 3, 0, -3, -3, -2, 0, 6, 5, 3, 1, -2, -3, -2, -1,
- 12, 11, 8, 4, 0, -2, -2, -1, 10, 9, 6, 2, -1, -2, -1, 0,
- 4, 3, 2, 0, -1, -1, 0, 1, -1, -1, -1, -1, -2, 0, 1, 2,
- -3, -5, -4, -2, -2, 0, 2, 3, -5, -5, -4, -2, -1, 0, 1, 2,
- -5, -5, -4, -2, -1, 0, 1, 1, -4, -4, -3, -2, -2, -1, 0, 0,
- 3, 3, 2, -1, -3, -4, -3, -2, 3, 2, 0, -2, -4, -4, -3, -2,
- 2, 2, 1, -1, -3, -5, -4, -3, 3, 3, 3, 1, -2, -3, -3, -3,
- 4, 4, 4, 3, 0, -2, -2, -2, 5, 5, 5, 3, 0, -1, -2, -2,
- 5, 5, 4, 2, -1, -2, -3, -2, 3, 3, 3, 0, -2, -4, -4, -4,
- -1, -1, 4, -2, -2, 6, 2, -5, -1, 0, 4, -2, -3, 6, 2, -6,
- -1, 0, 4, -2, -3, 7, 3, -7, -1, -1, 4, -3, -4, 8, 3, -7,
- 0, -1, 4, -3, -4, 7, 3, -6, -1, -1, 4, -3, -4, 7, 3, -6,
- -1, -1, 3, -3, -4, 6, 3, -6, -1, 0, 3, -2, -3, 6, 3, -5,
- 1, -2, -7, 2, 5, -2, -1, 1, 1, -2, -8, 3, 6, -3, -1, 2,
- 2, -2, -9, 4, 7, -4, -2, 2, 3, -1, -9, 5, 7, -4, -1, 3,
- 3, -1, -9, 4, 7, -4, -2, 2, 3, -1, -7, 4, 6, -4, -2, 1,
- 2, 0, -6, 4, 6, -4, -1, 1, 2, 0, -5, 3, 4, -3, -1, 1,
- -2, 2, 2, 0, 0, -1, -3, -4, -2, 2, 2, 1, 1, 0, -2, -4,
- -2, 2, 2, 2, 2, 1, -1, -2, -3, 2, 3, 3, 4, 2, 0, -2,
- -3, 2, 3, 2, 4, 2, 0, -3, -4, 1, 2, 1, 2, 1, -1, -3,
- -5, 0, 1, 0, 1, 1, -2, -3, -4, 0, 0, 0, 1, 0, -2, -3,
- 0, 0, -1, -2, -2, 2, 7, 8, 0, 0, -1, -3, -2, 1, 6, 7,
- 0, 1, -1, -3, -3, 0, 4, 5, 0, 1, 0, -1, -1, 0, 1, 3,
- 0, 2, 1, 1, 0, -1, 0, 1, -2, 0, 1, 2, 1, 0, -1, -1,
- -5, -2, 0, 1, 1, 0, -3, -3, -6, -4, -1, 1, 1, -1, -3, -4,
- -4, -2, 2, 5, 6, 4, 3, 2, -5, -3, 1, 4, 4, 2, 0, 0,
- -4, -2, 0, 2, 1, -1, -2, -2, -2, -1, 0, 1, 0, -2, -3, -2,
- -2, 0, 0, 0, -1, -1, -2, -1, -2, -1, -1, 0, 0, 0, 1, 2,
- -2, -2, -1, -1, 0, 1, 3, 4, -2, -3, -2, -1, 0, 2, 4, 5,
- 2, 1, -2, -2, -1, 0, 1, 0, 1, 0, -3, -3, -1, 0, 1, 0,
- 0, -1, -3, -3, -1, 1, 1, 1, 0, 0, -3, -1, 1, 2, 3, 3,
- 0, -1, -3, -1, 1, 3, 3, 3, -2, -2, -4, -2, 1, 3, 4, 4,
- -3, -3, -4, -2, 1, 3, 3, 4, -2, -3, -5, -2, 1, 2, 3, 3,
- 4, 5, 3, 4, 4, 4, 4, 5, 3, 3, 1, 0, 0, 0, 0, 1,
- 1, 1, -1, -2, -3, -4, -3, -2, 2, 2, 0, -2, -2, -4, -3, -2,
- 2, 3, 1, -1, -1, -3, -3, -2, 1, 2, 0, 0, -1, -2, -2, -1,
- 0, 1, 0, -1, -1, -3, -2, -1, 1, 1, 0, -1, -1, -2, -2, -2,
- -2, -1, -1, 0, 1, 2, 1, 0, 1, 2, 3, 5, 6, 5, 5, 3,
- 1, 2, 3, 4, 5, 5, 4, 3, -2, -2, -3, -3, -2, -1, 0, 0,
- -3, -3, -4, -5, -4, -3, -2, -1, -1, -1, -2, -2, -2, -1, 0, 0,
- 0, 1, 0, -1, -1, 0, 0, 1, -1, 0, -1, -2, -3, -2, -2, -1,
- 7, 7, 6, 5, 4, 2, -1, -2, 3, 3, 2, 2, 1, 0, -2, -3,
- 0, -1, -1, -1, 0, -1, -2, -2, -1, -3, -2, -1, 0, 0, 0, 1,
- 0, -2, -2, -1, -1, 1, 2, 2, 3, 1, -1, -1, -1, 1, 2, 2,
- 3, 1, -2, -3, -2, -1, 1, 2, 1, -2, -5, -6, -5, -3, -2, 0,
- 0, -1, -2, -3, -1, 0, -2, -2, 0, 0, -1, -1, 0, 1, -1, -2,
- 0, 0, -2, -1, 0, 0, 0, -2, -1, -2, -3, -3, -2, -1, -3, -3,
- -1, -2, -3, -3, -2, -2, -3, -4, 2, 2, 0, 0, 0, 0, -1, -2,
- 5, 5, 3, 2, 2, 2, 0, -1, 8, 8, 6, 5, 4, 4, 2, 1,
- -7, -8, -6, -3, -1, -1, -2, -1, -5, -5, -3, 0, 2, 1, 0, 0,
- -1, -1, 0, 3, 4, 3, 1, 1, 2, 1, 1, 3, 4, 3, 2, 2,
- 3, 2, 0, 2, 3, 2, 1, 2, 4, 2, -1, -1, 0, 1, 1, 1,
- 3, 2, -2, -3, -2, -1, 0, 1, 3, 1, -3, -4, -3, -2, 0, 1,
- -4, -2, -1, 2, 3, 3, 1, 0, -7, -5, -4, -2, 0, 0, -1, -2,
- -6, -5, -5, -4, -2, -2, -2, -3, -1, 0, -1, -1, 0, 0, 0, -1,
- 2, 3, 2, 2, 2, 2, 1, 0, 3, 5, 4, 3, 1, 0, 1, 0,
- 3, 4, 3, 2, 0, -1, -1, -1, 5, 5, 3, 1, 0, -1, -1, -1,
- 1, 1, 0, -1, -3, -5, -6, -4, 1, 1, 0, 0, 0, -3, -3, -1,
- 0, -1, -1, 0, 1, 0, 1, 3, -2, -2, -3, -1, 2, 2, 4, 7,
- -2, -2, -2, 0, 2, 2, 3, 6, -1, 0, 0, 1, 1, 0, 0, 3,
- 0, 3, 3, 3, 1, -2, -3, -1, 1, 3, 4, 3, 0, -3, -5, -4,
- 0, 2, 0, -1, -3, -4, -2, -2, 1, 4, 2, 0, -2, -3, -2, -1,
- 3, 6, 3, 1, -2, -2, 0, -1, 4, 7, 4, 1, -2, -3, -1, 0,
- 3, 6, 3, 0, -3, -3, -1, 0, 1, 3, 0, -1, -3, -2, 1, 1,
- 0, 1, -1, -2, -3, -1, 2, 2, -2, -1, -3, -3, -3, -1, 1, 2,
- 3, 1, -1, 0, 1, 0, 0, 0, 2, -1, -2, -1, 1, 0, -1, -1,
- 1, -1, -2, 0, 1, 0, -2, -3, 0, -2, -1, 1, 3, 1, -3, -5,
- 0, -2, -1, 2, 5, 2, -3, -5, 0, -2, -1, 4, 6, 3, -2, -5,
- 0, -2, 0, 4, 7, 4, -2, -4, 0, -2, 0, 4, 6, 4, -2, -4,
- -2, -2, -3, -4, -3, -2, -1, 0, 1, 1, 0, -1, -1, -1, 0, 1,
- 3, 3, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 0, 0, 1,
- 0, 0, 0, 0, -1, -1, -1, -1, -4, -4, -4, -4, -4, -4, -4, -3,
- -3, -3, -2, -3, -2, -1, -1, 0, 3, 4, 4, 5, 5, 6, 6, 7,
- -1, -2, 7, -2, -4, -1, -1, 0, -1, -2, 9, -1, -4, -1, -1, 0,
- -1, -3, 10, -1, -4, -1, -1, 1, -1, -3, 10, -2, -3, -1, -1, 2,
- -1, -2, 10, -2, -4, -1, -1, 2, -1, -2, 9, -2, -4, -1, -1, 2,
- -1, -2, 8, -2, -4, 0, -1, 1, 0, -2, 7, -2, -3, -1, 0, 2,
- 3, -4, 1, 3, -3, -2, 1, 0, 3, -5, 1, 4, -3, -2, 1, 0,
- 3, -6, 2, 5, -3, -1, 3, 0, 3, -6, 2, 5, -3, -1, 2, 0,
- 3, -6, 1, 5, -4, -2, 3, 0, 3, -6, 1, 5, -3, -2, 2, 0,
- 2, -6, 1, 4, -3, -1, 1, 0, 2, -6, 1, 4, -2, -1, 1, 0,
- 0, 0, 1, 1, 1, 0, 0, 2, 0, -1, 1, 1, 1, 0, 0, 2,
- 0, -1, 0, 0, 0, 0, 0, 2, 0, -1, 0, 0, 0, 0, -1, 0,
- 1, 0, 1, 0, 0, -1, -2, -1, 3, 1, 1, 0, 0, -2, -4, -3,
- 5, 3, 2, 1, 0, -3, -5, -4, 5, 4, 2, 0, -1, -4, -5, -5,
- 1, 0, -1, -2, -2, -3, -6, -9, 2, 0, -1, -1, 0, 0, -3, -6,
- 1, 0, 0, -1, 0, 0, -2, -5, 2, 1, 1, 1, 1, 2, -1, -3,
- 1, 1, 2, 1, 2, 2, 1, -1, 1, 1, 2, 1, 1, 1, 1, 1,
- 0, 0, 2, 1, 0, 0, 2, 2, 0, 1, 2, 2, 0, 0, 2, 2,
- -4, -3, 0, 1, 4, 6, 4, 3, -3, -2, 0, 0, 2, 4, 1, 0,
- -1, -1, 0, 0, 1, 1, -2, -3, 1, 1, 1, 0, 1, 1, -3, -5,
- 1, 1, 1, 0, 1, 1, -3, -5, -1, 0, 0, -1, 1, 1, -2, -4,
- -1, 0, 0, -1, 1, 2, 0, -2, -1, 0, 0, 0, 2, 3, 1, 0,
- -1, 0, 3, 4, 0, -4, -5, -5, 0, 0, 4, 5, 2, -2, -3, -2,
- 0, -1, 2, 4, 2, -1, -1, 0, 0, -2, -1, 1, 0, -2, 0, 1,
- 1, -2, -2, 0, 0, -1, -1, 1, 1, -2, -3, 0, 1, 0, -1, 0,
- 1, -2, -2, 1, 3, 1, 0, 0, 1, -2, -1, 2, 4, 2, 0, 0,
- 1, 2, 3, 2, 0, 2, 2, 1, -1, 0, 1, 0, -3, 1, 1, 1,
- -1, 0, 0, -2, -4, 0, 2, 1, -1, 2, 2, -1, -5, 0, 2, 1,
- -1, 3, 4, -1, -5, 0, 2, 1, -2, 2, 4, 0, -4, -1, 0, 0,
- -4, 0, 2, 0, -4, -2, 0, 0, -5, -1, 2, 1, -2, 1, 3, 2,
- 1, 0, 1, 0, 1, 2, -1, -2, 2, 0, -1, -2, 1, 3, 0, -1,
- 3, 0, -2, -4, 0, 3, 1, 0, 5, 1, -3, -5, -2, 2, 1, 1,
- 6, 1, -2, -5, -2, 1, 0, 1, 5, 1, -1, -5, -2, 0, -1, 0,
- 3, 0, -2, -4, -2, 0, -1, 0, 1, -1, 0, -2, 0, 1, 0, 1,
- 1, 1, 2, 3, 2, 1, 1, 2, -1, -1, 0, 1, 1, 0, 1, 1,
- -4, -3, 0, 0, 1, 1, 1, 2, -4, -3, 0, 2, 2, 2, 3, 2,
- -5, -4, 0, 1, 1, 1, 1, 2, -5, -4, -1, -1, -2, -2, -1, 0,
- -3, -2, 0, 0, -2, -3, -2, -1, 2, 3, 4, 4, 2, 0, 0, 0,
- -4, -2, 0, 1, 0, 0, 0, 0, -3, -1, 1, 1, 0, 0, 0, 0,
- -2, 0, 2, 2, 0, 0, 0, 2, -1, 1, 2, 1, -1, 0, 3, 5,
- 0, 2, 1, -1, -2, 0, 5, 6, 0, 1, 0, -3, -3, 0, 4, 6,
- 1, 1, -2, -4, -4, -3, 1, 2, 1, 0, -2, -4, -5, -4, -2, 0,
- -1, -3, -3, -3, -3, -2, -1, -1, 3, 2, 1, 0, 0, 1, 1, 1,
- 5, 4, 3, 2, 1, 1, 2, 2, 2, 1, 0, -2, -2, -2, -1, -1,
- 0, 0, 0, -1, -2, -2, -2, -2, 0, 1, 3, 3, 2, 1, -1, -1,
- 0, 1, 3, 4, 3, 2, 1, -1, -4, -3, -1, 1, 0, -2, -3, -3,
- -3, -4, -7, -8, -7, -4, -1, 2, 0, -1, -3, -4, -4, -2, 0, 2,
- 1, 0, 0, -1, -3, -2, 0, 2, 2, 1, 1, 0, -1, -1, 0, 2,
- 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 0, 0, 1, 2, 3, 3, 2, 2, 0, 0, 1, 3, 4, 4, 3, 2,
- 3, 3, 3, 0, -1, 0, 1, 2, 1, 1, 1, -1, -2, -1, -1, 1,
- -2, -2, -1, -3, -3, -2, -2, 0, -4, -4, -2, -2, -2, -2, -3, 0,
- -4, -4, -1, 1, 1, 0, -1, 2, -3, -1, 2, 3, 4, 3, 3, 5,
- -2, 0, 2, 3, 3, 3, 3, 3, -2, -2, 0, 0, 0, 0, 0, 1,
- 0, 2, 1, -1, -3, -1, 3, -2, -1, 0, -1, -1, -3, 0, 4, -2,
- -2, -2, -2, -2, -2, 1, 5, -2, -3, -2, -3, -1, -2, 1, 4, -3,
- -2, 0, -1, 0, -1, 0, 3, -5, 1, 2, 1, 2, 0, 0, 2, -5,
- 2, 4, 2, 3, 1, 1, 3, -3, 1, 2, 1, 1, 0, 1, 4, -2,
- 4, -3, -4, -1, 3, 3, 1, 3, 4, -4, -4, -1, 3, 2, 0, 2,
- 4, -3, -4, 0, 2, 2, -1, 1, 4, -3, -2, 1, 2, 1, -2, 0,
- 2, -4, -2, 1, 2, 0, -3, 0, 2, -3, -2, 0, 1, 0, -2, 2,
- 3, -1, -1, 0, 0, 0, 0, 3, 2, -2, -2, -2, -1, -1, -1, 2,
- 2, 2, 3, 4, 3, 1, 0, -1, 1, 0, 1, 2, 1, -1, -2, -2,
- 2, 1, 2, 1, 1, 0, -1, -1, 4, 3, 4, 3, 2, 1, 1, 1,
- 3, 2, 2, 2, 1, 1, 1, 1, -1, -2, -1, 0, -1, -1, -1, -1,
- -3, -3, -2, -1, -2, -2, -2, -2, -4, -4, -3, -3, -4, -4, -3, -3,
- 2, 1, -1, -3, -4, -2, 3, 4, 2, 2, 1, -1, -3, -2, 1, 2,
- 1, 2, 3, 3, 0, -2, -1, -2, -1, 0, 2, 4, 2, 0, -1, -3,
- -2, -2, 0, 3, 3, 2, 0, -3, 0, -2, -3, -1, 1, 2, 2, -1,
- 3, -1, -4, -5, -3, 0, 2, 0, 6, 3, -2, -6, -5, 0, 3, 1,
- -2, 3, -2, 0, 3, -2, -2, 1, -3, 4, -3, 0, 3, -2, -1, 2,
- -3, 5, -3, 0, 4, -2, -1, 2, -2, 4, -4, -1, 3, -3, -2, 2,
- -3, 4, -3, 0, 3, -3, -1, 2, -2, 5, -2, 0, 3, -3, -1, 2,
- -2, 4, -3, 1, 3, -2, -1, 2, -2, 3, -2, 1, 3, -2, 0, 2,
- 1, 0, 0, -1, 1, 2, -4, -1, 2, 0, 0, -1, 1, 2, -4, -2,
- 1, 1, 1, -1, 2, 4, -2, 0, 0, -1, 1, -1, 2, 5, -1, 1,
- 0, -1, 0, -2, 1, 5, -1, 1, 0, -1, -1, -2, 0, 3, -3, -1,
- 1, 1, 0, -2, 0, 3, -3, -1, 1, 1, 0, -3, 0, 3, -2, 0,
- 1, 0, -1, 1, 1, 2, 4, 5, 1, 0, -1, 1, 1, 1, 5, 7,
- 0, 0, -2, -1, -1, 0, 3, 5, 0, -1, -2, -1, -1, -1, 2, 3,
- 0, -1, -3, -1, -1, -1, 1, 2, -1, -2, -4, -2, -2, -2, 0, 0,
- -1, -2, -2, -1, -2, -2, 0, 0, 0, -1, -1, 0, -1, -1, 0, 0,
- 3, 3, 0, -1, -1, 1, 4, 4, 2, 3, 0, -2, -2, 0, 1, 1,
- 2, 3, 1, -1, -1, 0, 1, 0, 1, 2, 0, -1, -1, -1, 0, -2,
- 0, 1, 0, -1, -2, -1, 0, -2, 0, 1, 0, -1, -2, -1, 1, 0,
- 1, 1, -1, -3, -4, -3, 1, 3, 1, 2, -1, -3, -5, -4, 1, 3,
- -3, -2, 0, 1, 1, 1, 0, -2, 0, 1, 1, 1, 0, 0, -1, -3,
- 1, 2, 1, 1, 0, -1, -1, -2, 0, -1, -3, -1, -1, -1, 0, -1,
- 0, -3, -6, -3, -2, -1, 1, 1, 2, -1, -4, -3, -2, 0, 2, 2,
- 5, 4, 1, 1, 0, 1, 3, 2, 5, 4, 2, 1, 0, -1, 0, 1,
- -2, 0, -2, -5, -6, -3, 0, 0, -2, 0, 1, 0, -1, 1, 2, 2,
- -2, 0, 1, 3, 2, 2, 2, 1, -2, 0, 2, 4, 3, 2, 1, 1,
- -2, 0, 2, 3, 2, 0, -1, 0, -3, -1, 1, 1, 0, -1, -1, 1,
- -4, -1, 1, 0, -1, -2, 0, 2, -4, -1, 0, -1, -1, -2, 1, 4,
- -3, 0, 0, -1, 1, 1, 1, 0, -3, 1, 0, -1, 0, 0, -1, -1,
- -1, 3, 3, 0, 1, 0, 0, 1, -3, 2, 2, -2, -1, 0, 0, 1,
- -5, 0, 0, -2, -1, 1, 0, 2, -7, -2, 1, 0, 1, 2, 2, 2,
- -5, 0, 3, 2, 3, 3, 2, 2, -3, 2, 4, 1, 0, 0, -2, -3,
- 5, 2, -2, -2, 0, -1, -1, -1, 2, -1, -4, -3, -1, -2, -1, -1,
- 0, -2, -2, 1, 2, -1, 0, 1, -1, -2, -1, 3, 3, -1, 0, 2,
- 1, 0, 0, 3, 3, -2, -1, 2, 2, 1, 1, 3, 2, -2, -2, 0,
- 1, 0, -1, 1, 1, -3, -3, -2, 1, 0, 1, 2, 3, 0, 0, 0,
- -4, -5, -3, 0, 1, -1, -2, -1, -2, -3, -1, 1, 2, 0, 0, 0,
- 1, 1, 2, 1, 2, 1, 1, 1, 3, 4, 3, 1, 0, -2, -1, -1,
- 3, 3, 2, 0, -2, -3, -3, -2, 1, 1, 0, -1, -2, -4, -2, -2,
- 2, 1, 0, 0, 0, -1, 0, 1, 2, 1, 1, 1, 1, 1, 1, 3,
- 0, 0, 0, -1, -2, -1, 1, 0, -2, -1, -1, -2, -3, -2, 0, 0,
- -1, 0, 0, -1, -2, 0, 1, 1, 1, 1, 0, -1, -1, 1, 3, 1,
- 2, 2, 0, -2, -1, 2, 3, 0, 3, 1, -1, -1, 1, 4, 2, -2,
- 2, 0, -3, -1, 3, 5, 0, -5, 1, -1, -2, 0, 3, 3, -1, -6,
- -1, 0, 3, 4, 2, 0, 1, 2, -2, -1, 0, 1, -1, -2, 0, 1,
- -2, -3, -2, -3, -6, -7, -6, -3, 2, 2, 3, 1, -1, -2, -3, -2,
- 2, 2, 3, 1, 0, 0, 0, 0, 2, 1, 1, 0, 1, 1, 0, 1,
- 1, 0, 0, 0, 0, 1, 1, 2, 1, 0, -1, 0, 0, 2, 2, 1,
- 1, 1, 3, 1, -1, -1, -1, 1, -2, -1, 0, 0, -2, -2, -1, 2,
- -2, -2, 1, 1, 1, 0, 1, 3, -2, -2, 0, -1, 0, -1, 0, 2,
- 0, 0, 1, 0, -1, -1, -2, 1, 3, 2, 2, 1, 0, -2, -2, 1,
- 5, 3, 3, 2, 1, 1, 1, 4, 0, -3, -4, -5, -4, -3, -1, 1,
- -6, -4, -1, 2, 2, 0, 0, -1, -4, -2, 1, 3, 3, 2, 2, 0,
- -3, -2, -1, 2, 3, 3, 2, 0, -3, -2, -2, 1, 2, 1, 1, -1,
- -2, -2, -2, 0, 2, 2, 1, -1, -1, -1, -1, 1, 2, 3, 2, 0,
- -1, -1, -2, 1, 2, 2, 2, -1, 0, -1, -2, 0, 2, 1, 0, -1,
- 6, 4, 2, 1, 0, 0, 0, 1, 4, 2, -1, -2, -2, -2, -1, -1,
- 2, 1, -1, -2, -2, -2, -2, -1, 2, 2, 0, -2, -2, -2, -1, 0,
- 0, 0, -1, -2, -2, -1, 0, 1, -3, -3, -2, -1, -1, -2, -1, 0,
- -3, -2, 2, 3, 2, 0, -1, -2, -2, 0, 4, 5, 5, 2, 0, -1,
- 5, 4, 2, 0, -1, -2, -1, -1, 4, 3, 2, 1, 0, -1, 0, -1,
- 1, 1, 0, 1, 1, 0, 1, -1, -2, -1, -1, 0, 0, -2, -2, -3,
- -1, 0, 0, 0, -1, -3, -3, -5, 0, 1, 1, -1, -1, -2, -2, -3,
- -1, -1, -1, -2, -1, 1, 3, 1, -1, -2, -2, -1, 2, 5, 6, 5,
- -3, -3, -2, 1, 1, -2, -1, -1, 1, 2, 3, 4, 1, -3, -1, -3,
- 3, 2, 0, 1, -1, -3, -1, -3, 1, 0, -1, 0, -1, -1, 1, 0,
- 1, 1, 0, 1, 2, 2, 5, 3, 1, 1, 1, 2, 2, 2, 3, 0,
- -3, -1, -2, -2, -3, -3, -1, -3, -1, 1, 1, 0, -1, -1, 0, -2,
- 2, 0, -2, -2, 2, 4, 1, -2, 1, 0, -2, -1, 3, 5, 2, -1,
- -1, -2, -3, -2, 1, 3, 1, -2, -1, -2, -1, -1, 0, 2, 1, -1,
- 0, 0, 1, 1, 1, 2, 2, 0, 0, 1, 4, 4, 2, 2, 3, 1,
- -2, -1, 2, 1, -2, -3, -2, -3, -1, 0, 1, 0, -3, -4, -4, -5,
- 4, 0, -3, -4, -4, -4, -2, -1, 5, 0, -1, 0, -1, -3, -2, -1,
- 4, 0, 0, 1, 1, 0, 0, 0, 0, -3, -2, -1, 0, 0, 1, 0,
- 0, -2, 0, 0, 1, 1, 2, 1, 2, 0, 0, 0, 1, 1, 1, 0,
- 2, 0, -1, -1, 1, 1, 1, 0, 1, -1, -2, -2, 0, 2, 2, 2,
- -3, -5, -2, 0, -1, -3, -3, 0, 0, -2, 0, 2, 2, 0, 0, 3,
- 2, -1, -2, 0, 0, -1, -1, 2, 5, 2, -1, -1, -1, -1, -1, 2,
- 5, 2, 0, -1, -1, 0, -1, 2, 2, 1, 0, 0, 0, 1, 0, 2,
- -1, -1, 1, 1, 2, 2, 1, 2, -3, -2, 0, 0, 0, 0, -2, -1,
- 0, 3, 2, 0, -2, -3, -3, -3, 0, 3, 3, 1, 0, 0, 1, 2,
- -1, 0, -1, -2, -1, -1, 1, 3, -1, 0, -1, -2, -1, -1, 0, 2,
- -1, 0, -1, -2, 0, 0, -1, 2, -1, 0, -1, -2, -1, -1, -2, 1,
- 0, 1, 0, -3, -1, -1, -1, 2, 5, 5, 2, -1, -1, -1, 1, 3,
- 0, 0, 1, -1, -3, -2, 0, 2, 1, 1, 3, 0, -2, -2, 0, 1,
- 1, 1, 3, 1, 0, 0, -1, -1, 0, -1, 2, 1, 1, 0, -1, -3,
- -1, -2, 1, 1, 1, 0, -2, -4, -1, 0, 2, 1, 1, 0, -1, -3,
- 1, 1, 3, 2, 1, 0, -2, -3, 2, 2, 4, 2, 1, -1, -2, -4,
- 1, 2, 2, 2, 0, -2, 0, 2, -1, -1, -2, -3, -4, -5, -3, 1,
- 0, 1, 1, 0, -1, -1, -1, 1, 0, 1, 1, 1, 0, 0, 0, 2,
- 0, 1, 1, 2, 1, 1, 1, 2, -1, -1, 0, 2, 2, 2, 2, 3,
- -2, -4, -4, -1, -2, -2, -2, 0, 1, 0, 0, 1, 0, 0, 0, 1,
- 0, -1, -3, -2, 0, 2, 2, 1, 0, -1, -2, -3, 0, 1, 1, 2,
- 1, 0, -2, -3, -1, 0, 0, 1, -1, 0, -1, -2, 0, 0, -1, 0,
- -1, 1, 1, 0, 2, 2, 0, 0, 0, 2, 3, 1, 3, 5, 3, 2,
- -1, 1, 1, -2, 0, 3, 1, 1, -1, 0, 0, -4, -4, -1, -1, -1,
- -1, 1, 1, 0, 1, 2, 1, 2, -3, 0, 1, 0, 1, 1, 0, 2,
- -5, -3, -1, -1, 0, 1, 0, 1, -4, -3, -2, -3, -2, -1, -1, 0,
- 0, 0, -1, -2, -2, -2, -2, 0, 3, 4, 2, 0, 0, 0, 0, 1,
- 2, 1, 0, 0, 0, 0, -1, 0, 0, 1, 2, 3, 4, 4, 3, 2,
- -1, 4, 7, 4, 0, 0, 0, 0, -1, 4, 6, 3, 0, 1, 1, 1,
- 0, 3, 4, 0, -1, 0, 0, 1, 0, 1, 1, -2, -1, 0, -1, -1,
- -1, 0, -1, -1, -1, 0, 0, 0, -1, -1, -1, 0, 0, 0, 0, 0,
- -1, -3, -3, 0, 1, -1, -2, -1, -3, -4, -4, -2, -1, -2, -2, -1,
- 2, 2, 1, 0, 1, 1, 0, -3, -2, -1, 0, 0, 1, 1, 0, -3,
- -2, -1, 0, 1, 2, 1, 1, -2, 1, 2, 2, 2, 3, 3, 2, -1,
- 1, 2, 1, 0, 1, 1, 2, -1, 0, 1, -2, -4, -2, 0, 1, -1,
- 1, 1, -1, -3, -2, 0, -1, -3, 1, 2, 0, -1, 0, 1, -1, -4,
- -1, -1, -2, -2, 0, 3, 4, 3, 1, 1, -1, -3, -2, 0, 0, 0,
- 2, 2, 2, 2, 2, 1, -1, -1, 1, 1, 1, 3, 3, 0, -2, -2,
- 0, -1, -1, -1, 0, -2, -1, -1, -1, -3, -4, -3, -2, -2, 0, 2,
- -1, -1, 0, 1, 2, 2, 3, 5, -2, -1, -1, 0, 0, 0, 0, 1,
- -2, -3, 2, 0, 0, 1, 1, -1, -1, -4, 1, -2, -1, 2, 2, 0,
- 1, -4, 0, -2, -2, 1, 1, -1, 2, -3, 1, -1, -1, 1, 1, -1,
- 3, -2, 3, 1, 0, 1, 1, -1, 1, -3, 2, 1, 0, 1, 0, -1,
- -1, -5, 1, 0, -1, 0, 1, 1, 0, -3, 3, 3, 1, 2, 3, 3,
- 0, -1, -2, 1, 5, 5, 2, -1, 1, -1, -2, -1, 1, 1, -2, -5,
- 1, 1, -1, -2, -1, -1, -1, -3, 1, 1, -1, -1, -1, 2, 4, 3,
- -1, -1, -1, -1, -1, 0, 4, 3, -1, -1, 0, 1, -1, -3, -1, -1,
- 0, 0, 0, 2, 2, 0, 0, -1, 0, -2, -3, 0, 1, 1, 3, 2,
- 2, 3, 2, 1, 0, 0, -2, -2, 2, 3, 0, 1, 1, 3, 3, 2,
- 0, 0, -3, -1, -1, 2, 2, 3, -2, -2, -3, 1, 1, 2, 1, 1,
- -2, -1, -2, 2, 1, 1, -1, -2, 0, 1, 0, 2, 0, 0, -2, -2,
- 0, 1, 0, 2, 0, 0, -2, -2, -3, -2, -2, 0, -1, -2, -2, -3,
- 0, 1, -1, 3, -1, 1, 3, -1, 0, 1, -1, 3, -1, -1, 2, -3,
- 1, 1, -2, 3, -1, -3, 0, -3, 2, 2, -2, 3, 0, -2, 1, -2,
- 1, 1, -3, 3, -1, -2, 1, -3, 1, 1, -3, 3, 0, -1, 1, -2,
- 1, 2, -1, 4, 0, -1, 1, -2, 0, 1, -1, 3, -1, -3, 0, -3,
- -3, -3, -1, 1, 2, 1, -1, -2, -2, -2, 0, 2, 1, 0, -2, -2,
- -3, -2, 1, 2, 1, -1, -2, -1, -3, -2, 2, 4, 0, -2, -2, 1,
- -3, -1, 2, 4, 0, -2, -2, 2, -1, 1, 4, 3, -1, -3, -2, 2,
- 0, 2, 4, 2, -1, -2, -1, 2, 0, 1, 2, 0, -1, 0, 1, 3,
- 3, 0, -5, 1, 4, 0, 0, 1, 1, -2, -5, 2, 5, -1, -2, 1,
- -1, 0, 0, 3, 3, 1, 0, -1, -2, 3, 4, -2, -3, -1, 0, -2,
- -3, 3, 5, -3, -3, 0, 0, -2, -1, 3, 2, -2, -2, 2, 2, -1,
- 2, 0, 0, -1, 0, 0, 0, 0, 0, -3, -2, 1, 3, 0, -2, -2
-};
-
-/* list of codebooks for inter-coded vectors */
-static uint8_t *inter_codebooks[4] = {
- inter_codebook_4x2, inter_codebook_4x4, inter_codebook_8x4, inter_codebook_8x8
-};
-
-/* 6x16-entry codebook for intra-coded 4x2 vectors */
-static int8_t intra_codebook_4x2[768] = {
- 12, 13, 13, 11, -7,-10,-15,-17,-16,-15,-12,-10, 11, 15, 15, 12,
- 2, 17, 20, 15,-45,-24, 2, 13, 21, 20, -6,-36, 12, 16, -1,-27,
- -18,-21, 10, 45,-11,-20, -7, 21, 43, -8,-28, 0, 33,-16,-28, 3,
- -12,-18,-18, -6,-20,-10, 28, 55, -5,-18,-21,-18, 56, 30, -6,-20,
- -34, 27, 29,-22,-30, 29, 26,-25, 30, 34, 33, 26,-25,-31,-35,-33,
- -31,-35,-36,-32, 29, 36, 37, 31,-71,-12, 38, 34,-63, -1, 42, 33,
- 58, 37,-31,-60, 55, 34,-33,-61,-57,-57, 22, 93,-57,-58, 21, 93,
- 59, 69, 70, 62,-63,-68,-68,-60,-64,-71,-71,-64, 63, 73, 72, 62,
- -2, 0, 7, 15,-11,-10, -3, 5, -5, -8,-10,-10, 1, 9, 14, 9,
- 15, 8, -4,-11, 12, 2,-11,-12, -8, 0, 19, 28, 4, -1,-15,-26,
- -15, 27, 2,-14,-14, 22, 1, -9, -4, -6,-13,-10, -6,-14, 6, 47,
- -35,-20, 6, 23, 6, 9, 6, 4, -6, 2, 23,-22, -7, 4, 28,-21,
- 20,-22, -2, 6, 22,-28, -5, 8,-10,-18,-16,-12, 36, 19, 2, -1,
- -3, 0, 4, 8,-45,-10, 23, 23, 40, 15,-20,-35, -4, -1, 4, 1,
- 9, -5,-33, 24, 8, 3,-26, 19, -1, 4, 6, -3, 32, 25,-13,-49,
- 24, 24, 15, 7,-17,-27,-19, -7,-47, 0, 39, 24,-21, -6, 7, 4,
- -1, 0,-10,-13, 1, 1, 5, 16, 20, 5, -3, -9, -1, -4, -2, -6,
- -17, -7, 1, 4, 12, 7, 0, 0, 3, 0, 12, 11, -3, 1, 0,-23,
- 4, 17, -6, 0, 6, 3,-25, 0,-17, 10, 8, 5,-14, 4, 1, 4,
- 13, 10, 4, 2,-23, -9, 1, 2, 3, -3, 1, 7, 1,-23, -7, 20,
- -7,-18, 2, 12, -5, -4, 10, 9, 4, 10, 7,-24, 6, 3, 4,-10,
- 22,-14,-22, 6, 0, 5, 5, -1, -4, 3,-11, -4, -7, 31, 7,-14,
- -5,-16, -1, 42, -4, -2, -9, -5, 5, -8, -6, -3, 42, -4,-21, -5,
- -18, 12, 20,-12, 13,-13,-10, 7, -8, -9, -2,-18,-16, 6, 40, 8,
- 10, -1, 0, 4, -3, 4, -1,-13, -2, 6, 1,-15, 5, 3, 1, 2,
- -4, -2, 1, 3, 15, 0, -9, -4, -3, -4, -4, -4, -3, 5, 16, -3,
- 2, 13, 3, 4, -3, -8,-10, 0, -6, -2, -4, -1, -2, -3, -6, 23,
- 6, -6, 7, 1, 4,-18, 5, 1, -1, 1,-15, 14, -5, 6, -4, 4,
- 2, 2, 2, 6,-24, 2, 7, 3,-26, 0, 3, 3, 5, 7, 1, 6,
- 14, -2,-18, -3, 7, 5, -4, 2, -6, 3, 32, 1, -6, -6, -6,-12,
- 5,-36, 7, 6, 9, -1, 11, 0, 4, 4, 5, 3, 4, 15, 3,-38,
- 10, 23, -5,-42, 0, 4, 4, 4, 23, 17, -6,-13,-13,-37, 1, 29,
- 5,-14, -1, 1, 5, 0, 3, 1, 0, 4, -5, 2, 8, 0, 0,-10,
- 4, 7, -2, -3,-10, 3, 1, 1,-12, -1, 13, 3, 0, -1, 1, -3,
- 0, -1, 3, 1, -6, -9, 3, 9, -6, 1, -4, -6, 8, -1, 0, 8,
- -3, -3, 0, 18, -5, -1, -4, -1, -8, -2, 3, -4, 0, 17, -1, -5,
- 5, -2, 9,-10, 1, -5, 6, -5, 4, 2, 2, 3, 10,-14, -8, 1,
- -1, -2,-18, -1, -1, 20, 1, 2, -1, 1, -9, 1, -1, -9, 22, -4,
- 6, -4, 8, -3, -1, 7,-19, 5, -7, 31, -4, -4, -6, 0, -5, -5,
- -7, -8,-19, -4, 1, 1, 4, 32, 38, -1, -8, 4, -7, -8, -6,-12,
- -1, 0, -7, 1, -1, 9, -1, 0, 9, -1, -1, 0, 2, -6, 1, -3,
- -12, 0, 2, 1, 1, 1, 8, 0, 9, 1, 0, 2, -2, 1,-11, 0,
- 0, 8, 2,-10, -1, 2, -1, 0, -2, -4, 0, -5, -2, -1, -1, 14,
- -3, 7, -1, 5, 0,-10, 1, 1, -1, -5, 14, -1, -2, 1, -3, -2,
- -6, 0, 0, 6, 2, 3, -9, 4, 4, -5, -1, -1, -7, 3, 8, -1,
- 2, -4, -1,-11, 11, 2, 1, 0, -1, 2, 3, 9, 0, 2, 0,-15,
- 3, 5,-20, 3, 3, -1, 3, 3, 1, -1, 16, 1, 2,-29, 9, 2,
- -13, -6, -1, -3, 36, -1, -8, -3, 2, 5, 4, 2,-37, 9, 11, 3
-};
-
-/* 6x16-entry codebook for intra-coded 4x4 vectors */
-static int8_t intra_codebook_4x4[1536] = {
- -11, -3, 3, 6,-10, -1, 5, 7, -9, -1, 6, 7, -9, -1, 4, 6,
- 5, 7, 0,-14, 6, 9, 2,-15, 6, 9, 2,-15, 4, 6, 0,-14,
- 16, 3, -5, -6, 16, 1, -8, -8, 14, -1, -9, -9, 12, 0, -8, -8,
- 8, 12, 16, 17, -2, 2, 6, 9,-10, -8, -4, 0,-15,-14,-11, -7,
- -7,-10, -2, 16, -7,-11, -3, 18, -7,-11, -1, 20, -6, -8, 1, 19,
- -9,-13,-16,-17, 2, -2, -7, -9, 11, 8, 4, -1, 16, 15, 11, 7,
- -22, -2, 13, 15,-24, -2, 14, 16,-25, -4, 13, 15,-25, -6, 10, 13,
- 26, 26, 22, 16, 17, 15, 9, 3, -2, -6,-11,-14,-20,-25,-28,-28,
- -27,-27,-25,-21,-16,-15,-11, -7, 3, 8, 12, 13, 23, 28, 31, 30,
- 20, 16, -7,-33, 22, 19, -6,-35, 22, 19, -6,-34, 20, 17, -6,-32,
- -20,-20, 2, 38,-21,-22, 2, 40,-21,-22, 2, 40,-20,-20, 3, 38,
- -47, -4, 24, 26,-50, -3, 26, 27,-50, -3, 26, 27,-47, -4, 24, 26,
- 45, 6,-23,-27, 48, 5,-25,-28, 48, 5,-26,-28, 44, 6,-24,-27,
- -30,-36,-10, 76,-31,-37,-11, 78,-31,-37,-11, 78,-31,-36,-10, 77,
- -53,-32, 35, 52,-54,-34, 36, 52,-54,-34, 36, 52,-53,-33, 34, 51,
- -93,-34, 62, 65,-93,-34, 62, 66,-93,-34, 62, 65,-93,-34, 60, 64,
- -7, 0, 2, 2, -8, -1, 3, 3, -8, 0, 4, 5, -6, 1, 5, 5,
- 3, 7, 11, 11, 2, 2, 3, 3, 1, -2, -6, -7, 1, -5,-11,-13,
- 3, -2, -4, -3, 7, 0, -5, -5, 12, 4, -5, -7, 14, 6, -4, -7,
- 18, 14, 3, -2, 6, 4, 0, -3, -8, -5, -2, 0,-16,-11, -2, 2,
- -8, -6, 7, 18, -7, -8, 2, 13, -4, -6, -2, 6, 0, -4, -3, 1,
- 1, -3,-13,-18, 0, -1, -5, -7, -1, 1, 6, 7, -2, 4, 15, 17,
- -15,-14, -7, -2, -6, -5, -1, 0, 6, 6, 3, 1, 15, 13, 6, 1,
- 2, -2,-11, 10, 2, -1,-12, 11, 3, -1,-12, 11, 2, -2,-11, 11,
- -9, 14, -1, -5, -9, 15, -2, -5, -8, 16, -2, -5, -7, 15, -1, -4,
- 2, 6, 8, 8, -2, 3, 9, 12,-11, -5, 4, 10,-19,-16, -8, 0,
- 14, 8, -7,-15, 12, 7, -7,-14, 8, 5, -4, -9, 5, 3, -1, -4,
- 12,-14, -2, 2, 13,-15, -1, 3, 14,-15, -1, 3, 13,-14, -1, 3,
- 0, 6, 10,-13, 0, 6, 10,-15, 0, 7, 9,-17, 1, 6, 8,-16,
- -8, -5, 15, -2, -8, -6, 17, -2, -8, -6, 16, -3, -8, -5, 15, -2,
- -9,-11,-11,-10, 9, 10, 9, 8, 8, 10, 10, 9, -8, -9, -8, -7,
- 9, 10, 9, 7, -8,-10,-10,-10, -7,-10,-11,-11, 11, 12, 11, 8,
- 0, 10, 7, 0, 0, 7, 0, -6, 0, 2, -5, -6, -2, -1, -4, -1,
- 5, 0, -6, -9, 2, 2, 2, 1, -2, 0, 5, 7, -6, -5, 1, 4,
- 3, -8, 2, -1, 4, -9, 3, 0, 5, -7, 3, 0, 7, -5, 3, 0,
- -5, -3, 2, 9, -6, -3, 1, 8, -6, -3, 1, 7, -5, -2, 0, 4,
- 13, 8, 3, 1, -3, -5, -4, -1, -8, -7, -3, 0, -1, 1, 3, 2,
- 3, 2, -5,-12, 4, 3, -2, -9, 3, 4, 1, -4, 3, 5, 4, -1,
- -9, -8, -4, 0, 8, 6, 2, 0, 10, 8, 3, 0, -6, -5, -3, -1,
- -3, -9,-12, -5, 0, -3, -5, 0, 2, 3, 2, 4, 5, 8, 7, 6,
- -1, -2, 5, 12, -1, -1, 5, 9, 2, 1, -1, -2, 2, -1,-11,-17,
- -7, 3, 3, -1, -9, 3, 4, -1,-10, 4, 6, -1, -9, 5, 7, 0,
- -18, -7, 2, 2, -8, 1, 5, 3, 3, 4, 1, 0, 9, 5, -2, -3,
- -2, 0, 6, 8, -4, -5, -5, -3, 1, -2, -6, -8, 10, 9, 3, -1,
- 0, -2, -2, 0, 0, -4, -5, 0, -2, -8, -4, 8, -5, -7, 6, 24,
- 9, 1, -7, 1, 9, 1, -8, 1, 8, 0,-10, 1, 8, -1,-11, -1,
- 8, 8, 6, 3, 5, 4, 3, 2, -2, -3, -1, 0,-10,-13, -8, -4,
- 0, 4, 2, -3, 0, 6, 3, -5, 3, 10, 2,-12, 5, 10, -4,-22,
- 0, -4, -1, 3, 1, -4, -1, 5, 1, -5, 0, 8, -1, -6, -2, 7,
- -1, -1, -2, -4, -1, -2, -4, -6, -1, -1, -1, -2, 1, 5, 10, 9,
- 10, 3, 0, -2, 6, -1, -2, -5, 3, -1, -2, -6, 2, 0, 0, -5,
- 6, 3, 0, 0, 6, 3, 1, 1, 4, -2, -2, 1, 0, -9, -9, -2,
- -11, -3, 1, 2, -6, 2, 4, 5, -3, 2, 3, 4, -2, 1, 1, 2,
- -6, -4, -1, -2, 2, -1, -1, -2, 10, 2, -2, -2, 11, 2, -4, -1,
- 6, 0, -2, 2, 3, 3, 0, 0, -6, 3, 3, 0,-17, -1, 5, 0,
- -1, 4, 10, 11, -3, -2, 0, 1, -3, -4, -5, -3, -1, -2, -2, -1,
- 2, -3, -9,-12, 3, 3, 3, 2, 2, 2, 4, 4, 2, 1, -1, -2,
- -2, 9, 5,-10, -3, 5, 5, -5, -2, 1, 2, 0, -1, -2, -2, 1,
- -2, -3, 7, -2, -1, -3, 7, -3, -1, -2, 8, -4, -2, -2, 7, -3,
- 1, -8, -3, 12, 2, -2, -2, 4, 1, 3, 0, -5, -1, 5, 2, -7,
- -1, 3, 1, -5, -7, -2, 3, 1, -2, -7, -2, 2, 20, 3, -5, -1,
- 5, 0, -3, -2, -7, -7, 0, 6, -6, 0, 7, 6, 2, 6, 0, -7,
- -2, 6, -7, 1, -2, 7, -8, 3, -2, 7, -7, 3, -1, 7, -6, 2,
- -5, -2, 5, 7, 4, 1, -4, -8, 6, 3, -2, -5, -7, -5, 3, 7,
- -1, -1, 6, 5, 0, -1, 1, -4, 2, 1, 0, -7, 1, 0, 0, -4,
- -8, 0, 3, 1, -2, 1, -1, -1, 1, -1, -3, 1, 1, -2, 1, 9,
- 5, 2, -3, -4, -1, 0, -1, -3, -3, 1, 3, 1, -4, 0, 4, 2,
- 2, -2, -2, 12, 0, -2, -5, 3, -1, 0, -3, 1, -3, -1, -2, 1,
- 1, 5, 3, 0, -6, -4, -2, 1, 0, -2, -2, 2, 6, 1, -4, -1,
- -3, -5, -5, -1, 3, 5, 5, 4, 0, 3, 1, -1, -2, 1, -2, -3,
- 2, -4, -5, -3, 4, -2, -3, -2, 6, 0, -1, -1, 7, 1, 0, 0,
- -3, -2, -2, 0, -2, -3, -5, -1, -2, 2, 0, -1, -1, 11, 9, -1,
- 0, 1, -1,-10, -1, 1, 0, -6, 1, 0, 1, 4, 2, -5, -1, 13,
- -2, 4, 5, 0, -5, 1, 6, 3, -6, -2, 3, 2, -5, -2, 0, -2,
- -1, 1, 1, -2, -1, -2, 0, 2, 5, 5, 5, 7, 0, -4, -8, -7,
- 0, 2, -1, -5, -1, 2, 2, -3, 0, 5, 3, -5, 3, 8, 2,-12,
- 8, 4, 0, -2, 10, -1, -4, -1, 3, -6, -3, 0, -4, -5, 0, 0,
- 0,-10, -4, 2, -1, -6, 3, 5, -1, -3, 6, 4, 0, -2, 4, 2,
- 0, 8, 1, -1, 0, 11, 1, -3, -1, 6, -2, -4, -3, -2, -7, -4,
- 0, -1, -1, -1, 4, 5, 6, 5, -5, -9, -8, -5, 2, 2, 3, 2,
- 0, 2, 6, 1, 2, 0, 3, 0, 1, -2, -1, -2, 0, -1, -3, -6,
- 0, 0, 2, 0, 4, 0, 2, 1, 5, -2, 0, 0, -2, -9, -1, 2,
- 0, 1, 0,-10, -1, 1, 8, 0, -1, -2, 4, 0, 1, -1, 2, -1,
- -3, -2, 2, -1, -3, -1, 2, -3, 0, -1, 1, 0, 8, 1, -1, 3,
- 0, 1, 1, 2, 0, -4, -2, 0, -1, -5, 1, -1, -2, -1, 11, 2,
- 1, 5, -2, -2, 0, 2, -4, 0, -2, 1, -5, 1, 0, 5, 0, 1,
- -5, -3, 0, 6, -4, 2, 0, 0, -3, 5, 1, 0, -3, 3, 0, 0,
- 3, -2, -3, 1, 1, -4, 0, 8, -2, -3, -2, 3, 1, 2, -1, -1,
- 1, 1, 0, 2, 2, 0, 1, 6, 1, -1, 2, 1, 0, 3, 0,-19,
- 1, -3, -2, 2, 6, 5, -2, -7, -3, 1, 3, 1, -1, -1, 0, 2,
- -8, -1, -1, -4, 1, 1, -1, 2, 4, 3, 2, 3, -5, 1, 3, 0,
- 0, 2, -1, 1, -3, 0, 0, 5, -5, -2, 0, 8, -4, -4, -4, 6,
- 1, 2, 1, 2, 2, 2, -3, 2, 4, 0, -9, 0, 7, 0,-11, 1,
- 0, 0, 0, -2, 3, 3, -1, -6, 4, 3, -3,-10, -1, 2, 6, 2,
- 7, -2, -3, 5, -4, 0, 3, -1, -4, 2, 1, -7, 2, -1, -1, 3,
- 3, 2, 2, 2, -5, -7, -7, -5, 5, 6, 4, 2, -2, -1, 0, 1
-};
-
-/* 6x16-entry codebook for intra-coded 8x4 vectors */
-static int8_t intra_codebook_8x4[3072] = {
- 5, 6, 6, 6, 7, 7, 8, 8, 0, 0, 0, 0, 0, 1, 2, 3,
- -3, -4, -4, -5, -5, -4, -3, -2, -4, -4, -4, -5, -4, -4, -3, -3,
- 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 4, 4, 5, 5, 5,
- -1, 0, 1, 1, 2, 3, 4, 4, -9,-10, -9, -9, -8, -7, -6, -5,
- -4, -4, -5, -6, -6, -7, -7, -7, 0, -1, -2, -2, -3, -3, -4, -4,
- 4, 4, 3, 3, 2, 1, 1, 0, 7, 7, 7, 6, 6, 5, 4, 4,
- 2, 4, 5, 6, 4, 1, -3, -6, 3, 4, 5, 5, 4, 0, -5, -8,
- 2, 3, 4, 4, 2, -2, -7,-10, 2, 2, 2, 1, 0, -4, -9,-12,
- -9, -7, -3, 1, 4, 4, 3, 3,-10, -7, -2, 3, 5, 5, 3, 3,
- -9, -6, -2, 3, 6, 5, 4, 3, -8, -6, -1, 3, 4, 4, 3, 2,
- -5, -5, -5, -5, -3, 1, 4, 7, -5, -5, -5, -4, -2, 1, 6, 8,
- -4, -5, -4, -3, -1, 3, 8, 10, -3, -4, -3, -2, 1, 5, 9, 11,
- -2, -2, -2, -2, -2, -2, -2, -2, -4, -5, -5, -5, -5, -5, -5, -4,
- -3, -4, -4, -4, -4, -4, -4, -3, 9, 10, 10, 11, 11, 11, 10, 10,
- 7, 4, 1, -2, -4, -6, -9,-10, 9, 7, 3, 0, -2, -4, -8, -9,
- 11, 8, 4, 2, 0, -3, -6, -8, 11, 9, 5, 3, 1, -2, -5, -7,
- -13,-13,-13,-12,-11,-10, -8, -8, 0, 1, 2, 3, 4, 4, 4, 3,
- 3, 4, 5, 6, 6, 6, 5, 4, 3, 4, 4, 4, 3, 3, 3, 2,
- 10, 10, 11, 10, 9, 9, 8, 7, 6, 6, 6, 6, 5, 4, 3, 2,
- 0, 0, 0, -1, -2, -3, -4, -4,-10,-10,-11,-12,-13,-14,-14,-14,
- 16, 16, 17, 16, 15, 13, 12, 11, -1, -2, -3, -4, -4, -4, -4, -3,
- -4, -5, -6, -6, -6, -6, -6, -6, -5, -6, -6, -6, -6, -6, -5, -5,
- -13,-13,-13,-12,-11,-10, -8, -6, -9, -8, -7, -6, -4, -2, 0, 1,
- -2, -1, 1, 3, 5, 7, 8, 9, 5, 7, 9, 11, 13, 14, 15, 15,
- 16, 14, 11, 7, 2, -3, -7, -9, 14, 12, 8, 3, -1, -6, -9,-11,
- 11, 9, 4, 0, -4, -8,-11,-13, 8, 5, 1, -3, -6,-10,-12,-14,
- -18,-15, -9, -3, 1, 6, 9, 11,-17,-13, -7, -1, 3, 7, 11, 12,
- -15,-11, -5, 1, 5, 9, 12, 13,-13, -9, -3, 2, 5, 9, 11, 13,
- 22, 21, 19, 15, 10, 3, -4, -9, 20, 18, 15, 9, 2, -5,-12,-17,
- 16, 13, 8, 1, -7,-14,-20,-24, 10, 6, -1, -8,-15,-21,-25,-27,
- -25,-23,-20,-14, -7, 1, 9, 14,-23,-21,-16, -9, 0, 9, 16, 21,
- -20,-16,-10, -1, 8, 16, 22, 25,-15,-11, -3, 6, 14, 20, 25, 27,
- -4, -2, 0, 1, 2, 2, 2, 2, -5, -2, 0, 2, 3, 3, 3, 3,
- -6, -4, -1, 1, 2, 3, 3, 3, -7, -5, -2, 0, 1, 1, 2, 2,
- 2, 1, 1, 1, 1, 0, -2, -3, 3, 3, 2, 1, 0, -1, -3, -4,
- 4, 3, 2, 1, 0, -2, -4, -6, 5, 4, 3, 1, -1, -3, -5, -6,
- 5, 6, 6, 4, 2, 0, -2, -3, 3, 4, 4, 4, 3, 1, 0, -1,
- -2, -2, -1, -1, -1, -1, -2, -2, -5, -4, -3, -2, -2, -2, -3, -3,
- -1, -1, -1, -1, -1, -1, -1, -1, -3, -4, -4, -4, -3, -3, -3, -3,
- -1, -1, -1, -1, -1, -1, -1, -2, 5, 6, 6, 6, 6, 5, 4, 3,
- 4, 4, 4, 4, 4, 5, 6, 7, 0, -1, -1, -1, -1, 0, 1, 2,
- -2, -3, -3, -3, -3, -2, -1, 0, -3, -3, -4, -4, -4, -3, -2, -1,
- 0, -2, -4, -4, -2, 0, 2, 3, 0, -2, -3, -3, -1, 2, 4, 5,
- -1, -2, -4, -3, 0, 3, 5, 6, -2, -3, -4, -3, -1, 2, 4, 5,
- 9, 4, 0, -3, -3, -1, 0, 1, 8, 4, -1, -4, -3, -1, 1, 2,
- 6, 2, -3, -5, -4, -2, 0, 1, 5, 1, -3, -4, -4, -2, 0, 1,
- 5, 3, 1, -1, -4, -8,-10,-10, 3, 3, 2, 1, 0, -2, -3, -4,
- 1, 1, 1, 2, 3, 2, 1, 0, -1, 0, 1, 2, 3, 4, 3, 2,
- 0, 1, 2, 2, 1, -1, -3, -3, 0, 1, 1, 1, -1, -2, -4, -3,
- -3, -3, -3, -3, -3, -3, -1, 2, -4, -4, -3, 0, 3, 7, 12, 14,
- -5, -5, -6, -6, -6, -6, -6, -5, 2, 2, 2, 1, 0, 0, 0, 0,
- 4, 4, 3, 2, 1, 0, 0, 0, 6, 6, 5, 4, 2, 2, 1, 1,
- -7, -7, -6, -3, 0, 4, 7, 8, -1, -2, -3, -3, -2, -1, 1, 2,
- 3, 3, 1, -1, -2, -2, -2, -1, 6, 6, 4, 2, 0, -2, -2, -2,
- -6, -5, -2, 2, 5, 9, 11, 12, -4, -4, -2, 0, 2, 4, 5, 6,
- -3, -2, -2, -2, -2, -1, 0, 1, -2, -2, -2, -3, -3, -3, -3, -2,
- -7, -3, 1, 3, 3, 0, -3, -5, -6, -2, 3, 5, 4, 1, -3, -5,
- -5, -1, 4, 6, 5, 2, -3, -4, -4, 0, 5, 7, 6, 3, -1, -3,
- 0, 0, 0, 0, 0, 0, 0, 0, -2, -2, -3, -3, -3, -3, -2, -1,
- 6, 7, 8, 9, 9, 8, 7, 6, -4, -4, -5, -5, -6, -6, -5, -4,
- -9, -8, -6, -4, 0, 3, 6, 6, -5, -4, -1, 3, 5, 6, 5, 3,
- 1, 3, 6, 6, 4, 1, -2, -5, 6, 7, 5, 1, -3, -7,-10,-11,
- 10, 9, 5, 1, -3, -6, -6, -4, 5, 3, -1, -5, -6, -5, -2, 2,
- -2, -4, -6, -6, -4, 1, 6, 10, -6, -7, -7, -4, 1, 7, 11, 12,
- 6, 5, 3, 2, 0, 0, 0, 0, 2, 1, -1, -2, -3, -2, -1, -1,
- 0, -1, -2, -4, -4, -2, -1, 1, 0, 0, -1, -2, -1, 0, 2, 3,
- 0, -1, -2, -2, -2, -2, -1, -1, 5, 4, 2, 1, 0, 0, 0, 0,
- 6, 5, 3, 1, 0, 0, 0, 0, 2, 0, -2, -4, -4, -3, -2, -2,
- -7, -4, 0, 2, 2, 2, 2, 1, -7, -3, 0, 0, 0, 0, 0, 0,
- -4, -1, 1, 1, 0, 0, 0, 1, -1, 1, 2, 2, 2, 2, 3, 3,
- -2, 0, 2, 2, 1, 1, 1, 1, -1, 1, 2, 2, 1, 0, 0, -1,
- 0, 2, 4, 2, 0, -1, -2, -3, 1, 2, 3, 1, -2, -4, -6, -6,
- 1, 2, 2, 4, 5, 6, 4, 1, 0, -1, -1, -1, 0, 0, -2, -4,
- 0, 0, -1, -2, -2, -2, -4, -6, 2, 1, 0, 0, 1, 1, -1, -3,
- 1, 1, 1, 1, 1, 2, 3, 3, 0, 0, 1, 0, 1, 2, 4, 4,
- -1, -1, -1, -1, 0, 1, 2, 3, -4, -4, -5, -5, -5, -3, -1, 0,
- -6, -5, -5, -4, -3, -2, -1, -1, -1, 0, 0, 1, 1, 2, 3, 3,
- 0, 1, 1, 1, 2, 2, 3, 4, 0, 0, -1, -1, 0, 1, 2, 3,
- 0, 1, 1, 1, 0, 0, -1, -1, 1, 3, 3, 2, 1, -1, -2, -2,
- -2, 0, 2, 2, 2, 2, 1, 1, -9, -8, -4, -2, 1, 3, 3, 3,
- -1, -1, -1, -2, -3, -3, -3, -4, 0, 0, 0, -1, -2, -2, -3, -3,
- 2, 2, 2, 0, -1, -1, -1, -1, 5, 5, 4, 3, 2, 2, 2, 2,
- 6, 3, -1, -4, -3, -1, 1, 1, 2, -1, -3, -4, -1, 2, 2, 0,
- -1, -2, -2, 1, 4, 4, 1, -3, -2, -1, 1, 4, 6, 3, -3, -8,
- 3, 3, 2, 1, -1, -2, -2, -2, -4, -4, -2, -1, 1, 3, 4, 4,
- -4, -5, -5, -4, -2, 0, 2, 2, 7, 7, 4, 1, -1, -2, -3, -2,
- -1, 1, 3, 0, -4, -6, 0, 6, -2, 1, 4, 1, -4, -6, -1, 7,
- -3, 1, 4, 2, -3, -6, -1, 6, -2, 0, 3, 2, -2, -5, -1, 4,
- 1, -1, -2, 1, 4, 4, -1, -7, 1, -1, -4, -1, 5, 6, 0, -6,
- 3, 0, -4, -3, 3, 6, 2, -4, 3, 0, -5, -4, 1, 4, 1, -3,
- 2, 2, 3, 3, 3, 3, 2, 2, -4, -5, -6, -7, -7, -7, -7, -6,
- 1, 2, 3, 3, 3, 3, 2, 2, 0, 0, 1, 1, 1, 2, 2, 1,
- 3, -3, -3, 3, 4, -2, -2, 2, 3, -4, -4, 4, 4, -4, -4, 2,
- 4, -4, -4, 4, 4, -4, -3, 3, 3, -3, -4, 3, 3, -3, -3, 3,
- -2, -2, -2, -2, -2, -2, -1, -1, 6, 7, 8, 8, 8, 7, 6, 5,
- -5, -6, -7, -7, -8, -7, -6, -5, 1, 1, 2, 2, 2, 2, 1, 1,
- 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0,
- -2, -3, -2, -2, -2, -3, -3, -3, 2, 3, 5, 6, 4, 2, 1, 0,
- 8, 6, 2, 0, 0, 0, 0, 0, 4, 1, 0, 0, 0, -1, -1, -1,
- 1, -1, 0, 0, 0, -1, -2, -3, -2, -2, -1, 0, 0, -2, -4, -5,
- 3, 1, -1, -2, -3, -4, -5, -5, 2, 1, 0, 0, 1, 1, 0, 0,
- 0, -1, -1, 0, 2, 2, 2, 2, -1, -2, -1, 1, 2, 2, 2, 2,
- 0, -1, -2, -1, -1, -1, -1, 0, -1, -2, -2, -1, -1, 0, 0, 1,
- 2, 1, 1, 2, 2, 1, 1, 0, 6, 5, 3, 1, 0, -2, -4, -4,
- -3, -2, -1, 0, 1, 1, 0, -1, 0, 1, 3, 4, 5, 5, 3, 1,
- -1, -1, -1, 0, 1, 0, -1, -2, -2, -2, -2, -1, 0, -1, -2, -3,
- 0, -1, -2, -2, -1, -1, 0, 2, 1, -1, -2, -1, -1, -1, 0, 2,
- 1, 0, -2, -2, -2, -2, 1, 5, 1, -1, -2, -2, -2, 0, 5, 10,
- 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, 0, 0, 0, 1, 2,
- 1, 2, 2, 3, 4, 4, 6, 5, -3, -3, -3, -2, -2, -3, -3, -3,
- 1, -1, -2, -2, 0, 3, 5, 7, 2, 0, -2, -3, -2, 0, 2, 3,
- 3, 1, -2, -3, -3, -2, -1, -1, 3, 1, 0, -1, -1, -1, -1, -1,
- 1, 3, 5, 4, 2, -1, -3, -4, -3, -2, 1, 2, 1, 0, -1, -2,
- -5, -3, 0, 2, 2, 1, 0, 0, -3, -1, 1, 2, 2, 1, 0, 0,
- 0, -1, -1, -1, 1, 2, 3, 4, -3, -4, -4, -3, -1, 0, 0, 1,
- -2, -3, -2, -1, 1, 1, 1, 1, -2, -2, 0, 3, 4, 4, 3, 2,
- -4, -4, -3, -2, -1, 1, 2, 3, 0, 1, 1, 1, -1, -2, -3, -3,
- 3, 4, 5, 4, 2, -1, -3, -3, -2, -2, 0, 2, 2, 2, 1, 0,
- -4, 0, 5, 7, 4, -1, -4, -4, -1, 2, 4, 3, 0, -3, -3, -2,
- 2, 1, 0, -1, -2, -2, 0, 1, 0, 0, -1, -2, -2, -1, 1, 2,
- -4, -3, -2, -1, 0, 1, 2, 2, 10, 9, 5, 0, -3, -4, -3, -2,
- 1, -1, -2, -2, -1, 0, 0, 0, -2, -2, -1, 1, 1, 1, 0, -1,
- -5, -3, 0, 3, 4, 2, 0, -2, -2, -1, 0, 1, 1, 0, -1, -1,
- 3, 2, -1, -2, -2, -1, 1, 1, 7, 5, -1, -5, -6, -2, 2, 4,
- -2, 3, 3, -3, -4, 1, 2, -2, -3, 3, 4, -3, -4, 2, 3, -2,
- -3, 3, 4, -3, -4, 2, 3, -2, -4, 2, 4, -2, -3, 1, 2, -1,
- 4, 3, -1, -3, -3, -1, 1, 2, -4, -6, -4, 0, 4, 5, 4, 1,
- 0, 2, 5, 6, 2, -3, -5, -4, 1, 1, -1, -3, -5, -2, 2, 4,
- -1, 0, 1, 2, 2, 3, 3, 4, -1, 0, 1, 1, 0, -1, -1, -1,
- -1, 0, 1, 2, 2, 1, -1, -2, -3, -2, -1, 0, 0, -1, -2, -3,
- 1, 1, 1, 1, 0, 0, 1, 2, 1, 0, -1, 0, 0, 1, 1, 0,
- 1, -2, -4, -1, 1, 2, 1, 0, 1, -4, -7, -3, 1, 3, 2, 1,
- 1, 1, 1, 1, 1, 1, 0, -1, 1, 1, 1, 0, 1, 2, 2, 0,
- 1, 1, 0, 0, 0, 2, 0, -3, 3, 2, 0, -1, -1, -2, -6, -9,
- 0, 0, 0, 1, 0, 0, 1, 2, 1, 0, 0, 0, -1, -1, 0, 2,
- 0, 1, 1, 1, -1, -3, -2, 0, -7, -5, 1, 6, 6, 2, -1, -1,
- 3, 1, -1, -3, -4, -2, 1, 4, 2, 0, -2, -3, -4, -3, -1, 2,
- 2, 2, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1,
- -1, 1, 1, -2, -5, -6, -4, -1, -1, 1, 4, 3, 2, 0, 1, 2,
- -1, 0, 2, 3, 1, 0, 0, 1, -1, 0, 1, 0, 0, -1, -1, 0,
- 0, 1, 2, 2, 0, -2, -1, 1, -2, -1, -1, -2, -1, 2, 6, 8,
- -1, -1, -2, -3, -2, 0, 1, 2, -1, 0, 0, -1, -1, 0, -1, -1,
- 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, -1, -1, 1,
- -1, 0, 2, 2, -1, -3, -2, 3, 0, 2, 3, 0, -5, -7, -2, 4,
- -1, 0, 0, 0, -1, -2, -3, -3, -1, 0, -1, -2, -2, -2, -2, -2,
- 1, 1, 0, 0, 1, 2, 0, -1, 1, 2, 1, 2, 5, 6, 2, 0,
- -2, -4, -3, 0, 2, 2, 0, -3, 3, 1, 0, 1, 2, 1, -2, -3,
- 3, 1, 0, 0, 0, 0, 0, -1, 1, -1, -2, -2, -1, 1, 3, 3,
- 3, 2, 1, 2, 4, 3, 1, -2, -2, -4, -4, -3, -1, 0, -2, -3,
- 1, 0, -1, -1, 0, 1, 0, -1, 3, 2, 0, 0, 0, 1, 1, 0,
- 1, 1, 0, 0, 0, 0, 0, 0, 2, 3, 3, 2, 2, 2, 1, 1,
- 0, -1, -2, -3, -5, -5, -5, -4, 1, 1, 0, -1, 0, 1, 3, 3,
- -9, -6, -2, 0, 1, 1, 2, 2, -6, -2, 1, 2, 1, 1, 0, 1,
- -2, 1, 2, 2, 1, 1, 1, 1, 0, 2, 2, 1, 0, 1, 1, 1,
- 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, -3, -2, 0,
- -3, -3, -3, -2, -1, 3, 7, 9, 1, 2, 2, 2, 0, -2, -4, -3,
- 2, 0, -2, -1, 3, 4, -1, -6, 1, 0, -2, -3, -1, 3, 3, 0,
- 0, 3, 3, 0, -2, -1, 1, 1, -6, -1, 3, 2, -1, -2, 0, 1,
- 5, 3, 0, -2, -3, 0, 2, 1, 1, 1, 2, 2, 0, -2, -4, -7,
- -3, -2, 1, 2, 2, 1, -1, -4, 2, 2, 0, -2, -2, 0, 2, 2,
- 0, 0, -2, -3, -2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2,
- -2, -1, 0, 1, 0, 1, 2, 3, -4, -2, 0, 0, -1, 0, 2, 3,
- -2, -2, -2, -1, -1, 0, 2, 4, 0, 0, 0, 0, -1, -1, 0, 1,
- 0, -1, -1, -1, -1, -1, 0, 0, 6, 4, 2, 0, -1, -2, -1, -1,
- 0, 1, 1, 1, 1, -1, -5,-10, 1, 1, 1, 1, 1, 1, 0, -4,
- 1, 0, 1, 1, 1, 1, 1, -1, 2, 1, 1, 1, 0, 0, 0, 0,
- -3, 1, 4, 3, 3, 1, -1, 0, -4, 0, 1, 0, -1, 0, 0, 0,
- -5, 0, 2, 1, 1, 1, 0, -1, -1, 2, 1, -2, -2, -1, 0, -1,
- 2, 4, 5, 3, 0, -1, 1, 2, 0, 0, 1, 0, -2, -2, -1, -1,
- -2, -2, -2, -2, -3, -2, -1, 0, 0, 0, 1, 0, 0, 0, 1, 2,
- 0, -2, -2, -3, -1, 2, 2, -1, 1, 0, 0, 0, 1, 5, 3, -2,
- -1, -1, 0, -1, 0, 2, 0, -5, -1, 0, 1, 0, 0, 2, 2, -2,
- 3, 1, -1, -1, 0, 1, 1, 2, 1, 0, 0, 1, 1, 1, 1, 1,
- -10, -8, -2, 1, 2, 1, 1, 1, -1, 1, 2, 1, 0, 0, 0, 0,
- -1, -1, 0, 1, 2, 2, 2, 1, -1, -1, -1, 0, -1, -3, -5, -4,
- 1, 1, 2, 1, 1, 0, 0, 2, -1, -2, -1, -1, -1, 0, 2, 4,
- -3, -7, -5, 0, 2, 0, 0, 0, 3, -1, -2, 1, 2, 1, 1, 2,
- 1, -2, -1, 1, 2, 1, 0, 1, 0, -1, 0, 3, 2, -1, -1, -1,
- 2, 1, 1, 0, 0, 0, 0, 0, -9, -7, -2, 3, 3, 2, 1, 1,
- 3, 2, 0, -2, -2, -1, 1, 1, 0, -1, 0, 0, 1, 1, 0, 0,
- -2, -1, 1, 1, 1, 0, 0, 0, 1, 2, 1, -2, -4, -3, 1, 2,
- 1, 2, 1, -2, -3, 0, 3, 1, -1, -1, 0, 0, 1, 3, 0, -4,
- 2, 0, -1, 1, 2, -2, -2, 3, 2, 0, -1, 2, 3, -2, -4, 1,
- 0, 1, 1, 1, 2, -2, -6, -2, -1, 0, 0, 0, 2, 0, -2, -1,
- -1, -1, 1, 2, 1, -2, -3, -2, 3, -1, -2, -1, -1, 0, 1, 2,
- 10, 4, 0, 0, -1, -2, -2, -1, 3, -1, -2, -1, 0, -1, -1, 0,
- -5, 2, 7, 1, -4, -2, 1, 0, -2, 2, 3, -1, -3, 0, 2, 0,
- 2, 1, 0, 0, 1, 1, -1, -2, 1, -2, -2, -1, -1, -2, 0, 0,
- 0, 3, -2, -7, -1, 3, 0, 0, 1, 3, -3, -5, 2, 3, -1, 0,
- 0, 2, -2, -2, 4, 2, -2, 0, -1, 1, -1, 0, 2, -1, -2, 1,
- 4, 0, -3, -4, -2, 1, 2, 1, 0, 0, 3, 5, 3, 1, -1, -2,
- 1, 1, 1, -1, -3, -1, 1, 1, 1, -1, -2, -2, 0, 0, -1, -2
-};
-
-/* 6x16-entry codebook for intra-coded 8x8 vectors */
-static int8_t intra_codebook_8x8[6144] = {
- 4, 4, 3, 2, 2, 1, 0, -1, 4, 3, 3, 2, 1, 0, -1, -1,
- 3, 3, 2, 2, 1, 0, -1, -2, 3, 2, 2, 1, 0, -1, -2, -3,
- 2, 2, 1, 0, -1, -1, -2, -3, 2, 1, 0, 0, -1, -2, -3, -4,
- 1, 0, 0, -1, -2, -3, -4, -4, 0, 0, -1, -2, -2, -3, -4, -4,
- 2, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 3, 3,
- 1, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1,
- -1, 0, 0, 0, 0, 0, 1, 1, -2, -2, -1, -1, -1, -1, -1, -1,
- -3, -3, -3, -3, -3, -3, -2, -2, -5, -4, -4, -4, -4, -4, -4, -3,
- -4, -2, -1, 0, 1, 2, 2, 3, -4, -2, -1, 0, 1, 2, 3, 3,
- -4, -3, -1, 0, 1, 2, 3, 3, -4, -3, -1, 0, 1, 2, 3, 3,
- -5, -3, -1, 0, 1, 2, 3, 3, -5, -3, -1, 0, 1, 2, 3, 3,
- -5, -3, -1, 0, 1, 1, 2, 3, -5, -3, -2, -1, 0, 1, 2, 3,
- 4, 4, 5, 5, 6, 6, 7, 7, 2, 2, 2, 3, 3, 4, 4, 4,
- 0, 0, 0, 0, 1, 1, 1, 2, -2, -2, -2, -2, -1, -1, -1, 0,
- -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- -1, -2, -2, -2, -2, -2, -2, -2, -1, -1, -1, -1, -2, -2, -2, -2,
- 5, 3, 1, -1, -2, -3, -3, -3, 5, 3, 1, -1, -2, -3, -3, -3,
- 5, 3, 1, -1, -2, -3, -3, -3, 5, 3, 1, -1, -2, -3, -3, -3,
- 5, 4, 1, 0, -2, -3, -3, -3, 6, 4, 2, 0, -2, -2, -3, -3,
- 6, 4, 2, 0, -1, -2, -2, -3, 6, 4, 2, 1, -1, -2, -2, -2,
- -1, 1, 3, 3, 2, 0, -3, -6, -1, 1, 3, 4, 3, 0, -3, -6,
- -1, 1, 4, 4, 3, 1, -3, -6, -1, 1, 3, 4, 3, 1, -3, -6,
- -2, 1, 3, 4, 3, 1, -3, -6, -2, 1, 3, 4, 3, 1, -3, -7,
- -2, 1, 3, 3, 2, 0, -3, -7, -2, 0, 2, 3, 2, 0, -3, -6,
- 10, 9, 8, 6, 6, 5, 4, 4, 6, 5, 4, 3, 2, 2, 2, 1,
- 2, 1, 0, -1, -2, -2, -2, -1, -1, -2, -3, -4, -4, -4, -4, -3,
- -2, -3, -4, -4, -5, -4, -4, -3, -2, -2, -3, -3, -3, -3, -2, -2,
- -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 1, 1, 1, 1, 1, 2,
- -2, -1, 1, 2, 4, 5, 7, 8, -3, -2, 0, 1, 3, 5, 7, 8,
- -4, -3, -1, 0, 2, 4, 6, 7, -5, -4, -2, -1, 1, 3, 5, 7,
- -6, -5, -3, -2, 0, 2, 4, 6, -6, -5, -4, -2, -1, 1, 3, 5,
- -7, -6, -5, -3, -2, 0, 2, 3, -8, -7, -5, -4, -3, -1, 1, 2,
- 11, 9, 7, 5, 3, 1, -1, -1, 10, 8, 6, 3, 1, 0, -2, -2,
- 9, 7, 5, 2, 0, -2, -3, -4, 8, 6, 3, 1, -1, -3, -4, -4,
- 6, 4, 2, -1, -3, -4, -5, -5, 5, 3, 0, -2, -4, -5, -6, -6,
- 3, 1, -1, -3, -5, -6, -7, -7, 2, 0, -2, -4, -6, -6, -7, -7,
- 5, 6, 7, 7, 7, 8, 8, 8, 3, 4, 5, 5, 6, 6, 6, 6,
- 0, 2, 2, 3, 4, 4, 4, 5, -2, -1, 0, 1, 2, 2, 3, 3,
- -4, -3, -2, -1, 0, 1, 1, 2, -6, -5, -4, -3, -2, -2, -1, 0,
- -8, -7, -6, -6, -5, -4, -3, -3,-10, -9, -8, -8, -7, -6, -6, -5,
- 6, 5, 3, 1, -1, -3, -6, -8, 6, 5, 4, 2, -1, -3, -6, -8,
- 6, 5, 4, 2, 0, -3, -6, -8, 6, 5, 4, 2, 0, -3, -6, -8,
- 6, 6, 4, 2, 0, -3, -6, -8, 6, 5, 4, 2, 0, -3, -6, -8,
- 6, 5, 4, 2, 0, -3, -6, -8, 6, 5, 4, 2, -1, -3, -5, -8,
- 11, 10, 9, 8, 7, 6, 5, 4, 8, 8, 7, 6, 5, 4, 3, 2,
- 6, 5, 4, 4, 2, 2, 1, 0, 3, 3, 2, 1, 0, 0, -1, -2,
- 1, 1, 0, -1, -2, -2, -3, -3, -1, -1, -2, -3, -4, -4, -5, -5,
- -3, -4, -4, -5, -6, -6, -7, -7, -5, -5, -6, -7, -8, -8, -8, -8,
- -14,-13,-12,-11, -9, -7, -6, -4,-12,-11,-10, -9, -7, -5, -3, -1,
- -10, -9, -7, -6, -3, -2, 0, 2, -8, -6, -4, -2, 0, 2, 4, 5,
- -5, -3, 0, 2, 4, 5, 7, 8, -2, 0, 2, 4, 6, 8, 9, 10,
- 0, 3, 5, 7, 8, 10, 11, 12, 3, 5, 7, 8, 10, 11, 12, 12,
- -19,-19,-18,-18,-17,-16,-15,-14,-15,-15,-14,-13,-12,-11,-10, -9,
- -11,-10, -9, -8, -6, -5, -4, -3, -6, -5, -3, -2, -1, 0, 1, 2,
- -1, 0, 2, 3, 4, 5, 6, 6, 4, 6, 7, 8, 9, 10, 10, 10,
- 9, 10, 11, 12, 13, 14, 14, 14, 12, 14, 14, 15, 16, 16, 16, 16,
- 22, 21, 19, 17, 14, 11, 9, 5, 20, 19, 17, 14, 11, 8, 4, 1,
- 17, 15, 13, 10, 6, 3, 0, -4, 13, 11, 8, 5, 1, -2, -5, -9,
- 9, 6, 3, -1, -4, -7,-11,-13, 4, 0, -3, -6, -9,-12,-15,-17,
- -2, -5, -8,-11,-14,-16,-18,-20, -8,-10,-13,-16,-17,-19,-21,-22,
- 17, 18, 18, 18, 17, 16, 16, 14, 16, 16, 15, 15, 14, 13, 12, 11,
- 12, 12, 11, 10, 9, 8, 7, 5, 7, 6, 6, 4, 3, 2, 1, -1,
- 1, 0, -1, -2, -3, -4, -5, -6, -5, -6, -7, -8, -9,-10,-11,-12,
- -11,-12,-13,-14,-15,-16,-16,-17,-16,-17,-17,-18,-19,-20,-20,-20,
- 0, 0, 0, 0, -1, -1, -2, -3, 1, 0, 0, 0, 0, -1, -2, -3,
- 1, 1, 0, 0, -1, -1, -2, -2, 1, 1, 1, 0, 0, -1, -1, -2,
- 2, 1, 1, 1, 0, -1, -1, -2, 2, 2, 1, 1, 0, 0, -1, -2,
- 2, 2, 1, 1, 1, 0, -1, -1, 2, 2, 1, 1, 1, 0, 0, -2,
- 0, -1, -1, 0, 0, 1, 2, 3, 0, -1, -1, 0, 1, 1, 2, 2,
- -1, -1, -1, -1, 0, 1, 2, 2, -1, -1, -2, -1, 0, 1, 1, 2,
- -1, -2, -2, -1, 0, 0, 1, 2, -1, -2, -2, -2, -1, 0, 1, 2,
- -1, -1, -2, -1, 0, 0, 1, 2, -1, -1, -1, -1, 0, 1, 1, 2,
- 3, 2, 2, 2, 1, 1, 0, 0, 3, 2, 2, 2, 2, 1, 0, 0,
- 2, 2, 2, 1, 1, 1, 0, 0, 2, 2, 1, 1, 1, 0, 0, -1,
- 1, 1, 1, 0, 0, 0, -1, -1, 0, 0, -1, -1, -1, -1, -1, -1,
- -2, -2, -2, -2, -2, -2, -2, -2, -2, -3, -3, -3, -2, -2, -2, -2,
- 5, 2, 0, 0, -1, 0, 0, 0, 4, 2, 0, -1, -1, -1, 0, -1,
- 4, 1, -1, -1, -2, -1, -1, -1, 4, 1, -1, -1, -2, -1, -1, -1,
- 4, 1, -1, -2, -2, -1, -1, -1, 4, 1, -1, -2, -2, -1, -1, -1,
- 4, 1, -1, -1, -1, -1, -1, -1, 4, 2, 0, -1, 0, 0, 0, -1,
- -2, -1, 0, 1, 1, 1, 1, 1, -3, -1, 0, 1, 1, 1, 1, 1,
- -3, -1, 0, 1, 1, 1, 1, 1, -3, -1, 0, 1, 1, 1, 1, 1,
- -3, -2, 0, 1, 2, 2, 1, 1, -4, -2, 0, 1, 2, 2, 2, 2,
- -5, -3, -1, 1, 1, 2, 1, 2, -5, -3, -2, 0, 1, 1, 1, 1,
- 3, 3, 1, 0, -2, -4, -4, -5, 3, 3, 2, 0, -1, -2, -3, -4,
- 2, 2, 1, 1, 0, -1, -2, -2, 1, 1, 1, 1, 1, 0, 0, 0,
- 0, 0, 0, 1, 1, 1, 1, 1, -2, -1, -1, 0, 0, 1, 2, 2,
- -3, -2, -2, -1, 0, 1, 2, 3, -3, -3, -2, -1, 0, 1, 2, 3,
- -3, -3, -3, -3, -3, -2, -2, -2, -3, -3, -2, -2, -2, -1, -1, -1,
- -2, -2, -2, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 2, 2, 2, 2,
- 1, 1, 1, 2, 2, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, 3,
- -8, -7, -5, -3, -2, -1, 0, -1, -4, -3, -1, 0, 1, 2, 1, 1,
- -1, 1, 2, 3, 3, 2, 2, 1, 1, 2, 3, 3, 2, 2, 1, 0,
- 2, 3, 3, 2, 1, 0, 0, -1, 1, 2, 1, 0, -1, -1, -1, -1,
- 1, 1, 0, -1, -1, -2, -2, -1, 1, 1, 0, 0, -1, -1, 0, -1,
- -4, -3, -2, 0, 1, 2, 3, 3, -4, -3, -2, 0, 1, 2, 2, 2,
- -3, -3, -2, -1, 0, 1, 1, 1, -2, -2, -2, -1, -1, 0, 0, 0,
- 0, -1, -1, -1, -1, -1, -1, -1, 2, 1, 1, 0, 0, -1, -1, -2,
- 3, 3, 3, 1, 0, -1, -2, -2, 5, 4, 4, 2, 1, 0, -1, -2,
- 0, 0, 0, 0, 1, 2, 3, 3, 0, -1, 0, 0, 1, 2, 3, 3,
- 0, -1, 0, 0, 1, 2, 3, 2, 0, 0, 0, 1, 1, 2, 2, 2,
- 2, 1, 1, 1, 1, 1, 1, 0, 2, 2, 2, 1, 0, 0, -1, -2,
- 2, 1, 0, 0, -2, -3, -5, -6, 0, -1, -1, -3, -5, -6, -8, -9,
- -2, 0, 1, 2, 2, 1, -1, -4, -2, 0, 2, 2, 2, 1, -1, -4,
- -2, 0, 2, 2, 2, 1, -1, -3, -2, 0, 2, 2, 2, 1, -1, -3,
- -2, -1, 2, 2, 2, 1, -1, -3, -2, -1, 1, 2, 2, 1, -1, -3,
- -3, -1, 1, 2, 2, 1, -1, -3, -2, -1, 1, 2, 2, 1, -1, -3,
- -1, 1, 1, -1, -3, -3, 0, 4, -1, 1, 1, -1, -3, -3, 0, 4,
- -1, 1, 1, 0, -3, -3, 0, 4, -1, 1, 2, 0, -3, -3, 0, 5,
- 0, 1, 2, 0, -3, -4, 0, 4, 0, 1, 2, 0, -3, -4, 0, 5,
- 0, 1, 2, 0, -3, -3, 0, 4, 0, 1, 2, -1, -2, -2, 0, 4,
- 6, 6, 5, 6, 5, 5, 5, 5, 2, 2, 2, 2, 2, 2, 2, 2,
- 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -2, -2, -2, -2,
- -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 0, 0, 0, 0, 0,
- -1, -2, -2, -2, -2, -2, -2, -1, -3, -3, -3, -3, -3, -3, -3, -2,
- -3, -4, -4, -3, -3, -3, -2, -2, -2, -2, -2, -2, -1, -1, 0, 0,
- 0, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6,
- 4, 1, -2, -3, -3, -1, 1, 3, 4, 1, -2, -4, -3, -1, 1, 3,
- 5, 1, -2, -4, -3, -1, 1, 4, 5, 1, -2, -3, -3, -1, 2, 4,
- 5, 1, -2, -3, -3, -1, 2, 4, 4, 0, -3, -4, -3, -1, 2, 4,
- 4, 0, -3, -3, -3, -1, 1, 3, 3, 0, -2, -3, -2, -1, 1, 3,
- -3, -4, -4, -4, -4, -4, -4, -4, -1, -1, -1, -1, -1, -1, -2, -2,
- 2, 1, 1, 2, 2, 1, 1, 1, 3, 3, 3, 4, 4, 3, 3, 3,
- 3, 3, 3, 4, 4, 4, 3, 3, 1, 2, 1, 2, 2, 2, 2, 2,
- -2, -2, -2, -1, -1, -1, 0, 0, -4, -4, -4, -4, -3, -3, -3, -3,
- -1, -2, -3, -3, -2, -2, -1, 0, 0, -1, -2, -2, -2, -1, 0, 1,
- 2, 1, -1, -1, -1, -1, 0, 1, 3, 1, 0, -1, -1, 0, 0, 1,
- 3, 2, 0, -1, 0, 0, 0, 1, 3, 1, 0, -1, 0, 0, 0, 1,
- 3, 1, 0, -1, 0, 0, 0, 1, 2, 1, 0, 0, 0, 0, 0, 1,
- 0, 0, 0, 1, 1, 2, 3, 4, 0, 0, -1, 0, 0, 0, 2, 3,
- 0, -1, -1, -1, -1, -1, 0, 1, 0, -1, -1, -1, -1, -1, -1, 0,
- 0, 0, -1, -1, -1, -2, -2, -1, 1, 0, 0, -1, -1, -2, -2, -1,
- 2, 2, 1, 0, -1, -1, -1, -1, 3, 3, 2, 1, 0, -1, -1, 0,
- 1, 0, 1, 0, 0, -1, -2, -1, 0, 0, 0, 0, -1, -1, -2, -1,
- 0, -1, 0, 0, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0,
- -1, -1, -1, 0, 0, 0, 1, 1, -1, -1, -1, 0, 1, 1, 2, 3,
- -2, -2, -1, 0, 1, 2, 3, 4, -2, -2, -1, 0, 1, 2, 4, 5,
- -3, -1, 1, 0, 0, -1, 0, 1, -3, 0, 1, 0, -1, -1, 0, 2,
- -3, 0, 1, 0, -1, -1, 0, 2, -2, 1, 2, 0, -1, -1, 0, 2,
- -2, 1, 2, 0, -1, -1, 0, 2, -2, 1, 2, 0, -1, -1, 0, 2,
- -1, 2, 2, 0, -1, -1, 0, 2, -1, 1, 1, 0, -1, -1, -1, 1,
- -2, -2, -1, 1, 3, 4, 3, 1, -2, -2, -1, 0, 2, 3, 2, 0,
- -2, -2, -1, 0, 1, 2, 1, -1, -1, -1, -1, 0, 1, 2, 1, -1,
- -1, -1, -1, 0, 1, 1, 0, -2, 0, -1, -1, 0, 1, 1, 0, -1,
- 0, -1, -1, 0, 1, 1, 1, -1, 0, -1, -1, 0, 0, 1, 0, -1,
- -2, -1, 0, 1, 1, 1, 1, 1, -2, -1, 0, 0, 0, 0, 0, 0,
- -2, -1, -1, 0, -1, -1, -2, -2, -2, -1, -1, -1, -1, -2, -2, -3,
- -1, 0, 1, 1, 0, -1, -2, -2, 1, 2, 3, 3, 2, 1, 0, 0,
- 1, 2, 3, 3, 3, 2, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0,
- 0, -1, -1, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, -1, 0, 0, 1, 1, 0, 0, 0,
- -3, -2, -1, -1, -1, -1, 0, -1, -5, -5, -4, -3, -2, -2, -2, -1,
- 1, 1, 1, 1, 2, 1, 0, -1, 1, 1, 1, 2, 1, 1, 0, -1,
- 1, 1, 1, 1, 1, 1, 0, -2, 2, 1, 1, 1, 1, 1, 0, -2,
- 1, 1, 0, 0, 0, 0, -1, -3, 1, 1, 0, 0, 0, -1, -2, -3,
- 1, 1, 0, 0, -1, -1, -2, -4, 1, 0, 0, -1, -2, -2, -3, -4,
- 8, 7, 5, 3, 2, 1, 1, 1, 2, 1, 0, 0, -1, -1, -2, -1,
- -1, -1, -1, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, -1, -1, 0,
- 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0,
- -1, 0, 0, 0, 0, 0, -1, -1, -2, -2, -1, -1, -1, -2, -2, -1,
- 9, 4, 0, -2, -2, -2, -1, -1, 7, 2, -1, -2, -2, -1, 0, 0,
- 4, 0, -2, -2, -1, 0, 1, 1, 1, -2, -2, -2, -1, 0, 1, 1,
- -1, -2, -2, -1, 0, 1, 1, 1, -1, -2, -1, 0, 1, 1, 1, 0,
- -1, -1, 0, 1, 1, 1, 0, -1, 0, -1, 0, 1, 0, 0, -1, -1,
- 0, 1, 1, 1, 1, 1, 0, 0, 1, 2, 2, 2, 1, 0, 0, 0,
- 2, 2, 2, 2, 1, 0, -1, -1, 1, 1, 1, 0, -1, -2, -2, -2,
- 0, 0, 0, -1, -2, -3, -2, -2, -1, -1, -1, -2, -2, -2, -1, 0,
- -1, -1, -1, -1, 0, 0, 1, 2, -1, -1, -1, 0, 1, 2, 3, 4,
- -1, -1, 0, 0, -1, -2, -3, -3, -1, -1, 0, 0, 0, -1, -1, -1,
- -2, -2, -1, 0, 1, 1, 1, 1, -2, -2, -2, 0, 1, 2, 3, 3,
- -1, -1, -1, 0, 1, 3, 3, 3, 1, 0, 0, 0, 1, 1, 2, 2,
- 2, 2, 1, 0, 0, -1, -1, -1, 3, 2, 1, 0, -1, -2, -3, -3,
- -1, -1, -1, -2, -2, -3, -4, -5, 0, 0, 0, -1, -1, -3, -3, -4,
- 1, 1, 1, 0, 0, -1, -2, -3, 2, 2, 2, 1, 1, 0, -1, -1,
- 2, 2, 2, 2, 1, 1, 0, -1, 2, 2, 2, 2, 2, 1, 0, 0,
- 1, 1, 2, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, -1,
- -2, 2, 3, 1, -1, 1, 1, -1, -3, 2, 3, 0, -1, 1, 1, -1,
- -3, 2, 3, 0, -1, 1, 1, -1, -4, 2, 3, 0, -1, 1, 1, -2,
- -4, 1, 3, 0, -1, 1, 1, -2, -4, 1, 3, -1, -2, 1, 1, -2,
- -3, 1, 2, 0, -1, 1, 1, -2, -3, 1, 2, 0, -1, 1, 1, -1,
- -1, -1, -1, -2, -2, -2, -2, -2, 1, 1, 1, 1, 0, 0, 0, 0,
- 1, 2, 2, 2, 2, 2, 2, 2, 0, 0, 1, 1, 1, 2, 2, 2,
- -2, -2, -1, -1, -1, 0, 0, 0, -3, -3, -3, -3, -3, -3, -3, -2,
- -1, -1, -1, -1, -2, -2, -2, -2, 4, 4, 4, 4, 4, 3, 3, 2,
- -3, -3, -2, -1, 0, 1, 2, 5, -3, -3, -3, -2, -1, 1, 3, 6,
- -3, -3, -2, -2, 0, 2, 3, 5, -3, -2, -2, -2, 0, 1, 3, 5,
- -2, -2, -2, -1, -1, 1, 3, 5, -2, -2, -1, -1, 0, 1, 2, 4,
- -1, -1, -1, -1, 0, 1, 1, 4, -1, -1, -1, -1, 0, 1, 2, 3,
- 0, -1, 0, 1, 1, 0, -1, -1, 0, 0, 0, 1, 2, 0, -1, -1,
- 1, 0, -1, 0, 1, 0, 0, 0, 1, -1, -2, -1, 0, 0, 0, 0,
- 1, -2, -3, -1, 0, 0, 0, 1, 1, -1, -3, -2, 0, 1, 1, 2,
- 1, -1, -2, -1, 0, 1, 1, 2, 2, 0, -1, 0, 1, 1, 2, 2,
- 1, 1, 1, 1, 0, 0, 1, 2, -1, 0, 0, -1, 0, 0, 0, 1,
- -3, -2, -1, -1, -1, 0, 1, 1, -4, -2, -1, 0, 0, 1, 1, 1,
- -3, -2, 0, 0, 1, 1, 1, 1, -3, -1, 0, 1, 1, 1, 0, 0,
- -1, 0, 1, 1, 1, 0, 0, -1, 0, 1, 2, 2, 1, 0, 0, -1,
- -4, -4, -4, -3, -2, -1, -1, -1, -2, -2, -2, -1, 0, 0, 0, 0,
- -1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1,
- 0, 0, 1, 1, 2, 2, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0,
- 0, 0, 0, 1, 1, 1, 1, 0, -1, 0, 0, 1, 1, 1, 0, 0,
- 1, 2, 2, 2, 1, -1, -2, -4, 1, 1, 2, 2, 1, 0, -2, -4,
- 0, 1, 1, 1, 1, 0, -1, -3, -1, 0, 1, 1, 0, 0, -1, -2,
- -1, 0, 1, 1, 1, 0, 0, -1, -2, -1, 0, 0, 0, 0, 0, -1,
- -1, -1, 0, 1, 1, 0, 0, 0, -1, 0, 1, 1, 1, 1, 1, 0,
- 2, 2, 0, -1, -2, -1, -1, -2, 1, 1, -1, -2, -2, -1, -1, -2,
- 1, 1, -1, -2, -2, 0, 0, -1, 1, 1, 0, -2, -1, 1, 1, 0,
- 1, 1, 0, -1, -1, 1, 2, 1, 1, 1, 0, -1, -1, 1, 2, 1,
- 1, 1, 0, -1, -1, 1, 1, 1, 1, 1, 0, -1, 0, 1, 1, 1,
- 0, 0, -1, -2, -4, -4, -4, -4, 3, 3, 3, 2, 1, 0, 0, 0,
- 3, 3, 3, 3, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 1,
- -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, 0, 0, -1, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0,
- -1, -1, 0, -1, -1, 1, 2, -1, 1, 1, 0, 0, 0, 2, 3, -1,
- 1, 1, 0, -1, -1, 1, 3, -1, 1, 1, 0, -2, -2, 0, 1, -2,
- 1, 0, 0, -2, -2, 0, 1, -3, 0, 0, 0, 0, -1, 1, 1, -3,
- 0, 1, 1, 0, 1, 2, 1, -3, -1, 0, 1, 1, 1, 2, 1, -4,
- -4, -3, 0, 1, 1, 1, 0, 0, -4, -2, 0, 1, 1, 1, 0, -1,
- -3, -1, 1, 1, 1, 0, -1, -1, -1, 1, 1, 1, 1, 0, -1, 0,
- 1, 2, 2, 1, 0, -1, 0, 0, 2, 2, 1, 0, -1, -1, 0, 1,
- 2, 1, 0, -1, -2, -1, 0, 1, 2, 2, 0, -1, -2, -1, 1, 1,
- 1, 1, 0, 0, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, -1, -1, -1, -1, -1,
- 1, 0, 0, -1, -1, -1, -1, -1, 2, 1, 0, 0, -1, -1, -1, -1,
- 5, 3, 2, 1, 0, 0, 0, 0, 6, 5, 3, 2, 1, 0, 0, 0,
- 4, 4, 3, 1, 0, 0, 0, 1, 3, 3, 2, 1, 0, 0, 0, 1,
- 2, 2, 1, 0, -1, -1, 0, 1, 0, 0, 0, -1, -1, -1, 0, 1,
- 0, 0, -1, -1, -2, -1, 0, 2, 0, -1, -1, -2, -2, -2, 0, 1,
- 0, -1, -1, -2, -2, -2, -1, 0, 0, 0, -1, -2, -2, -2, -1, 0,
- 0, 0, -1, -1, -1, 0, 2, 3, 0, -1, -2, -2, -1, -1, 1, 2,
- 1, 0, -1, -1, -1, 0, 0, 0, 1, 1, 1, 0, 0, 0, -1, -1,
- 1, 2, 1, 0, 0, -1, -1, -1, -1, 0, 0, 0, -1, -1, -1, -1,
- -3, -2, -1, -1, 0, 1, 1, 2, -4, -3, -1, 1, 2, 3, 5, 5,
- 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
- 0, 0, 0, -1, 0, 0, 0, 1, -1, -1, -2, -2, -2, -1, -1, 0,
- 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3,
- 1, 1, 1, 1, 2, 2, 1, 1, -4, -3, -4, -4, -4, -4, -3, -3,
- -1, 0, 1, 2, 2, 3, 3, 3, -1, -1, -1, -1, 0, 0, 0, 0,
- 0, 0, -1, -2, -2, -3, -3, -2, 3, 2, 1, 0, -1, -2, -2, -2,
- 4, 3, 2, 1, 1, 0, 0, 0, 2, 2, 1, 1, 0, 1, 1, 1,
- 0, -1, -1, -1, -1, 0, 0, 1, -2, -2, -2, -2, -2, -1, 0, 0,
- 1, -1, 0, 2, 1, -2, -1, 1, 1, -1, 0, 2, 1, -2, -2, 1,
- 1, -1, 0, 3, 2, -2, -1, 1, 0, -2, 0, 3, 2, -2, -2, 1,
- 0, -2, 0, 3, 2, -2, -2, 1, 0, -2, 0, 3, 1, -2, -1, 1,
- 0, -2, 0, 2, 1, -2, -2, 1, 0, -1, 0, 2, 1, -2, -1, 1,
- 0, 1, 2, 2, 3, 3, 2, 2, 0, 1, 1, 2, 3, 3, 2, 1,
- 0, 0, 1, 2, 2, 2, 2, 1, -1, 0, 0, 1, 1, 1, 1, 1,
- -1, -1, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1,
- -2, -2, -2, -2, -2, -2, -2, -1, -2, -2, -2, -2, -2, -2, -2, -1,
- 0, 0, -1, -2, -1, 0, 3, 5, 0, 0, -1, -1, -1, 0, 2, 4,
- 1, 1, 0, 0, -1, -1, 1, 2, 1, 2, 1, 1, 0, -1, -1, 0,
- 0, 1, 2, 1, 0, -1, -2, -2, -1, 0, 1, 2, 1, 0, -3, -3,
- -2, -1, 1, 2, 2, 0, -2, -4, -2, -1, 0, 2, 2, 1, -1, -3,
- 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, -1, 0, 0, 0, 0, 0,
- -1, -1, -1, -1, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, 0,
- -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, 0, 0, 0, -1, -1, 0,
- 0, 0, 1, 1, 0, 0, 0, 1, 3, 3, 3, 4, 3, 3, 3, 3,
- 5, 1, -2, -2, 0, 0, 0, -1, 4, -1, -3, -1, 0, 0, 0, -1,
- 3, -1, -1, 0, 1, 1, 0, -1, 2, 0, 0, 1, 1, 1, 0, -2,
- 1, 0, 0, 1, 1, 1, 0, -2, 0, -1, -1, -1, 0, 0, 0, -1,
- 0, -1, -1, -1, -1, 0, 0, -1, 2, 1, 0, 0, 0, 1, 0, 0,
- 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0,
- 1, -1, -1, 0, 0, 0, 0, 0, 2, 0, -1, -1, -1, -1, -1, 0,
- 3, 1, -1, -1, -2, -2, -2, -1, 4, 2, 1, 0, -1, -2, -2, -1,
- 2, 1, 0, 0, -1, -1, 0, 0, 0, -1, -1, -1, -1, 0, 1, 1,
- 0, 1, 2, 2, 2, 1, -1, -3, 0, 0, 1, 1, 1, 0, -1, -2,
- 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, -1, 0, 0, 1, 1, 0,
- 0, 0, -1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0,
- 0, 0, 1, 1, 2, 1, -1, -3, 0, 0, 0, 1, 1, -1, -4, -5,
- -2, -2, -2, -1, 0, 2, 2, 2, 0, 0, 0, 0, 1, 1, 1, 0,
- 1, 1, 1, 1, 1, 0, -2, -3, 0, 0, 1, 1, 0, -1, -3, -4,
- -1, -1, 0, 1, 0, 0, -2, -3, -1, -1, 0, 1, 1, 1, 0, -1,
- 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0,
- 0, 1, 0, 0, 1, 1, 1, 2, 1, 2, 0, 0, 0, 0, -1, 1,
- 0, 2, 0, -1, 1, 0, -1, 0, 0, 1, 0, 0, 2, 1, 0, 1,
- 0, 1, -1, 0, 2, 2, 0, 1, -1, 0, -1, -1, 2, 1, 1, 2,
- -2, -2, -3, -2, 0, 1, 1, 1, -2, -2, -3, -3, -1, -1, -1, 0,
- -3, -1, 0, 1, 2, 1, 1, 0, -3, -1, 0, 1, 2, 1, 1, 1,
- -2, 0, 0, 1, 1, 1, 1, 1, -1, 0, 0, 0, 0, 0, 0, 0,
- -2, 0, 0, 0, 0, -1, -1, 0, -2, 0, 0, 0, 0, 0, -1, -1,
- -3, 0, 1, 1, 1, 1, 0, 1, -5, -2, 0, 1, 2, 2, 1, 2,
- -2, -1, -1, 0, 0, 1, 2, 3, 0, 0, 1, 1, 0, 0, 1, 2,
- 0, 0, 1, 0, -1, -1, 0, 1, -1, -1, -1, -1, -2, -2, -1, 0,
- -2, -2, -2, -2, -2, -1, 0, 1, 0, 0, 0, -1, 0, 1, 2, 2,
- 2, 1, 0, 0, 0, 1, 2, 2, 2, 1, 0, -1, -1, -1, 0, 0,
- 0, 1, 1, 1, 1, 1, -1, -4, -1, -1, 0, 1, 1, 1, 0, -3,
- -2, -1, 0, 0, 1, 2, 2, -2, -1, 0, 0, 0, 0, 2, 3, -1,
- -1, 0, 0, 0, 0, 1, 2, 0, 0, 0, -1, -2, -1, 1, 1, 0,
- 0, 0, -1, -2, -2, 0, 2, 1, 0, 0, -1, -2, -1, 1, 2, 2,
- 1, 0, 0, 0, -2, -3, -2, -3, 0, 0, 1, 0, -2, -2, -1, -1,
- 0, -1, 1, 1, -1, -1, 0, 0, 0, -1, 1, 1, -1, -1, 0, 0,
- 0, 1, 2, 1, -1, -1, 0, 1, 1, 2, 3, 2, 0, 0, 1, 2,
- -1, 0, 2, 1, 0, 0, 2, 3, -2, -1, 0, 0, -1, 0, 1, 2,
- 1, 1, 0, -1, -2, -2, -1, 1, 1, 1, 1, -1, -2, -2, 0, 2,
- 1, 1, 1, -1, -1, -1, 0, 2, 0, 0, 0, 0, 0, 0, 1, 2,
- -1, -1, -1, 0, 0, 0, 1, 2, -1, -2, -1, 1, 1, 1, 0, 0,
- -1, -2, -1, 1, 2, 2, 0, -1, -1, -2, -1, 2, 2, 2, 0, -1,
- -1, -1, -1, -2, -1, -1, 0, 1, 0, 0, -1, -1, -1, 0, 1, 2,
- 1, 0, 0, 0, 0, 1, 1, 2, 1, 1, 0, 0, 1, 1, 1, 1,
- 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, -1, -1, -1,
- 1, 2, 1, 0, -1, -2, -2, -3, 2, 2, 1, 0, -2, -3, -4, -4,
- -4, -2, 1, 1, 1, 1, 0, 0, -2, 0, 1, 0, 0, 0, 0, 0,
- 0, 1, 1, -2, -2, -1, 0, 1, 2, 2, 1, -2, -2, -1, 1, 2,
- 1, 2, 1, -2, -2, -1, 1, 2, -1, 1, 1, -1, -1, -1, 0, 1,
- -2, 0, 1, 1, 0, -1, -1, 0, -2, 0, 2, 2, 1, -1, -1, 0,
- 1, 1, 0, 0, 0, 1, 0, 0, -2, -3, -3, -2, -2, -1, 0, 0,
- -3, -4, -3, -2, -1, 0, 0, 0, -1, -1, 0, 1, 2, 3, 2, 1,
- 0, 1, 2, 3, 3, 3, 2, 1, 1, 1, 1, 2, 1, 0, 0, -1,
- 0, 0, 0, 0, -1, -1, -1, -1, 0, -1, -1, 0, 0, 0, 0, 0,
- 1, 1, 0, 0, -1, -1, 0, 2, 0, 0, 1, 0, -1, -1, 1, 1,
- -2, -1, 0, 1, 1, 1, 1, 1, -3, -3, 0, 2, 2, 1, 1, 0,
- -2, -2, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, -1, -1,
- 3, 1, -1, -3, -2, -1, 0, 1, 4, 2, -1, -3, -3, -1, 1, 2,
- 0, 0, 0, -1, -1, -1, -1, -1, 1, 2, 1, 0, 0, 0, -1, -1,
- 2, 3, 3, 2, 1, 0, -1, -1, 3, 4, 4, 2, 1, 0, -1, -2,
- 3, 3, 2, 1, 0, -1, -2, -2, 1, 1, 0, -1, -1, -2, -2, -3,
- 0, 0, 0, -1, -1, -2, -2, -2, -1, -1, -1, -1, -1, -2, -2, -1,
- 1, 2, 2, 2, 2, 1, 2, 2, 0, 1, 1, 1, 1, 0, 0, 0,
- 0, 0, 0, 1, 1, 0, -1, -2, 0, 0, 0, 0, 1, 0, -1, -4,
- 1, 0, 0, 0, 0, 0, -2, -5, 1, 0, 0, 0, 0, 0, -1, -4,
- 1, 0, -1, 0, 0, 0, -1, -3, 0, -1, -1, 0, 1, 1, 1, -1,
- -2, -1, 0, 0, -1, -1, -1, -2, -1, 0, 0, 0, -1, -1, -2, -2,
- 0, 1, 1, 0, -1, -1, -1, -2, 0, 1, 1, 0, 0, 0, -1, -1,
- 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 2, 2, 1,
- 1, 1, 0, 0, 1, 2, 2, 1, 1, 1, 0, -1, 0, 1, 1, 0,
- 4, 2, 1, 0, 0, 1, 1, 1, 4, 2, 1, 0, 0, 0, 0, 1,
- 3, 1, 0, 0, -1, -1, -1, 0, 1, 0, 0, -1, -1, -2, -1, 0,
- 0, 0, 0, 0, -1, -1, -1, 0, -1, -1, 0, 0, -1, -1, 0, 1,
- -2, -1, 0, -1, -1, 0, 0, 1, -2, -2, -1, -2, -1, 0, 0, 1,
- 0, 1, 1, 1, 2, 1, 0, -1, -1, -1, -1, 0, 0, -1, -2, -2,
- -1, 0, -1, 0, 0, -1, -2, -1, 0, 0, 0, 0, 0, 0, 1, 2,
- 0, 0, 0, 0, 0, 0, 2, 3, -1, 0, -1, -1, -1, -1, 0, 3,
- -1, 0, 0, -1, -1, -2, 0, 3, 0, 0, 0, 0, -1, -1, 1, 4,
- 2, 2, 0, 0, 0, 0, 0, 1, 1, 1, -1, -2, -1, -2, -1, 1,
- -1, -1, -2, -2, -2, -3, -2, 0, -1, 0, -1, -1, -1, -2, -1, 1,
- 1, 1, 0, 0, 1, 0, 0, 1, 2, 2, 0, 0, 1, 0, 0, 1,
- 2, 2, 0, 0, 0, 0, -1, -1, 2, 2, 0, 0, 1, 0, -1, -1,
- -1, 0, 1, 1, 0, -1, -1, -1, 1, 2, 3, 2, 1, 0, 0, 0,
- 0, 1, 1, 1, 0, -1, 0, 0, -2, -2, -1, 0, 1, 0, 0, 0,
- -2, -2, -1, 2, 2, 2, 1, 0, -2, -1, 0, 1, 1, 0, 0, -1,
- -1, -1, 0, 0, -1, -2, -1, -2, 0, 1, 1, 1, 0, 0, 1, 1,
- -3, -3, -3, -2, -1, -1, -2, -2, -1, -1, 0, 1, 2, 1, 0, 0,
- 1, 1, 1, 2, 2, 1, 0, 0, 1, 1, 1, 1, 1, 0, -1, 1,
- 1, 0, -1, -1, 0, 0, -1, 1, 0, -1, -1, -1, 0, -1, -1, 1,
- 1, 0, -1, 0, 0, -1, 0, 2, 2, 0, -1, 0, 0, 0, 0, 2,
- 1, 0, -2, -1, 0, 1, 1, 0, 2, 0, -1, -1, 0, 1, 1, 0,
- 1, 0, -2, -1, 0, 1, 0, -1, 1, 0, -1, -1, 0, 1, 0, -1,
- 0, 1, 1, 0, 1, 1, 0, 0, -2, 1, 2, 1, 0, 0, 0, 1,
- -5, 0, 2, 1, 0, -1, 0, 1, -6, -1, 2, 1, 0, -1, 0, 0,
- 5, 3, 0, -1, -2, -1, -1, -1, 1, 1, 0, -1, -1, 0, -1, -1,
- -1, 0, 1, 1, 2, 2, 1, 0, -2, -1, 0, 1, 2, 1, 1, 1,
- -2, -1, -1, -1, 0, -1, 0, 1, 0, 1, 0, 0, -1, -1, 0, 0,
- 0, 1, 1, 1, 1, 0, 0, 0, -3, -2, 0, 1, 1, 0, 0, -1,
- -1, 0, 1, 0, -1, 0, 2, 3, -1, 0, 0, -2, -4, -2, -1, 0,
- 0, 1, 1, 0, -2, -1, 0, -1, 1, 2, 3, 1, 0, 1, 1, 0,
- -1, 0, 1, 1, 1, 1, 1, 0, -2, -3, -2, 0, 0, 0, 1, 0,
- -1, -2, -2, 0, 1, 0, 0, -1, 3, 1, 0, 0, 1, 0, -1, -1,
- -2, -1, 0, 0, -1, -1, 0, 0, -1, 0, 0, 0, 0, 1, 1, 1,
- -1, -1, -1, 0, 1, 1, 1, 1, 0, -2, -3, -1, 1, 0, 0, 0,
- 1, -1, -3, -1, 1, 1, 0, -1, 3, 1, -1, 1, 2, 2, 0, -1,
- 3, 1, 0, 1, 2, 1, 1, 0, 0, -2, -2, -1, -1, 0, 0, 0,
- 1, 0, -1, -1, 1, 2, 1, 0, 0, -1, -2, -1, 1, 2, 2, 1,
- -1, -1, -1, 0, 0, 1, 2, 0, -2, 0, 0, 0, 0, 0, 1, -1,
- -1, 0, 1, 0, -1, -1, -1, -1, 0, 1, 1, 2, 0, -2, -1, 0,
- 1, 2, 2, 2, 1, -1, -1, 0, 0, 1, 1, 1, 0, -2, -2, -1,
- 0, 0, -1, -1, -1, -1, -2, -2, 0, 0, -1, 0, 1, 2, 2, 1,
- 0, 0, -1, -1, 0, 1, 2, 2, 1, 1, -1, -2, -1, -1, -1, -1,
- 2, 2, 1, 0, 0, -1, -2, -2, 1, 2, 2, 1, 0, 0, -2, -2,
- 0, 0, 0, 0, 1, 1, 0, -1, 0, -1, -1, -1, 2, 3, 2, 1,
- 0, -2, 1, 2, -1, 0, 0, 1, -1, -2, 2, 3, -1, 0, 0, 0,
- 0, -2, 2, 3, -1, -1, 0, 0, 0, -1, 3, 2, -2, 0, 1, 0,
- 0, -1, 3, 1, -2, 0, 1, 0, 0, -1, 2, 1, -1, 1, 0, -1,
- 0, 0, 1, -1, -2, 0, 0, -1, 1, 0, 0, -2, -2, -1, -1, -1,
- 1, 1, 1, 1, 1, -1, -1, -2, 0, 0, 0, 1, 1, 1, 1, 1,
- 0, 0, 0, 1, 1, 1, 2, 3, 1, 0, 0, -1, 0, 0, 1, 2,
- 0, -1, -1, -2, -1, 0, 1, 2, -2, -2, -2, -2, -1, 0, 1, 1,
- -1, -1, -1, -1, 0, 0, 0, -1, 2, 2, 2, 0, -1, -1, -2, -4,
- -1, -2, -1, -1, 0, 1, 2, 3, -1, -1, -1, -1, 0, 1, 2, 3,
- 1, 0, -1, 0, -1, 0, 1, 2, 1, 0, 0, 0, -1, 0, 2, 2,
- 1, 0, -1, -1, -2, 0, 1, 2, 0, -2, -2, -2, -3, -1, 0, 1,
- 0, -2, -2, -2, -2, -1, 1, 1, 0, 0, 0, 0, 0, 1, 2, 2
-};
-
-/* list of codebooks for intra-coded vectors */
-static uint8_t *intra_codebooks[4] = {
- intra_codebook_4x2, intra_codebook_4x4, intra_codebook_8x4, intra_codebook_8x8
-};
diff --git a/src/libxinevdec/wc3video.c b/src/libxinevdec/wc3video.c
deleted file mode 100644
index 68ba2b43f..000000000
--- a/src/libxinevdec/wc3video.c
+++ /dev/null
@@ -1,539 +0,0 @@
-/*
- * Copyright (C) 2000-2003 the xine project
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * Video Decoder for Origin's Wing Commander III MVE Movie Files
- * by Mario Brito (mbrito@student.dei.uc.pt)
- * For more information on the WC3 Movie format, visit:
- * http://www.pcisys.net/~melanson/codecs/
- *
- * $Id: wc3video.c,v 1.20 2004/02/09 22:04:11 jstembridge Exp $
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include "buffer.h"
-#include "xine_internal.h"
-#include "video_out.h"
-#include "xineutils.h"
-#include "bswap.h"
-
-#define VIDEOBUFSIZE 128*1024
-
-#define WC3_WIDTH 320
-#define WC3_HEIGHT 165
-
-typedef struct {
- video_decoder_class_t decoder_class;
-} wc3video_class_t;
-
-typedef struct wc3video_decoder_s {
- video_decoder_t video_decoder; /* parent video decoder structure */
-
- wc3video_class_t *class;
- xine_stream_t *stream;
-
- /* these are traditional variables in a video decoder object */
- uint64_t video_step; /* frame duration in pts units */
- int decoder_ok; /* current decoder status */
- int skipframes;
-
- unsigned char *buf; /* the accumulated buffer data */
- int bufsize; /* the maximum size of buf */
- int size; /* the current size of buf */
-
- unsigned char yuv_palette[256 * 4];
-
- yuv_planes_t yuv_planes1;
- yuv_planes_t yuv_planes2;
-
- yuv_planes_t *current_frame;
- yuv_planes_t *last_frame;
-
- /* this is either 1 or 2 indicating the current_frame points to yuv_planes
- * structure 1 or 2 */
- int current_planes;
-
- double ratio;
-
-} wc3video_decoder_t;
-
-/**************************************************************************
- * WC3 video specific decode functions
- *************************************************************************/
-
-#define SIZE (WC3_WIDTH * WC3_HEIGHT)
-#define BYTE unsigned char
-
-static BYTE buffer1[SIZE];
-static BYTE buffer2[SIZE];
-
-static BYTE * part1;
-static BYTE * part2;
-static BYTE * part3;
-static BYTE * part4;
-
-static void bytecopy(BYTE * dest, BYTE * src, int count) {
-
- int i;
-
- /* Don't use memcpy because the memory locations often overlap and
- * memcpy doesn't like that; it's not uncommon, for example, for
- * dest = src+1, to turn byte A into pattern AAAAAAAA.
- * This was originally repz movsb. */
- for (i = 0; i < count; i ++)
- dest[i] = src[i];
-}
-
-static void wc3_build_frame (wc3video_decoder_t *this) {
-
- int frame_size = WC3_WIDTH * WC3_HEIGHT;
- int index = 0;
- BYTE pixel;
- BYTE y, u, v;
- int size = 0;
- BYTE flag = 0;
- int func;
-
- while (index < frame_size) {
- func = *part1++;
- size = 0;
-
- switch (func) {
- case 0:
- flag ^= 1;
- continue;
-
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- size = func;
- break;
-
- case 12:
- case 13:
- case 14:
- case 15:
- case 16:
- case 17:
- case 18:
- size += (func - 10);
- break;
-
- case 9:
- case 19:
- size = (*part2++);
- break;
-
- case 10:
- case 20:
- size = BE_16(&part2[0]);
- part2 += 2;
- break;
-
- case 11:
- case 21:
- size = (part2[0] << 16) | (part2[1] << 8) | part2[2];
- part2 += 3;
- break;
- }
-
- /* run is unchanged from last frame */
- if (func < 12) {
- flag = flag ^ 1;
- if ( flag ) {
- xine_fast_memcpy(
- &this->current_frame->y[index],
- &this->last_frame->y[index],
- size);
- xine_fast_memcpy(
- &this->current_frame->u[index],
- &this->last_frame->u[index],
- size);
- xine_fast_memcpy(
- &this->current_frame->v[index],
- &this->last_frame->v[index],
- size);
- index += size;
- } else {
- while (size > 0) {
- pixel = *part4++;
- y = this->yuv_palette[pixel * 4 + 0];
- u = this->yuv_palette[pixel * 4 + 1];
- v = this->yuv_palette[pixel * 4 + 2];
- this->current_frame->y[index] = y;
- this->current_frame->u[index] = u;
- this->current_frame->v[index] = v;
- index++;
- size --;
- }
- }
- } else {
- /* run displacement from last frame */
- int x = (*part3 >> 4) & 0xf;
- int y = *part3 & 0xf;
- part3++;
-
- /* extend sign */
- if (x & 8) x |= 0xfffffff0;
- if (y & 8) y |= 0xfffffff0;
-
- /* copy a run of pixels from the previous frame */
- xine_fast_memcpy(
- &this->current_frame->y[index],
- &this->last_frame->y[index + x + y * WC3_WIDTH],
- size);
- xine_fast_memcpy(
- &this->current_frame->u[index],
- &this->last_frame->u[index + x + y * WC3_WIDTH],
- size);
- xine_fast_memcpy(
- &this->current_frame->v[index],
- &this->last_frame->v[index + x + y * WC3_WIDTH],
- size);
- index += size;
-
- flag = 0;
- }
- }
-}
-
-static void wc3_do_part4 (BYTE * dest, BYTE * src) {
-
- int func;
- int size;
- int offset;
- int byte1, byte2, byte3;
-
- for (;;) {
- func = *src++;
-
- if ( (func & 0x80) == 0 ) {
-
- offset = *src++;
-
- size = func & 3;
- bytecopy(dest, src, size); dest += size; src += size;
-
- size = ((func & 0x1c) >> 2) + 3;
- bytecopy (dest, dest - ( ((func & 0x60) << 3) + offset + 1 ), size);
- dest += size;
-
- } else if ( (func & 0x40) == 0 ) {
-
- byte1 = *src++;
- byte2 = *src++;
-
- size = byte1 >> 6;
- bytecopy (dest, src, size); dest += size; src += size;
-
- size = (func & 0x3f) + 4;
- bytecopy (dest, dest - (((byte1 & 0x3f) << 8) + byte2 + 1), size);
- dest += size;
-
- } else if ( (func & 0x20) == 0 ) {
-
- byte1 = *src++;
- byte2 = *src++;
- byte3 = *src++;
-
- size = func & 3;
- bytecopy (dest, src, size); dest += size; src += size;
-
- size = byte3 + 5 + ((func & 0xc) << 6);
- bytecopy (dest,
- dest - ((((func & 0x10) >> 4) << 0x10) + 1 + (byte1 << 8) + byte2),
- size);
- dest += size;
- } else {
- size = ((func & 0x1f) << 2) + 4;
-
- if (size > 0x70)
- break;
-
- bytecopy (dest, src, size); dest += size; src += size;
- }
- }
-
- size = func & 3;
- bytecopy(dest, src, size); dest += size; src += size;
-}
-
-static void wc3_do_part1 (BYTE * dest, BYTE * src) {
-
- BYTE byte = *src++;
- BYTE ival = byte + 0x16;
- BYTE * ptr = src + byte*2;
- BYTE val = ival;
- int counter = 0;
-
- BYTE bits = *ptr++;
-
- while ( val != 0x16 ) {
- if ( (1 << counter) & bits )
- val = src[byte + val - 0x17];
- else
- val = src[val - 0x17];
-
- if ( val < 0x16 ) {
- *dest++ = val;
- val = ival;
- }
-
- if (counter++ == 7) {
- counter = 0;
- bits = *ptr++;
- }
- }
-}
-
-static void wc3_decode_frame (wc3video_decoder_t *this) {
-
- BYTE * ptr;
-
- part1 = buffer1;
- part4 = buffer2;
-
- wc3_do_part1(part1, this->buf + LE_16(&this->buf[0]));
- part2 = this->buf + LE_16(&this->buf[2]);
- part3 = this->buf + LE_16(&this->buf[4]);
-
- ptr = this->buf + LE_16(&this->buf[6]);
- if (*ptr++ == 2)
- wc3_do_part4(part4, ptr);
- else
- part4 = ptr;
-
- wc3_build_frame(this);
-}
-
-/**************************************************************************
- * xine video plugin functions
- *************************************************************************/
-
-/*
- * This function receives a buffer of data from the demuxer layer and
- * figures out how to handle it based on its header flags.
- */
-static void wc3video_decode_data (video_decoder_t *this_gen,
- buf_element_t *buf) {
-
- wc3video_decoder_t *this = (wc3video_decoder_t *) this_gen;
- palette_entry_t *palette;
- int i;
-
- vo_frame_t *img; /* video out frame */
-
- /* a video decoder does not care about this flag (?) */
- if (buf->decoder_flags & BUF_FLAG_PREVIEW)
- return;
-
- /* convert the RGB palette to a YUV palette */
- if ((buf->decoder_flags & BUF_FLAG_SPECIAL) &&
- (buf->decoder_info[1] == BUF_SPECIAL_PALETTE)) {
- palette = (palette_entry_t *)buf->decoder_info_ptr[2];
- for (i = 0; i < buf->decoder_info[2]; i++) {
- this->yuv_palette[i * 4 + 0] =
- COMPUTE_Y(palette[i].r, palette[i].g, palette[i].b);
- this->yuv_palette[i * 4 + 1] =
- COMPUTE_U(palette[i].r, palette[i].g, palette[i].b);
- this->yuv_palette[i * 4 + 2] =
- COMPUTE_V(palette[i].r, palette[i].g, palette[i].b);
- }
- }
-
- if (buf->decoder_flags & BUF_FLAG_FRAMERATE) {
- this->video_step = buf->decoder_info[0];
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION, this->video_step);
- }
-
- if (buf->decoder_flags & BUF_FLAG_HEADER) { /* need to initialize */
- this->stream->video_out->open (this->stream->video_out, this->stream);
-
- if(this->buf)
- free(this->buf);
-
- if (this->buf)
- free (this->buf);
- this->bufsize = VIDEOBUFSIZE;
- this->buf = malloc(this->bufsize);
- this->size = 0;
-
- init_yuv_planes(&this->yuv_planes1, WC3_WIDTH, WC3_HEIGHT);
- init_yuv_planes(&this->yuv_planes2, WC3_WIDTH, WC3_HEIGHT);
- this->current_planes = 1;
-
- this->decoder_ok = 1;
-
- /* load the stream/meta info */
- _x_meta_info_set(this->stream, XINE_META_INFO_VIDEOCODEC, "Wing Commander III Video");
-
- return;
- } else if (this->decoder_ok) {
-
- if (this->size + buf->size > this->bufsize) {
- this->bufsize = this->size + 2 * buf->size;
- this->buf = realloc (this->buf, this->bufsize);
- }
-
- xine_fast_memcpy (&this->buf[this->size], buf->content, buf->size);
-
- this->size += buf->size;
-
- if (buf->decoder_flags & BUF_FLAG_FRAME_END) {
-
- img = this->stream->video_out->get_frame (this->stream->video_out,
- WC3_WIDTH, WC3_HEIGHT,
- this->ratio, XINE_IMGFMT_YUY2, VO_BOTH_FIELDS);
-
- img->duration = this->video_step;
- img->pts = buf->pts;
- img->bad_frame = 0;
-
- if (this->current_planes == 1) {
- this->current_planes = 2;
- this->current_frame = &this->yuv_planes1;
- this->last_frame = &this->yuv_planes2;
- } else {
- this->current_planes = 1;
- this->current_frame = &this->yuv_planes2;
- this->last_frame = &this->yuv_planes1;
- }
-
- wc3_decode_frame (this);
- yuv444_to_yuy2(this->current_frame, img->base[0], img->pitches[0]);
-
- img->draw(img, this->stream);
- img->free(img);
-
- this->size = 0;
- }
- }
-}
-
-/*
- * This function is called when xine needs to flush the system. Not
- * sure when or if this is used or even if it needs to do anything.
- */
-static void wc3video_flush (video_decoder_t *this_gen) {
-}
-
-/*
- * This function resets the video decoder.
- */
-static void wc3video_reset (video_decoder_t *this_gen) {
- wc3video_decoder_t *this = (wc3video_decoder_t *) this_gen;
-
- this->size = 0;
-}
-
-static void wc3video_discontinuity (video_decoder_t *this_gen) {
-}
-
-/*
- * This function frees the video decoder instance allocated to the decoder.
- */
-static void wc3video_dispose (video_decoder_t *this_gen) {
-
- wc3video_decoder_t *this = (wc3video_decoder_t *) this_gen;
-
- if (this->buf) {
- free (this->buf);
- this->buf = NULL;
- }
-
- if (this->decoder_ok) {
- this->decoder_ok = 0;
- this->stream->video_out->close(this->stream->video_out, this->stream);
- }
-
- free (this_gen);
-}
-
-static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stream_t *stream) {
-
- wc3video_decoder_t *this ;
-
- this = (wc3video_decoder_t *) xine_xmalloc (sizeof (wc3video_decoder_t));
-
- this->video_decoder.decode_data = wc3video_decode_data;
- this->video_decoder.flush = wc3video_flush;
- this->video_decoder.reset = wc3video_reset;
- this->video_decoder.discontinuity = wc3video_discontinuity;
- this->video_decoder.dispose = wc3video_dispose;
- this->size = 0;
-
- this->stream = stream;
- this->class = (wc3video_class_t *) class_gen;
-
- this->decoder_ok = 0;
- this->buf = NULL;
-
- this->ratio = (double)WC3_WIDTH/(double)WC3_HEIGHT;
-
- return &this->video_decoder;
-}
-
-static char *get_identifier (video_decoder_class_t *this) {
- return "WC3 Video";
-}
-
-static char *get_description (video_decoder_class_t *this) {
- return "Wing Commander III video decoder plugin";
-}
-
-static void dispose_class (video_decoder_class_t *this) {
- free (this);
-}
-
-static void *init_plugin (xine_t *xine, void *data) {
-
- wc3video_class_t *this;
-
- this = (wc3video_class_t *) xine_xmalloc (sizeof (wc3video_class_t));
-
- this->decoder_class.open_plugin = open_plugin;
- this->decoder_class.get_identifier = get_identifier;
- this->decoder_class.get_description = get_description;
- this->decoder_class.dispose = dispose_class;
-
- return this;
-}
-
-/* plugin catalog information */
-static uint32_t supported_types[] = { BUF_VIDEO_WC3, 0 };
-
-static decoder_info_t video_decoder_info = {
- supported_types, /* supported types */
- 9 /* priority */
-};
-
-plugin_info_t xine_plugin_info[] = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_VIDEO_DECODER, 18, "wc3video", XINE_VERSION_CODE, &video_decoder_info, &init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};