summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/en/codecs.html11
-rw-r--r--codec-cfg.c2
-rw-r--r--etc/codecs.conf29
-rw-r--r--libmpcodecs/Makefile2
-rw-r--r--libmpcodecs/native/svq1.c799
-rw-r--r--libmpcodecs/native/svq1.h38
-rw-r--r--libmpcodecs/native/svq1_cb.h1971
-rw-r--r--libmpcodecs/vd.c6
-rw-r--r--libmpcodecs/vd_huffyuv.c1019
-rw-r--r--libmpcodecs/vd_svq1.c90
10 files changed, 11 insertions, 3956 deletions
diff --git a/DOCS/en/codecs.html b/DOCS/en/codecs.html
index f577448149..430bb39e75 100644
--- a/DOCS/en/codecs.html
+++ b/DOCS/en/codecs.html
@@ -325,14 +325,9 @@ MPlayer supports decoding all versions of RealVideo:
following decoders:</P>
<UL>
- <LI>Sorenson 1 (fourcc <I>SVQ1</I>) - decoding supported by <B>native
- codecs</B><BR>
- Actually there are two (nearly equal) decoders for SVQ1: one is built in
- MPlayer, the other is in libavcodec. You can invoke each of them with the
- <CODE>-vc svq1</CODE> and <CODE>-vc ffsvq1</CODE> options respectively.
- Some files may work with one of them, and not with the other, so test
- both decoders.</LI>
- <LI>Sorenson 3 (fourcc <I>SVQ3</I>) - decoding supported by <B>native
+ <LI>Sorenson Video v1 (fourcc <I>SVQ1</I>) - decoding supported by <B>native
+ codec</B> (<A HREF="#libavcodec">libavcodec</A>)</LI>
+ <LI>Sorenson Video v3 (fourcc <I>SVQ3</I>) - decoding supported by <B>native
codec</B> (<A HREF="#libavcodec">libavcodec</A>)</LI>
</UL>
diff --git a/codec-cfg.c b/codec-cfg.c
index 5ec732360d..6ad5183406 100644
--- a/codec-cfg.c
+++ b/codec-cfg.c
@@ -285,11 +285,9 @@ static short get_driver(char *s,int audioflag)
"qtrpza",
"mpng",
"ijpg",
- "huffyuv",
"zlib",
"mpegpes",
"realvid",
- "svq1",
"xvid",
"libdv",
NULL
diff --git a/etc/codecs.conf b/etc/codecs.conf
index 2c185d210b..7572ad836b 100644
--- a/etc/codecs.conf
+++ b/etc/codecs.conf
@@ -209,13 +209,6 @@ videocodec huffyuv
;NATIVE:
-videocodec svq1
- info "Sorenson v1 (native codec)"
- status buggy
- fourcc SVQ1
- driver svq1
- out YVU9
-
videocodec video1
info "Microsoft Video 1 (native codec)"
status working
@@ -234,14 +227,6 @@ videocodec cvid
out YUY2
out BGR32,BGR24
-videocodec mphuffyuv
- info "HuffYUV (native codec)"
- status working
- fourcc HFYU
- driver huffyuv
- out YUY2
- out BGR32,BGR24
-
videocodec mpmszh
info "AVImszh (native codec)"
status working
@@ -270,8 +255,8 @@ videocodec cvidxa
; ff* is fastest...
videocodec ffhuffyuv
- info "FFHuffYUV"
- status untested
+ info "FFmpeg HuffYUV"
+ status working
fourcc HFYU
driver ffmpeg
dll huffyuv
@@ -279,7 +264,7 @@ videocodec ffhuffyuv
out BGR32,BGR24
videocodec ffv1
- info "FFV1"
+ info "FFV1 (lossless codec)"
status working
fourcc FFV1
driver ffmpeg
@@ -287,7 +272,7 @@ videocodec ffv1
out 411P,444P,422P,YV12,I420,IYUV,YVU9
videocodec ffasv1
- info "ASUS V1"
+ info "FFmpeg ASUS V1"
status working
fourcc ASV1
driver ffmpeg
@@ -295,7 +280,7 @@ videocodec ffasv1
out YV12,I420,IYUV
videocodec ffsvq1
- info "FFmpeg Sorenson Video v1"
+ info "FFmpeg Sorenson Video v1 (SVQ1)"
status working
fourcc SVQ1
driver ffmpeg
@@ -361,7 +346,7 @@ videocodec ffh264
out YV12,I420,IYUV
videocodec ffsvq3
- info "FFmpeg SVQ3"
+ info "FFmpeg Sorenson Video v3 (SVQ3)"
status working
fourcc SVQ3
driver ffmpeg
@@ -387,7 +372,7 @@ videocodec ffodivx
out YV12,I420,IYUV
videocodec xvid
- info "Xvid (MPEG-4)"
+ info "XviD (MPEG-4)"
status working
fourcc DIVX,divx
fourcc xvid,XVID,XviD
diff --git a/libmpcodecs/Makefile b/libmpcodecs/Makefile
index 2d5772d441..20d149e254 100644
--- a/libmpcodecs/Makefile
+++ b/libmpcodecs/Makefile
@@ -10,7 +10,7 @@ AUDIO_SRCS_OPT=ad_acm.c ad_dshow.c ad_dmo.c ad_qtaudio.c ad_ffmpeg.c ad_faad.c a
AUDIO_SRCS=dec_audio.c ad.c $(AUDIO_SRCS_LIB) $(AUDIO_SRCS_NAT) $(AUDIO_SRCS_OPT)
VIDEO_SRCS_LIB=vd_libmpeg2.c vd_nuv.c vd_lzo.c
-VIDEO_SRCS_NAT=vd_null.c vd_cinepak.c vd_qtrpza.c vd_raw.c vd_hmblck.c vd_msvidc.c vd_fli.c vd_qtrle.c vd_qtsmc.c vd_roqvideo.c vd_cyuv.c vd_msrle.c vd_huffyuv.c vd_mpegpes.c vd_svq1.c vd_lcl.c vd_mtga.c vd_sgi.c
+VIDEO_SRCS_NAT=vd_null.c vd_cinepak.c vd_qtrpza.c vd_raw.c vd_hmblck.c vd_msvidc.c vd_fli.c vd_qtrle.c vd_qtsmc.c vd_roqvideo.c vd_cyuv.c vd_msrle.c vd_mpegpes.c vd_lcl.c vd_mtga.c vd_sgi.c
VIDEO_SRCS_OPT=vd_realvid.c vd_ffmpeg.c vd_dshow.c vd_dmo.c vd_vfw.c vd_vfwex.c vd_odivx.c vd_divx4.c vd_xanim.c vd_xvid.c vd_libdv.c vd_qtvideo.c vd_theora.c
VIDEO_SRCS=dec_video.c vd.c $(VIDEO_SRCS_NAT) $(VIDEO_SRCS_LIB) $(VIDEO_SRCS_OPT)
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,