summaryrefslogtreecommitdiffstats
path: root/libmpcodecs/native
diff options
context:
space:
mode:
authoralex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2>2003-07-13 15:56:20 +0000
committeralex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2>2003-07-13 15:56:20 +0000
commit5b891238099525c8b8529a0f11ac4a296fc8aba6 (patch)
tree9b61e78ae02de2fdd9043fdcac36e881be903c16 /libmpcodecs/native
parent8dbd85b9249385d246b11ba81d157e0b19c74e55 (diff)
downloadmpv-5b891238099525c8b8529a0f11ac4a296fc8aba6.tar.bz2
mpv-5b891238099525c8b8529a0f11ac4a296fc8aba6.tar.xz
removed our native svq1 and huffyuv implementation as libavcodec's implementations are much better
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10419 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpcodecs/native')
-rw-r--r--libmpcodecs/native/svq1.c799
-rw-r--r--libmpcodecs/native/svq1.h38
-rw-r--r--libmpcodecs/native/svq1_cb.h1971
3 files changed, 0 insertions, 2808 deletions
diff --git a/libmpcodecs/native/svq1.c b/libmpcodecs/native/svq1.c
deleted file mode 100644
index b662400c17..0000000000
--- a/libmpcodecs/native/svq1.c
+++ /dev/null
@@ -1,799 +0,0 @@
-/*
- * Copyright (C) 2002 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$
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "../../config.h"
-
-#ifdef USE_SVQ1
-
-#include "bswap.h"
-
-/* variable length (bit) code */
-typedef struct vlc_code_s {
- int16_t value :10,
- length :6;
-} vlc_code_t;
-
-#define VIDEOBUFSIZE 1280 * 1024
-
-//char temp_buf[VIDEOBUFSIZE];
-
-#define MEDIAN(a,b,c) (((a < b) != (b >= c)) ? b : (((a < c) != (c > b)) ? c : a))
-
-#include "svq1.h"
-#include "svq1_cb.h"
-
-#ifdef USE_LIBAVCODEC
-typedef void (*op_pixels_func)(unsigned char *block, const unsigned char *pixels, int line_size, int h);
-extern op_pixels_func put_pixels_tab[4];
-extern op_pixels_func put_no_rnd_pixels_tab[4];
-//#define HAVE_AV_CONFIG_H
-#endif
-
-#ifdef HAVE_AV_CONFIG_H
-// use libavcodec's get_bits():
-//#define ALT_BITSTREAM_READER
-//#define ALIGNED_BITSTREAM
-#include "../../libavcodec/common.h"
-#define bit_buffer_t GetBitContext
-#define get_bit_cache(buf) (show_bits(buf,24)<<8)
-//#define get_bit_cache(buf) show_bits(buf,32)
-#else
-// use built-in version:
-
-/* memory bit stream */
-typedef struct bit_buffer_s {
- uint8_t *buffer;
- uint32_t bitpos;
-} bit_buffer_t;
-
-static inline void skip_bits(bit_buffer_t *bitbuf, int n){
- bitbuf->bitpos+=n;
-}
-
-static void init_get_bits(bit_buffer_t *bitbuf,
- unsigned char *buffer, int buffer_size){
- bitbuf->buffer=buffer;
- bitbuf->bitpos=0;
-}
-
-static inline uint32_t get_bits (bit_buffer_t *bitbuf, int count) {
- uint32_t result;
-
- /* load 32 bits of data (byte-aligned) */
- result = be2me_32 (*((uint32_t *) &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 inline uint32_t get_bit_cache(bit_buffer_t *bitbuf) {
- uint32_t result;
-
- /* load 32 bits of data (byte-aligned) */
- result = be2me_32 (*((uint32_t *) &bitbuf->buffer[bitbuf->bitpos >> 3]));
-
- /* compensate for sub-byte offset */
- result <<= (bitbuf->bitpos & 0x7);
-
- return result;
-}
-
-#endif
-
-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;
- skip_bits(bitbuf,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;
- skip_bits(bitbuf,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 */
- skip_bits(bitbuf,1);
-
- } 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 */
- skip_bits(bitbuf,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 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, int x, int y) {
- 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;
-
- src = &previous[(x + (mv.x >> 1)) + (y + (mv.y >> 1))*pitch];
- dst = current;
-
-#ifdef USE_LIBAVCODEC
- put_pixels_tab[((mv.y & 1) << 1) | (mv.x & 1)](dst,src,pitch,16);
- put_pixels_tab[((mv.y & 1) << 1) | (mv.x & 1)](dst+8,src+8,pitch,16);
-#else
- /* 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;
- }
- }
- }
-#endif
-
- return 0;
-}
-
-static int motion_inter_4v_block (bit_buffer_t *bitbuf,
- uint8_t *current, uint8_t *previous, int pitch,
- svq1_pmv_t *motion,int x, int y) {
- 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;
-
- /* form predictions */
- for (i=0; i < 4; i++) {
- src = &previous[(x + (pmv[i]->x >> 1)) + (y + (pmv[i]->y >> 1))*pitch];
- dst = current;
-
-#ifdef USE_LIBAVCODEC
- put_pixels_tab[((pmv[i]->y & 1) << 1) | (pmv[i]->x & 1)](dst,src,pitch,8);
-#else
- 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;
- }
- }
- }
-#endif
-
- /* 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, int x, int y) {
- 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;
- skip_bits(bitbuf,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);
-
- 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);
-
- 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;
-}
-
-/* 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 }
-};
-
-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) {
- skip_bits(bitbuf,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;
-}
-
-int svq1_decode_frame (svq1_t *svq1, uint8_t *buffer,int buffer_len) {
- bit_buffer_t bitbuf;
- uint8_t *current, *previous;
- int result, i, x, y, width, height;
- int luma_size, chroma_size;
-
-// memcpy(temp_buf,buffer,buffer_len); buffer=temp_buf;
-
- /* initialize bit buffer */
- init_get_bits(&bitbuf,buffer,buffer_len);
-
- /* 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)
- 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->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)
- 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);
-
- if (result != 0)
- 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;
-}
-
-void svq1_free (svq1_t *svq1){
- if (svq1) {
- free (svq1->current);
- free (svq1->previous);
- free (svq1->motion);
- free (svq1);
- }
-}
-
-#endif
diff --git a/libmpcodecs/native/svq1.h b/libmpcodecs/native/svq1.h
deleted file mode 100644
index a641c307e8..0000000000
--- a/libmpcodecs/native/svq1.h
+++ /dev/null
@@ -1,38 +0,0 @@
-
-#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
-
-/* 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;
-} svq1_t;
-
-int svq1_decode_frame (svq1_t *svq1, uint8_t *buffer, int buffer_size);
-void svq1_free (svq1_t *svq1);
diff --git a/libmpcodecs/native/svq1_cb.h b/libmpcodecs/native/svq1_cb.h
deleted file mode 100644
index cc26ac6c27..0000000000
--- a/libmpcodecs/native/svq1_cb.h
+++ /dev/null
@@ -1,1971 +0,0 @@
-/*
- * Copyright (C) 2002 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$
- */
-
-#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