summaryrefslogtreecommitdiff
path: root/src/libxinevdec
diff options
context:
space:
mode:
Diffstat (limited to 'src/libxinevdec')
-rw-r--r--src/libxinevdec/Makefile.am47
-rw-r--r--src/libxinevdec/bitplane.c1586
-rw-r--r--src/libxinevdec/foovideo.c305
-rw-r--r--src/libxinevdec/gdkpixbuf.c316
-rw-r--r--src/libxinevdec/image.c323
-rw-r--r--src/libxinevdec/rgb.c467
-rw-r--r--src/libxinevdec/xine_theora_decoder.c398
-rw-r--r--src/libxinevdec/yuv.c394
8 files changed, 0 insertions, 3836 deletions
diff --git a/src/libxinevdec/Makefile.am b/src/libxinevdec/Makefile.am
deleted file mode 100644
index b7dbe1db1..000000000
--- a/src/libxinevdec/Makefile.am
+++ /dev/null
@@ -1,47 +0,0 @@
-include $(top_builddir)/misc/Makefile.plugins
-include $(top_srcdir)/misc/Makefile.common
-
-AM_CFLAGS = $(VISIBILITY_FLAG)
-AM_LDFLAGS = $(xineplug_ldflags)
-
-EXTRA_DIST = foovideo.c
-
-if HAVE_WAND
-image_module = xineplug_decode_image.la
-endif
-
-if HAVE_GDK_PIXBUF
-gdkpixbuf_module = xineplug_decode_gdk_pixbuf.la
-endif
-
-if HAVE_THEORA
-theora_module = xineplug_decode_theora.la
-endif
-
-xineplug_LTLIBRARIES = $(image_module) \
- $(gdkpixbuf_module) \
- $(theora_module) \
- xineplug_decode_bitplane.la \
- xineplug_decode_rgb.la \
- xineplug_decode_yuv.la
-
-xineplug_decode_bitplane_la_SOURCES = bitplane.c
-xineplug_decode_bitplane_la_LIBADD = $(XINE_LIB) $(LTLIBINTL)
-
-xineplug_decode_rgb_la_SOURCES = rgb.c
-xineplug_decode_rgb_la_LIBADD = $(XINE_LIB)
-
-xineplug_decode_yuv_la_SOURCES = yuv.c
-xineplug_decode_yuv_la_LIBADD = $(XINE_LIB)
-
-xineplug_decode_image_la_SOURCES = image.c
-xineplug_decode_image_la_CFLAGS = $(AM_CFLAGS) $(WAND_CFLAGS)
-xineplug_decode_image_la_LIBADD = $(XINE_LIB) $(DYNAMIC_LD_LIBS) $(WAND_LIBS)
-
-xineplug_decode_gdk_pixbuf_la_SOURCES = gdkpixbuf.c
-xineplug_decode_gdk_pixbuf_la_CFLAGS = $(AM_CFLAGS) $(GDK_PIXBUF_CFLAGS)
-xineplug_decode_gdk_pixbuf_la_LIBADD = $(XINE_LIB) $(DYNAMIC_LD_LIBS) $(GDK_PIXBUF_LIBS)
-
-xineplug_decode_theora_la_SOURCES = xine_theora_decoder.c
-xineplug_decode_theora_la_CFLAGS = $(AM_CFLAGS) $(OGG_CFLAGS) $(THEORA_CFLAGS)
-xineplug_decode_theora_la_LIBADD = $(XINE_LIB) $(OGG_LIBS) $(THEORA_LIBS) $(LTLIBINTL)
diff --git a/src/libxinevdec/bitplane.c b/src/libxinevdec/bitplane.c
deleted file mode 100644
index 76b7c8a89..000000000
--- a/src/libxinevdec/bitplane.c
+++ /dev/null
@@ -1,1586 +0,0 @@
-/*
- * Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * Bitplane "Decoder" by Manfred Tremmel (Manfred.Tremmel@iiv.de)
- * Converts Amiga typical bitplane pictures to a YUV2 map
- * suitable for display under xine. It's based on the rgb-decoder
- * and the development documentation from the Amiga Developer CD
- *
- * Supported formats:
- * - uncompressed and byterun1 compressed ILBM data
- * - IFF ANIM compression methods OPT 5, 7 (long and short) and
- * 8 (long and short)
- * - untested (found no testfiles) IFF-ANIM OPT 3, 4 and 6
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#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"
-
-#include "demuxers/iff.h"
-
-#define IFF_REPLACE_BYTE_SIMPLE(ptr, old_data, new_data, colorindexx ) { \
- register uint8_t *index_ptr = ptr; \
- register uint8_t colorindex = colorindexx; \
- *index_ptr -= ((old_data & 0x80) ? colorindex : 0); \
- *index_ptr++ += ((new_data & 0x80) ? colorindex : 0); \
- *index_ptr -= ((old_data & 0x40) ? colorindex : 0); \
- *index_ptr++ += ((new_data & 0x40) ? colorindex : 0); \
- *index_ptr -= ((old_data & 0x20) ? colorindex : 0); \
- *index_ptr++ += ((new_data & 0x20) ? colorindex : 0); \
- *index_ptr -= ((old_data & 0x10) ? colorindex : 0); \
- *index_ptr++ += ((new_data & 0x10) ? colorindex : 0); \
- *index_ptr -= ((old_data & 0x08) ? colorindex : 0); \
- *index_ptr++ += ((new_data & 0x08) ? colorindex : 0); \
- *index_ptr -= ((old_data & 0x04) ? colorindex : 0); \
- *index_ptr++ += ((new_data & 0x04) ? colorindex : 0); \
- *index_ptr -= ((old_data & 0x02) ? colorindex : 0); \
- *index_ptr++ += ((new_data & 0x02) ? colorindex : 0); \
- *index_ptr -= ((old_data & 0x01) ? colorindex : 0); \
- *index_ptr += ((new_data & 0x01) ? colorindex : 0); \
- old_data = new_data; \
-}
-
-#define IFF_REPLACE_BYTE(ptr, yuvy, yuvu, yuvv, yuv_palette, old_data, new_data, colorindexx ) { \
- register uint8_t *index_ptr = ptr; \
- register uint8_t colorindex = colorindexx; \
- register uint8_t *yuv_y = yuvy; \
- register uint8_t *yuv_u = yuvu; \
- register uint8_t *yuv_v = yuvv; \
- *index_ptr -= ((old_data & 0x80) ? colorindex : 0); \
- *index_ptr += ((new_data & 0x80) ? colorindex : 0); \
- yuv_index = *index_ptr++ * 4; \
- *yuv_y++ = yuv_palette[yuv_index++]; \
- *yuv_u++ = yuv_palette[yuv_index++]; \
- *yuv_v++ = yuv_palette[yuv_index]; \
- *index_ptr -= ((old_data & 0x40) ? colorindex : 0); \
- *index_ptr += ((new_data & 0x40) ? colorindex : 0); \
- yuv_index = *index_ptr++ * 4; \
- *yuv_y++ = yuv_palette[yuv_index++]; \
- *yuv_u++ = yuv_palette[yuv_index++]; \
- *yuv_v++ = yuv_palette[yuv_index]; \
- *index_ptr -= ((old_data & 0x20) ? colorindex : 0); \
- *index_ptr += ((new_data & 0x20) ? colorindex : 0); \
- yuv_index = *index_ptr++ * 4; \
- *yuv_y++ = yuv_palette[yuv_index++]; \
- *yuv_u++ = yuv_palette[yuv_index++]; \
- *yuv_v++ = yuv_palette[yuv_index]; \
- *index_ptr -= ((old_data & 0x10) ? colorindex : 0); \
- *index_ptr += ((new_data & 0x10) ? colorindex : 0); \
- yuv_index = *index_ptr++ * 4; \
- *yuv_y++ = yuv_palette[yuv_index++]; \
- *yuv_u++ = yuv_palette[yuv_index++]; \
- *yuv_v++ = yuv_palette[yuv_index]; \
- *index_ptr -= ((old_data & 0x08) ? colorindex : 0); \
- *index_ptr += ((new_data & 0x08) ? colorindex : 0); \
- yuv_index = *index_ptr++ * 4; \
- *yuv_y++ = yuv_palette[yuv_index++]; \
- *yuv_u++ = yuv_palette[yuv_index++]; \
- *yuv_v++ = yuv_palette[yuv_index]; \
- *index_ptr -= ((old_data & 0x04) ? colorindex : 0); \
- *index_ptr += ((new_data & 0x04) ? colorindex : 0); \
- yuv_index = *index_ptr++ * 4; \
- *yuv_y++ = yuv_palette[yuv_index++]; \
- *yuv_u++ = yuv_palette[yuv_index++]; \
- *yuv_v++ = yuv_palette[yuv_index]; \
- *index_ptr -= ((old_data & 0x02) ? colorindex : 0); \
- *index_ptr += ((new_data & 0x02) ? colorindex : 0); \
- yuv_index = *index_ptr++ * 4; \
- *yuv_y++ = yuv_palette[yuv_index++]; \
- *yuv_u++ = yuv_palette[yuv_index++]; \
- *yuv_v++ = yuv_palette[yuv_index]; \
- *index_ptr -= ((old_data & 0x01) ? colorindex : 0); \
- *index_ptr += ((new_data & 0x01) ? colorindex : 0); \
- yuv_index = *index_ptr * 4; \
- *yuv_y = yuv_palette[yuv_index++]; \
- *yuv_u = yuv_palette[yuv_index++]; \
- *yuv_v = yuv_palette[yuv_index]; \
- old_data = new_data; \
-}
-
-#define IFF_REPLACE_SHORT_SIMPLE(ptr_s, old_data_s, new_data_s, colorindexx_s ) { \
- uint8_t *xindex_ptr = (uint8_t *)ptr_s; \
- uint8_t *xold_data = (uint8_t *)old_data_s; \
- uint8_t *xnew_data = (uint8_t *)new_data_s; \
- IFF_REPLACE_BYTE_SIMPLE(xindex_ptr, *xold_data, *xnew_data, colorindexx_s ); \
- xindex_ptr += 8; \
- xold_data++; \
- xnew_data++; \
- IFF_REPLACE_BYTE_SIMPLE(xindex_ptr, *xold_data, *xnew_data, colorindexx_s ); \
-}
-
-#define IFF_REPLACE_SHORT(ptr_s, yuvy_s, yuvu_s, yuvv_s, yuv_palette_s, old_data_s, new_data_s, colorindexx_s ) { \
- uint8_t *xindex_ptr = (uint8_t *)ptr_s; \
- uint8_t *xold_data = (uint8_t *)old_data_s; \
- uint8_t *xnew_data = (uint8_t *)new_data_s; \
- uint8_t *xyuv_y = yuvy_s; \
- uint8_t *xyuv_u = yuvu_s; \
- uint8_t *xyuv_v = yuvv_s; \
- IFF_REPLACE_BYTE(xindex_ptr, xyuv_y, xyuv_u, xyuv_v, yuv_palette_s, *xold_data, *xnew_data, colorindexx_s ); \
- xindex_ptr += 8; \
- xold_data++; \
- xnew_data++; \
- xyuv_y += 8; \
- xyuv_u += 8; \
- xyuv_v += 8; \
- IFF_REPLACE_BYTE(xindex_ptr, xyuv_y, xyuv_u, xyuv_v, yuv_palette_s, *xold_data, *xnew_data, colorindexx_s ); \
-}
-
-#define IFF_REPLACE_LONG_SIMPLE(ptr_l, old_data_l, new_data_l, colorindexx_l ) { \
- uint8_t *xindex_ptr = (uint8_t *)ptr_l; \
- uint8_t *xold_data = (uint8_t *)old_data_l; \
- uint8_t *xnew_data = (uint8_t *)new_data_l; \
- IFF_REPLACE_BYTE_SIMPLE(xindex_ptr, *xold_data, *xnew_data, colorindexx_l ); \
- xindex_ptr += 8; \
- xold_data++; \
- xnew_data++; \
- IFF_REPLACE_BYTE_SIMPLE(xindex_ptr, *xold_data, *xnew_data, colorindexx_l ); \
- xindex_ptr += 8; \
- xold_data++; \
- xnew_data++; \
- IFF_REPLACE_BYTE_SIMPLE(xindex_ptr, *xold_data, *xnew_data, colorindexx_l ); \
- xindex_ptr += 8; \
- xold_data++; \
- xnew_data++; \
- IFF_REPLACE_BYTE_SIMPLE(xindex_ptr, *xold_data, *xnew_data, colorindexx_l ); \
-}
-
-#define IFF_REPLACE_LONG(ptr_l, yuvy_l, yuvu_l, yuvv_l, yuv_palette_l, old_data_l, new_data_l, colorindexx_l ) { \
- uint8_t *xindex_ptr = (uint8_t *)ptr_l; \
- uint8_t *xold_data = (uint8_t *)old_data_l; \
- uint8_t *xnew_data = (uint8_t *)new_data_l; \
- uint8_t *xyuv_y = yuvy_l; \
- uint8_t *xyuv_u = yuvu_l; \
- uint8_t *xyuv_v = yuvv_l; \
- IFF_REPLACE_BYTE(xindex_ptr, xyuv_y, xyuv_u, xyuv_v, yuv_palette_l, *xold_data, *xnew_data, colorindexx_l ); \
- xindex_ptr += 8; \
- xold_data++; \
- xnew_data++; \
- xyuv_y += 8; \
- xyuv_u += 8; \
- xyuv_v += 8; \
- IFF_REPLACE_BYTE(xindex_ptr, xyuv_y, xyuv_u, xyuv_v, yuv_palette_l, *xold_data, *xnew_data, colorindexx_l ); \
- xindex_ptr += 8; \
- xold_data++; \
- xnew_data++; \
- xyuv_y += 8; \
- xyuv_u += 8; \
- xyuv_v += 8; \
- IFF_REPLACE_BYTE(xindex_ptr, xyuv_y, xyuv_u, xyuv_v, yuv_palette_l, *xold_data, *xnew_data, colorindexx_l ); \
- xindex_ptr += 8; \
- xold_data++; \
- xnew_data++; \
- xyuv_y += 8; \
- xyuv_u += 8; \
- xyuv_v += 8; \
- IFF_REPLACE_BYTE(xindex_ptr, xyuv_y, xyuv_u, xyuv_v, yuv_palette_l, *xold_data, *xnew_data, colorindexx_l ); \
-}
-
-typedef struct {
- video_decoder_class_t decoder_class;
-} bitplane_class_t;
-
-typedef struct bitplane_decoder_s {
- video_decoder_t video_decoder; /* parent video decoder structure */
-
- bitplane_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; /* 0 = draw picture, 1 = skip it */
- int framenumber;
-
- unsigned char *buf; /* the accumulated buffer data */
- int bufsize; /* the maximum size of buf */
- int size; /* the current size of buf */
- int size_uk; /* size of unkompressed bitplane */
-
- int width; /* the width of a video frame */
- int height; /* the height of a video frame */
- int num_pixel; /* number pixel */
- double ratio; /* the width to height ratio */
- int bytes_per_pixel;
- int num_bitplanes;
- int camg_mode;
- int is_ham;
-
- unsigned char yuv_palette[256 * 4];
- unsigned char rgb_palette[256 * 4];
- yuv_planes_t yuv_planes;
- yuv_planes_t yuv_planes_hist;
-
- uint8_t *buf_uk; /* uncompressed buffer */
- uint8_t *buf_uk_hist; /* uncompressed buffer historic */
- uint8_t *index_buf; /* index buffer (for indexed pics) */
- uint8_t *index_buf_hist;/* index buffer historic */
-
-} bitplane_decoder_t;
-
-/* create a new buffer and decde a byterun1 decoded buffer into it */
-static uint8_t *bitplane_decode_byterun1 (uint8_t *compressed,
- int size_compressed,
- int size_uncompressed) {
-
- /* BytRun1 decompression */
- int pixel_ptr = 0;
- int i = 0;
- int j = 0;
-
- uint8_t *uncompressed = calloc(1, size_uncompressed );
-
- while ( i < size_compressed &&
- pixel_ptr < size_uncompressed ) {
- if( compressed[i] <= 127 ) {
- j = compressed[i++];
- if( (i+j) > size_compressed ) {
- free(uncompressed);
- return NULL;
- }
- for( ; (j >= 0) && (pixel_ptr < size_uncompressed); j-- ) {
- uncompressed[pixel_ptr++] = compressed[i++];
- }
- } else if ( compressed[i] > 128 ) {
- j = 256 - compressed[i++];
- if( i >= size_compressed ) {
- free(uncompressed);
- return NULL;
- }
- for( ; (j >= 0) && (pixel_ptr < size_uncompressed); j-- ) {
- uncompressed[pixel_ptr++] = compressed[i];
- }
- i++;
- }
- }
- return uncompressed;
-}
-
-/* create a new buffer with "normal" index or rgb numbers out of a bitplane */
-static void bitplane_decode_bitplane (uint8_t *bitplane_buffer,
- uint8_t *index_buf,
- int width,
- int height,
- int num_bitplanes,
- int bytes_per_pixel ) {
-
- int rowsize = width / 8;
- int pixel_ptr = 0;
- int row_ptr = 0;
- int palette_index = 0;
- int i = 0;
- int j = 0;
- int row_i = 0;
- int row_j = 0;
- int palette_offset = 0;
- int palette_index_rowsize = 0;
- uint8_t color = 0;
- uint8_t data = 0;
- int bytes_per_pixel_8 = bytes_per_pixel * 8;
- int rowsize_num_bitplanes = rowsize * num_bitplanes;
- int width_bytes_per_pixel = width * bytes_per_pixel;
-
- for (i = 0; i < (height * width_bytes_per_pixel); index_buf[i++] = 0);
-
- /* decode Bitplanes to RGB/Index Numbers */
- for (row_ptr = 0; row_ptr < height; row_ptr++) {
-
- row_i = row_ptr * width_bytes_per_pixel;
- row_j = row_ptr * rowsize_num_bitplanes;
-
- for (palette_index = 0; palette_index < num_bitplanes; palette_index++) {
-
- palette_offset = ((palette_index > 15) ? 2 : (palette_index > 7) ? 1 : 0);
- color = bitplainoffeset[palette_index];
- palette_index_rowsize = palette_index * rowsize;
-
- for (pixel_ptr = 0; pixel_ptr < rowsize; pixel_ptr++) {
- i = row_i +
- (pixel_ptr * bytes_per_pixel_8) +
- palette_offset;
- j = row_j + palette_index_rowsize + pixel_ptr;
-
- data = bitplane_buffer[j];
-
- index_buf[i] += ((data & 0x80) ? color : 0);
- i += bytes_per_pixel;
- index_buf[i] += ((data & 0x40) ? color : 0);
- i += bytes_per_pixel;
- index_buf[i] += ((data & 0x20) ? color : 0);
- i += bytes_per_pixel;
- index_buf[i] += ((data & 0x10) ? color : 0);
- i += bytes_per_pixel;
- index_buf[i] += ((data & 0x08) ? color : 0);
- i += bytes_per_pixel;
- index_buf[i] += ((data & 0x04) ? color : 0);
- i += bytes_per_pixel;
- index_buf[i] += ((data & 0x02) ? color : 0);
- i += bytes_per_pixel;
- index_buf[i] += ((data & 0x01) ? color : 0);
- }
- }
- }
-}
-
-/* create Buffer decode HAM6 and HAM8 to YUV color */
-static void bitplane_decode_ham (uint8_t *ham_buffer,
- yuv_planes_t *yuv_planes,
- int width,
- int height,
- int num_bitplanes,
- int bytes_per_pixel,
- unsigned char *rgb_palette ) {
-
- uint8_t *ham_buffer_work = ham_buffer;
- uint8_t *ham_buffer_end = &ham_buffer[(width * height)];
- uint8_t *yuv_ptr_y = yuv_planes->y;
- uint8_t *yuv_ptr_u = yuv_planes->u;
- uint8_t *yuv_ptr_v = yuv_planes->v;
- int i = 0;
- int j = 0;
- uint8_t r = 0;
- uint8_t g = 0;
- uint8_t b = 0;
- /* position of special HAM-Bits differs in HAM6 and HAM8, detect them */
- int hambits = num_bitplanes > 6 ? 6 : 4;
- /* the other bits contain the real data, dreate a mask out of it */
- int maskbits = 8 - hambits;
- int mask = ( 1 << hambits ) - 1;
-
- for(; ham_buffer_work < ham_buffer_end; j = *ham_buffer_work++) {
- i = (j & mask);
- switch ( j >> hambits ) {
- case HAMBITS_CMAP:
- /* Take colors from palette */
- r = rgb_palette[i * 4 + 0];
- g = rgb_palette[i * 4 + 1];
- b = rgb_palette[i * 4 + 2];
- break;
- case HAMBITS_BLUE:
- /* keep red and green and modify blue */
- b = i << maskbits;
- b |= b >> hambits;
- break;
- case HAMBITS_RED:
- /* keep green and blue and modify red */
- r = i << maskbits;
- r |= r >> hambits;
- break;
- case HAMBITS_GREEN:
- /* keep red and blue and modify green */
- g = i << maskbits;
- g |= g >> hambits;
- break;
- default:
- break;
- }
- *yuv_ptr_y++ = COMPUTE_Y(r, g, b);
- *yuv_ptr_u++ = COMPUTE_U(r, g, b);
- *yuv_ptr_v++ = COMPUTE_V(r, g, b);
- }
-}
-
-/* decoding method 3 */
-static void bitplane_sdelta_opt_3 (bitplane_decoder_t *this) {
-
- uint32_t rowsize = this->width / 16;
- uint32_t rowsize_all_planes = rowsize * this->num_bitplanes;
-
- uint32_t palette_index = 0;
- uint32_t *deltadata = (uint32_t *)this->buf;
- uint16_t *ptr = NULL;
- uint16_t *planeptr = NULL;
- uint16_t *picture_end = (uint16_t *)(&this->buf_uk[(rowsize_all_planes * 2 * this->height)]);
- uint16_t *data = NULL;
- uint16_t *data_end = (uint16_t *)(&this->buf[this->size]);
- uint16_t *rowworkptr = NULL;
- int16_t s = 0;
- int16_t size = 0;
- uint32_t pixel_ptr_bit = 0;
- uint32_t row_ptr = 0;
- uint32_t yuv_index = 0;
-
- /* Repeat for each plane */
- for(palette_index = 0; palette_index < this->num_bitplanes; palette_index++) {
-
- planeptr = (uint16_t *)(&this->buf_uk[(palette_index * rowsize * 2)]);
- /* data starts at beginn of delta-Buffer + offset of the first */
- /* 32 Bit long word in the buffer. The buffer starts with 8 */
- /* of this Offset, for every bitplane (max 8) one */
- data = (uint16_t *)(&this->buf[_X_BE_32(&deltadata[palette_index])]);
- if( data != (uint16_t *)this->buf ) {
- /* This 8 Pointers are followd by another 8 */
- ptr = (uint16_t *)(&this->buf[_X_BE_32(&deltadata[(palette_index+8)])]);
-
- /* in this case, I think big/little endian is not important ;-) */
- while( *data != 0xFFFF) {
- row_ptr = 0;
- size = _X_BE_16(data);
- data++;
- if( size >= 0 ) {
- rowworkptr = planeptr + size;
- pixel_ptr_bit = size * 16;
- if( this->is_ham ) {
- IFF_REPLACE_SHORT_SIMPLE(&this->index_buf[pixel_ptr_bit],
- rowworkptr, data, bitplainoffeset[palette_index] );
- } else {
- IFF_REPLACE_SHORT( &this->index_buf[pixel_ptr_bit],
- &this->yuv_planes.y[pixel_ptr_bit], &this->yuv_planes.u[pixel_ptr_bit],
- &this->yuv_planes.v[pixel_ptr_bit], this->yuv_palette,
- rowworkptr, data, bitplainoffeset[palette_index] );
- }
- data++;
- } else {
- size = 0 - size + 2;
- rowworkptr = planeptr + size;
- pixel_ptr_bit = size * 16;
- s = _X_BE_16(data);
- data++;
- while( s--) {
- if( this->is_ham ) {
- IFF_REPLACE_SHORT_SIMPLE(&this->index_buf[pixel_ptr_bit],
- rowworkptr, data, bitplainoffeset[palette_index] );
- } else {
- IFF_REPLACE_SHORT( &this->index_buf[pixel_ptr_bit],
- &this->yuv_planes.y[pixel_ptr_bit], &this->yuv_planes.u[pixel_ptr_bit],
- &this->yuv_planes.v[pixel_ptr_bit], this->yuv_palette,
- rowworkptr, data, bitplainoffeset[palette_index] );
- }
- rowworkptr++;
- data++;
- }
- }
-
-
-
-
- size = _X_BE_16(ptr);
- ptr++;
- if (size < 0) {
- for (s = size; s < 0; s++) {
- if (data > data_end || rowworkptr > picture_end)
- return;
- yuv_index = ((row_ptr * this->width) + pixel_ptr_bit);
- if( this->is_ham ) {
- IFF_REPLACE_SHORT_SIMPLE(&this->index_buf[yuv_index],
- rowworkptr, data, bitplainoffeset[palette_index] );
- } else {
- IFF_REPLACE_SHORT( &this->index_buf[yuv_index],
- &this->yuv_planes.y[yuv_index], &this->yuv_planes.u[yuv_index],
- &this->yuv_planes.v[yuv_index], this->yuv_palette,
- rowworkptr, data, bitplainoffeset[palette_index] );
- }
- rowworkptr += rowsize_all_planes;
- row_ptr++;
- }
- data++;
- }
- else {
- for (s = 0; s < size; s++) {
- if (data > data_end || rowworkptr > picture_end)
- return;
- yuv_index = ((row_ptr * this->width) + pixel_ptr_bit);
- if( this->is_ham ) {
- IFF_REPLACE_SHORT_SIMPLE(&this->index_buf[yuv_index],
- rowworkptr, data, bitplainoffeset[palette_index] );
- } else {
- IFF_REPLACE_SHORT( &this->index_buf[yuv_index],
- &this->yuv_planes.y[yuv_index], &this->yuv_planes.u[yuv_index],
- &this->yuv_planes.v[yuv_index], this->yuv_palette,
- rowworkptr, data, bitplainoffeset[palette_index] );
- }
- data++;
- rowworkptr += rowsize_all_planes;
- row_ptr++;
- }
- }
- }
- }
- }
-}
-
-/* decoding method 4 */
-static void bitplane_set_dlta_short (bitplane_decoder_t *this) {
-
- uint32_t rowsize = this->width / 16;
- uint32_t rowsize_all_planes = rowsize * this->num_bitplanes;
-
- uint32_t palette_index = 0;
- uint32_t *deltadata = (uint32_t *)this->buf;
- uint16_t *ptr = NULL;
- uint16_t *planeptr = NULL;
- uint16_t *picture_end = (uint16_t *)(&this->buf_uk[(rowsize_all_planes * 2 * this->height)]);
- uint16_t *data = NULL;
- uint16_t *data_end = (uint16_t *)(&this->buf[this->size]);
- uint16_t *rowworkptr = NULL;
- int16_t s = 0;
- int16_t size = 0;
- uint16_t pixel_ptr = 0;
- uint32_t pixel_ptr_bit = 0;
- uint32_t row_ptr = 0;
- uint32_t yuv_index = 0;
-
- /* Repeat for each plane */
- for(palette_index = 0; palette_index < this->num_bitplanes; palette_index++) {
-
- planeptr = (uint16_t *)(&this->buf_uk[(palette_index * rowsize * 2)]);
- /* data starts at beginn of delta-Buffer + offset of the first */
- /* 32 Bit long word in the buffer. The buffer starts with 8 */
- /* of this Offset, for every bitplane (max 8) one */
- data = (uint16_t *)(&this->buf[_X_BE_32(&deltadata[palette_index])]);
- if( data != (uint16_t *)this->buf ) {
- /* This 8 Pointers are followd by another 8 */
- ptr = (uint16_t *)(&this->buf[_X_BE_32(&deltadata[(palette_index+8)])]);
-
- /* in this case, I think big/little endian is not important ;-) */
- while( *ptr != 0xFFFF) {
- pixel_ptr = _X_BE_16(ptr);
- pixel_ptr_bit = pixel_ptr * 16;
- row_ptr = 0;
- rowworkptr = planeptr + pixel_ptr;
- ptr++;
- size = _X_BE_16(ptr);
- ptr++;
- if (size < 0) {
- for (s = size; s < 0; s++) {
- if (data > data_end || rowworkptr > picture_end)
- return;
- yuv_index = ((row_ptr * this->width) + pixel_ptr_bit);
- if( this->is_ham ) {
- IFF_REPLACE_SHORT_SIMPLE(&this->index_buf[yuv_index],
- rowworkptr, data, bitplainoffeset[palette_index] );
- } else {
- IFF_REPLACE_SHORT( &this->index_buf[yuv_index],
- &this->yuv_planes.y[yuv_index], &this->yuv_planes.u[yuv_index],
- &this->yuv_planes.v[yuv_index], this->yuv_palette,
- rowworkptr, data, bitplainoffeset[palette_index] );
- }
- rowworkptr += rowsize_all_planes;
- row_ptr++;
- }
- data++;
- } else {
- for (s = 0; s < size; s++) {
- if (data > data_end || rowworkptr > picture_end)
- return;
- yuv_index = ((row_ptr * this->width) + pixel_ptr_bit);
- if( this->is_ham ) {
- IFF_REPLACE_SHORT_SIMPLE(&this->index_buf[yuv_index],
- rowworkptr, data, bitplainoffeset[palette_index] );
- } else {
- IFF_REPLACE_SHORT( &this->index_buf[yuv_index],
- &this->yuv_planes.y[yuv_index], &this->yuv_planes.u[yuv_index],
- &this->yuv_planes.v[yuv_index], this->yuv_palette,
- rowworkptr, data, bitplainoffeset[palette_index] );
- }
- data++;
- rowworkptr += rowsize_all_planes;
- row_ptr++;
- }
- }
- }
- }
- }
-}
-
-/* decoding method 5 */
-static void bitplane_dlta_5 (bitplane_decoder_t *this) {
-
- uint32_t rowsize = this->width / 8;
- uint32_t rowsize_all_planes = rowsize * this->num_bitplanes;
-
- uint32_t yuv_index = 0;
- uint32_t delta_offset = 0;
- uint32_t palette_index = 0;
- uint32_t pixel_ptr = 0;
- uint32_t pixel_ptr_bit = 0;
- uint32_t row_ptr = 0;
- uint32_t *deltadata = (uint32_t *)this->buf;
- uint8_t *planeptr = NULL;
- uint8_t *rowworkptr = NULL;
- uint8_t *picture_end = this->buf_uk + (rowsize_all_planes * this->height);
- uint8_t *data = NULL;
- uint8_t *data_end = this->buf + this->size;
- uint8_t op_count = 0;
- uint8_t op = 0;
- uint8_t count = 0;
-
- /* Repeat for each plane */
- for(palette_index = 0; palette_index < this->num_bitplanes; palette_index++) {
-
- planeptr = &this->buf_uk[(palette_index * rowsize)];
- /* data starts at beginn of delta-Buffer + offset of the first */
- /* 32 Bit long word in the buffer. The buffer starts with 8 */
- /* of this Offset, for every bitplane (max 8) one */
- delta_offset = _X_BE_32(&deltadata[palette_index]);
-
- if (delta_offset > 0) {
- data = this->buf + delta_offset;
- for( pixel_ptr = 0; pixel_ptr < rowsize; pixel_ptr++) {
- rowworkptr = planeptr + pixel_ptr;
- pixel_ptr_bit = pixel_ptr * 8;
- row_ptr = 0;
- /* execute ops */
- for( op_count = *data++; op_count; op_count--) {
- op = *data++;
- if (op & 0x80) {
- /* Uniq ops */
- count = op & 0x7f; /* get count */
- while(count--) {
- if (data > data_end || rowworkptr > picture_end)
- return;
- yuv_index = ((row_ptr * this->width) + pixel_ptr_bit);
- if( this->is_ham ) {
- IFF_REPLACE_BYTE_SIMPLE(&this->index_buf[yuv_index],
- *rowworkptr, *data, bitplainoffeset[palette_index] );
- } else {
- IFF_REPLACE_BYTE( &this->index_buf[yuv_index],
- &this->yuv_planes.y[yuv_index], &this->yuv_planes.u[yuv_index],
- &this->yuv_planes.v[yuv_index], this->yuv_palette,
- *rowworkptr, *data, bitplainoffeset[palette_index] );
- }
- data++;
- rowworkptr += rowsize_all_planes;
- row_ptr++;
- }
- } else {
- if (op == 0) {
- /* Same ops */
- count = *data++;
- while(count--) {
- if (data > data_end || rowworkptr > picture_end)
- return;
- yuv_index = ((row_ptr * this->width) + pixel_ptr_bit);
- if( this->is_ham ) {
- IFF_REPLACE_BYTE_SIMPLE(&this->index_buf[yuv_index],
- *rowworkptr, *data, bitplainoffeset[palette_index] );
- } else {
- IFF_REPLACE_BYTE( &this->index_buf[yuv_index],
- &this->yuv_planes.y[yuv_index], &this->yuv_planes.u[yuv_index],
- &this->yuv_planes.v[yuv_index], this->yuv_palette,
- *rowworkptr, *data, bitplainoffeset[palette_index] );
- }
- rowworkptr += rowsize_all_planes;
- row_ptr++;
- }
- data++;
- } else {
- /* Skip ops */
- rowworkptr += (rowsize_all_planes * op);
- row_ptr += op;
- }
- }
- }
- }
- }
- }
-}
-
-/* decoding method 7 (short version) */
-static void bitplane_dlta_7_short (bitplane_decoder_t *this) {
-
- uint32_t rowsize = this->width / 16;
- uint32_t rowsize_all_planes = rowsize * this->num_bitplanes;
-
- uint32_t yuv_index = 0;
- uint32_t opcode_offset = 0;
- uint32_t data_offset = 0;
- uint32_t palette_index = 0;
- uint32_t pixel_ptr = 0;
- uint32_t pixel_ptr_bit = 0;
- uint32_t row_ptr = 0;
- uint32_t *deltadata = (uint32_t *)this->buf;
- uint8_t *planeptr = NULL;
- uint16_t *rowworkptr = NULL;
- uint16_t *picture_end = (uint16_t *)(&this->buf_uk[(rowsize_all_planes * 2 * this->height)]);
- uint16_t *data = NULL;
- uint16_t *data_end = (uint16_t *)(&this->buf[this->size]);
- uint8_t *op_ptr = NULL;
- uint8_t op_count = 0;
- uint8_t op = 0;
- uint8_t count = 0;
-
- /* Repeat for each plane */
- for(palette_index = 0; palette_index < this->num_bitplanes; palette_index++) {
-
- planeptr = &this->buf_uk[(palette_index * rowsize * 2)];
- /* find opcode and data offset (up to 8 pointers, one for every bitplane */
- opcode_offset = _X_BE_32(&deltadata[palette_index]);
- data_offset = _X_BE_32(&deltadata[palette_index + 8]);
-
- if (opcode_offset > 0 && data_offset > 0) {
- data = (uint16_t *)(&this->buf[data_offset]);
- op_ptr = this->buf + opcode_offset;
- for( pixel_ptr = 0; pixel_ptr < rowsize; pixel_ptr++) {
- rowworkptr = (uint16_t *)(&planeptr[pixel_ptr * 2]);
- pixel_ptr_bit = pixel_ptr * 16;
- row_ptr = 0;
- /* execute ops */
- for( op_count = *op_ptr++; op_count; op_count--) {
- op = *op_ptr++;
- if (op & 0x80) {
- /* Uniq ops */
- count = op & 0x7f; /* get count */
- while(count--) {
- if (data > data_end || rowworkptr > picture_end)
- return;
- yuv_index = ((row_ptr * this->width) + pixel_ptr_bit);
- if( this->is_ham ) {
- IFF_REPLACE_SHORT_SIMPLE(&this->index_buf[yuv_index],
- rowworkptr, data, bitplainoffeset[palette_index] );
- } else {
- IFF_REPLACE_SHORT( &this->index_buf[yuv_index],
- &this->yuv_planes.y[yuv_index], &this->yuv_planes.u[yuv_index],
- &this->yuv_planes.v[yuv_index], this->yuv_palette,
- rowworkptr, data, bitplainoffeset[palette_index] );
- }
- data++;
- rowworkptr += rowsize_all_planes;
- row_ptr++;
- }
- } else {
- if (op == 0) {
- /* Same ops */
- count = *op_ptr++;
- while(count--) {
- if (data > data_end || rowworkptr > picture_end)
- return;
- yuv_index = ((row_ptr * this->width) + pixel_ptr_bit);
- if( this->is_ham ) {
- IFF_REPLACE_SHORT_SIMPLE(&this->index_buf[yuv_index],
- rowworkptr, data, bitplainoffeset[palette_index] );
- } else {
- IFF_REPLACE_SHORT( &this->index_buf[yuv_index],
- &this->yuv_planes.y[yuv_index], &this->yuv_planes.u[yuv_index],
- &this->yuv_planes.v[yuv_index], this->yuv_palette,
- rowworkptr, data, bitplainoffeset[palette_index] );
- }
- rowworkptr += rowsize_all_planes;
- row_ptr++;
- }
- data++;
- } else {
- /* Skip ops */
- rowworkptr += (rowsize_all_planes * op);
- row_ptr += op;
- }
- }
- }
- }
- }
- }
-}
-
-/* decoding method 7 (long version) */
-static void bitplane_dlta_7_long (bitplane_decoder_t *this) {
-
- uint32_t rowsize = this->width / 32;
- uint32_t rowsize_all_planes = rowsize * this->num_bitplanes;
-
- uint32_t yuv_index = 0;
- uint32_t opcode_offset = 0;
- uint32_t data_offset = 0;
- uint32_t palette_index = 0;
- uint32_t pixel_ptr = 0;
- uint32_t pixel_ptr_bit = 0;
- uint32_t row_ptr = 0;
- uint32_t *deltadata = (uint32_t *)this->buf;
- uint8_t *planeptr = NULL;
- uint32_t *rowworkptr = NULL;
- uint32_t *picture_end = (uint32_t *)(&this->buf_uk[(rowsize_all_planes * 4 * this->height)]);
- uint32_t *data = NULL;
- uint32_t *data_end = (uint32_t *)(&this->buf[this->size]);
- uint8_t *op_ptr = NULL;
- uint8_t op_count = 0;
- uint8_t op = 0;
- uint8_t count = 0;
-
- /* Repeat for each plane */
- for(palette_index = 0; palette_index < this->num_bitplanes; palette_index++) {
- planeptr = &this->buf_uk[(palette_index * rowsize * 4)];
- /* find opcode and data offset (up to 8 pointers, one for every bitplane */
- opcode_offset = _X_BE_32(&deltadata[palette_index]);
- data_offset = _X_BE_32(&deltadata[palette_index + 8]);
-
- if (opcode_offset > 0 && data_offset > 0) {
- data = (uint32_t *)(&this->buf[data_offset]);
- op_ptr = this->buf + opcode_offset;
- for( pixel_ptr = 0; pixel_ptr < rowsize; pixel_ptr++) {
- rowworkptr = (uint32_t *)(&planeptr[pixel_ptr * 4]);
- pixel_ptr_bit = pixel_ptr * 32;
- row_ptr = 0;
- /* execute ops */
- for( op_count = *op_ptr++; op_count; op_count--) {
- op = *op_ptr++;
- if (op & 0x80) {
- /* Uniq ops */
- count = op & 0x7f; /* get count */
- while(count--) {
- if (data > data_end || rowworkptr > picture_end)
- return;
- yuv_index = ((row_ptr * this->width) + pixel_ptr_bit);
- if( this->is_ham ) {
- IFF_REPLACE_LONG_SIMPLE(&this->index_buf[yuv_index],
- rowworkptr, data, bitplainoffeset[palette_index] );
- } else {
- IFF_REPLACE_LONG( &this->index_buf[yuv_index],
- &this->yuv_planes.y[yuv_index], &this->yuv_planes.u[yuv_index],
- &this->yuv_planes.v[yuv_index], this->yuv_palette,
- rowworkptr, data, bitplainoffeset[palette_index] );
- }
- data++;
- rowworkptr += rowsize_all_planes;
- row_ptr++;
- }
- } else {
- if (op == 0) {
- /* Same ops */
- count = *op_ptr++;
- while(count--) {
- if (data > data_end || rowworkptr > picture_end)
- return;
- yuv_index = ((row_ptr * this->width) + pixel_ptr_bit);
- if( this->is_ham ) {
- IFF_REPLACE_LONG_SIMPLE(&this->index_buf[yuv_index],
- rowworkptr, data, bitplainoffeset[palette_index] );
- } else {
- IFF_REPLACE_LONG( &this->index_buf[yuv_index],
- &this->yuv_planes.y[yuv_index], &this->yuv_planes.u[yuv_index],
- &this->yuv_planes.v[yuv_index], this->yuv_palette,
- rowworkptr, data, bitplainoffeset[palette_index] );
- }
- rowworkptr += rowsize_all_planes;
- row_ptr++;
- }
- data++;
- } else {
- /* Skip ops */
- rowworkptr += (rowsize_all_planes * op);
- row_ptr += op;
- }
- }
- }
- }
- }
- }
-}
-
-/* decoding method 8 short */
-static void bitplane_dlta_8_short (bitplane_decoder_t *this) {
-
- uint32_t rowsize = this->width / 16;
- uint32_t rowsize_all_planes = rowsize * this->num_bitplanes;
-
- uint32_t yuv_index = 0;
- uint32_t delta_offset = 0;
- uint32_t palette_index = 0;
- uint32_t pixel_ptr = 0;
- uint32_t row_ptr = 0;
- uint32_t pixel_ptr_bit = 0;
- uint32_t *deltadata = (uint32_t *)this->buf;
- uint16_t *planeptr = NULL;
- uint16_t *rowworkptr = NULL;
- uint16_t *picture_end = (uint16_t *)(&this->buf_uk[(rowsize_all_planes * 2 * this->height)]);
- uint16_t *data = NULL;
- uint16_t *data_end = (uint16_t *)(&this->buf[this->size]);
- uint16_t op_count = 0;
- uint16_t op = 0;
- uint16_t count = 0;
-
- /* Repeat for each plane */
- for(palette_index = 0; palette_index < this->num_bitplanes; palette_index++) {
-
- planeptr = (uint16_t *)(&this->buf_uk[(palette_index * rowsize * 2)]);
- /* data starts at beginn of delta-Buffer + offset of the first */
- /* 32 Bit long word in the buffer. The buffer starts with 8 */
- /* of this Offset, for every bitplane (max 8) one */
- delta_offset = _X_BE_32(&deltadata[palette_index]);
-
- if (delta_offset > 0) {
- data = (uint16_t *)(&this->buf[delta_offset]);
- for( pixel_ptr = 0; pixel_ptr < rowsize; pixel_ptr++) {
- rowworkptr = planeptr + pixel_ptr;
- pixel_ptr_bit = pixel_ptr * 16;
- row_ptr = 0;
- /* execute ops */
- op_count = _X_BE_16(data);
- data++;
- for( ; op_count; op_count--) {
- op = _X_BE_16(data);
- data++;
- if (op & 0x8000) {
- /* Uniq ops */
- count = op & 0x7fff; /* get count */
- while(count--) {
- if (data > data_end || rowworkptr > picture_end)
- return;
- yuv_index = ((row_ptr * this->width) + pixel_ptr_bit);
- if( this->is_ham ) {
- IFF_REPLACE_SHORT_SIMPLE(&this->index_buf[yuv_index],
- rowworkptr, data, bitplainoffeset[palette_index] );
- } else {
- IFF_REPLACE_SHORT( &this->index_buf[yuv_index],
- &this->yuv_planes.y[yuv_index], &this->yuv_planes.u[yuv_index],
- &this->yuv_planes.v[yuv_index], this->yuv_palette,
- rowworkptr, data, bitplainoffeset[palette_index] );
- }
- data++;
- rowworkptr += rowsize_all_planes;
- row_ptr++;
- }
- } else {
- if (op == 0) {
- /* Same ops */
- count = _X_BE_16(data);
- data++;
- while(count--) {
- if (data > data_end || rowworkptr > picture_end)
- return;
- yuv_index = ((row_ptr * this->width) + pixel_ptr_bit);
- if( this->is_ham ) {
- IFF_REPLACE_SHORT_SIMPLE(&this->index_buf[yuv_index],
- rowworkptr, data, bitplainoffeset[palette_index] );
- } else {
- IFF_REPLACE_SHORT( &this->index_buf[yuv_index],
- &this->yuv_planes.y[yuv_index], &this->yuv_planes.u[yuv_index],
- &this->yuv_planes.v[yuv_index], this->yuv_palette,
- rowworkptr, data, bitplainoffeset[palette_index] );
- }
- rowworkptr += rowsize_all_planes;
- row_ptr++;
- }
- data++;
- } else {
- /* Skip ops */
- rowworkptr += (rowsize_all_planes * op);
- row_ptr += op;
- }
- }
- }
- }
- }
- }
-}
-
-/* decoding method 8 long */
-static void bitplane_dlta_8_long (bitplane_decoder_t *this) {
-
- uint32_t rowsize = this->width / 32;
- uint32_t rowsize_all_planes = rowsize * this->num_bitplanes;
-
- uint32_t yuv_index = 0;
- uint32_t delta_offset = 0;
- uint32_t palette_index = 0;
- uint32_t pixel_ptr = 0;
- uint32_t pixel_ptr_bit = 0;
- uint32_t row_ptr = 0;
- uint32_t *deltadata = (uint32_t *)this->buf;
- uint32_t *planeptr = NULL;
- uint32_t *rowworkptr = NULL;
- uint32_t *picture_end = (uint32_t *)(&this->buf_uk[(rowsize_all_planes * 4 * this->height)]);
- uint32_t *data = NULL;
- uint32_t *data_end = (uint32_t *)(&this->buf[this->size]);
- uint32_t op_count = 0;
- uint32_t op = 0;
- uint32_t count = 0;
-
- /* Repeat for each plane */
- for(palette_index = 0; palette_index < this->num_bitplanes; palette_index++) {
-
- planeptr = (uint32_t *)(&this->buf_uk[(palette_index * rowsize * 4)]);
- /* data starts at beginn of delta-Buffer + offset of the first */
- /* 32 Bit long word in the buffer. The buffer starts with 8 */
- /* of this Offset, for every bitplane (max 8) one */
- delta_offset = _X_BE_32(&deltadata[palette_index]);
-
- if (delta_offset > 0) {
- data = (uint32_t *)(&this->buf[delta_offset]);
- for( pixel_ptr = 0; pixel_ptr < rowsize; pixel_ptr++) {
- rowworkptr = planeptr + pixel_ptr;
- pixel_ptr_bit = pixel_ptr * 32;
- row_ptr = 0;
- /* execute ops */
- op_count = _X_BE_32(data);
- data++;
- for( ; op_count; op_count--) {
- op = _X_BE_32(data);
- data++;
- if (op & 0x80000000) {
- /* Uniq ops */
- count = op & 0x7fffffff; /* get count */
- while(count--) {
- if (data <= data_end || rowworkptr <= picture_end) {
- yuv_index = ((row_ptr * this->width) + pixel_ptr_bit);
- if( this->is_ham ) {
- IFF_REPLACE_LONG_SIMPLE(&this->index_buf[yuv_index],
- rowworkptr, data, bitplainoffeset[palette_index] );
- } else {
- IFF_REPLACE_LONG( &this->index_buf[((row_ptr * this->width) + pixel_ptr_bit)],
- &this->yuv_planes.y[yuv_index], &this->yuv_planes.u[yuv_index],
- &this->yuv_planes.v[yuv_index], this->yuv_palette,
- rowworkptr, data, bitplainoffeset[palette_index] );
- }
- }
- data++;
- rowworkptr += rowsize_all_planes;
- row_ptr++;
- }
- } else {
- if (op == 0) {
- /* Same ops */
- count = _X_BE_32(data);
- data++;
- while(count--) {
- if (data <= data_end && rowworkptr <= picture_end) {
- yuv_index = ((row_ptr * this->width) + pixel_ptr_bit);
- if( this->is_ham ) {
- IFF_REPLACE_LONG_SIMPLE(&this->index_buf[yuv_index],
- rowworkptr, data, bitplainoffeset[palette_index] );
- } else {
- IFF_REPLACE_LONG( &this->index_buf[yuv_index],
- &this->yuv_planes.y[yuv_index], &this->yuv_planes.u[yuv_index],
- &this->yuv_planes.v[yuv_index], this->yuv_palette,
- rowworkptr, data, bitplainoffeset[palette_index] );
- }
- }
- rowworkptr += rowsize_all_planes;
- row_ptr++;
- }
- data++;
- } else {
- /* Skip ops */
- rowworkptr += (rowsize_all_planes * op);
- row_ptr += op;
- }
- }
- }
- }
- }
- }
-/* bitplane_decode_bitplane(this->buf_uk, this->index_buf, this->width, this->height, this->num_bitplanes, 1);*/
-}
-
-static void bitplane_decode_data (video_decoder_t *this_gen,
- buf_element_t *buf) {
-
- bitplane_decoder_t *this = (bitplane_decoder_t *) this_gen;
- xine_bmiheader *bih = 0;
- palette_entry_t *palette = 0;
- AnimHeader *anhd = NULL;
- int i = 0;
- int j = 0;
- int buf_ptr = 0;
- unsigned char r = 0;
- unsigned char g = 0;
- unsigned char b = 0;
- uint8_t *buf_exchange = NULL;
-
- vo_frame_t *img = 0; /* 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);
- this->rgb_palette[i * 4 + 0] = palette[i].r;
- this->rgb_palette[i * 4 + 1] = palette[i].g;
- this->rgb_palette[i * 4 + 2] = palette[i].b;
- }
-
- /* EHB Pictures not allways contain all 64 colors, sometimes only */
- /* the first 32 are included and sometimes all 64 colors are provide,*/
- /* but second 32 are only stupid dirt, so recalculate them */
- if (((this->num_bitplanes == 6) &&
- (buf->decoder_info[2] == 32)) ||
- (this->camg_mode & CAMG_EHB)) {
- for (i = 32; i < 64; i++) {
- this->rgb_palette[i * 4 + 0] = palette[(i-32)].r / 2;
- this->rgb_palette[i * 4 + 1] = palette[(i-32)].g / 2;
- this->rgb_palette[i * 4 + 2] = palette[(i-32)].b / 2;
- this->yuv_palette[i * 4 + 0] =
- COMPUTE_Y(this->rgb_palette[i*4+0], this->rgb_palette[i*4+1], this->rgb_palette[i*4+2]);
- this->yuv_palette[i * 4 + 1] =
- COMPUTE_U(this->rgb_palette[i*4+0], this->rgb_palette[i*4+1], this->rgb_palette[i*4+2]);
- this->yuv_palette[i * 4 + 2] =
- COMPUTE_V(this->rgb_palette[i*4+0], this->rgb_palette[i*4+1], this->rgb_palette[i*4+2]);
- }
- }
-
- return;
- }
-
- if (buf->decoder_flags & BUF_FLAG_STDHEADER) { /* need to initialize */
- (this->stream->video_out->open) (this->stream->video_out, this->stream);
-
- bih = (xine_bmiheader *) buf->content;
- this->width = (bih->biWidth + 15) & ~0x0f;
- this->height = bih->biHeight;
- this->num_pixel = this->width * this->height;
- this->ratio = (double)this->width/(double)this->height;
- this->video_step = buf->decoder_info[1];
- /* Palette based Formates use up to 8 Bit per pixel, always use 8 Bit if less */
- this->bytes_per_pixel = (bih->biBitCount + 1) / 8;
- if( this->bytes_per_pixel < 1 )
- this->bytes_per_pixel = 1;
-
- /* New Buffer for indexes (palette based formats) */
- this->index_buf = calloc( this->num_pixel, this->bytes_per_pixel );
- this->index_buf_hist = calloc( this->num_pixel, this->bytes_per_pixel );
-
- this->num_bitplanes = bih->biPlanes;
- this->camg_mode = bih->biCompression;
- if( this->camg_mode & CAMG_HAM )
- this->is_ham = 1;
- else
- this->is_ham = 0;
-
- if( buf->decoder_info[2] != buf->decoder_info[3] &&
- buf->decoder_info[3] > 0 ) {
- this->ratio *= buf->decoder_info[2];
- this->ratio /= buf->decoder_info[3];
- }
-
- if( (bih->biCompression & CAMG_HIRES) &&
- !(bih->biCompression & CAMG_LACE) ) {
- if( (buf->decoder_info[2] * 16) > (buf->decoder_info[3] * 10) )
- this->ratio /= 2.0;
- }
-
- if( !(bih->biCompression & CAMG_HIRES) &&
- (bih->biCompression & CAMG_LACE) ) {
- if( (buf->decoder_info[2] * 10) < (buf->decoder_info[3] * 16) )
- this->ratio *= 2.0;
- }
-
- if (this->buf)
- free (this->buf);
- this->bufsize = VIDEOBUFSIZE;
- this->buf = calloc(1, this->bufsize);
- this->size = 0;
- this->framenumber = 0;
-
- init_yuv_planes(&this->yuv_planes, this->width, this->height);
- init_yuv_planes(&this->yuv_planes_hist, this->width, this->height);
-
- (this->stream->video_out->open) (this->stream->video_out, this->stream);
- this->decoder_ok = 1;
-
- /* load the stream/meta info */
- switch( buf->type ) {
- case BUF_VIDEO_BITPLANE:
- _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Uncompressed bitplane");
- break;
- case BUF_VIDEO_BITPLANE_BR1:
- _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "ByteRun1 bitplane");
- break;
- default:
- _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Unknown bitplane");
- break;
- }
-
- return;
- } else if (this->decoder_ok) {
-
- this->skipframes = 0;
- this->framenumber++;
- 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_FRAMERATE)
- this->video_step = buf->decoder_info[0];
-
- 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;
- anhd = (AnimHeader *)(buf->decoder_info_ptr[0]);
-
- if( (this->buf_uk == NULL) ||
- (anhd == NULL) ||
- (anhd->operation == IFF_ANHD_ILBM) ) {
-
- /* iterate through each row */
- buf_ptr = 0;
- this->size_uk = (((this->num_pixel) / 8) * this->num_bitplanes);
-
- if( this->buf_uk_hist != NULL )
- xine_fast_memcpy (this->buf_uk_hist, this->buf_uk, this->size_uk);
- switch( buf->type ) {
- case BUF_VIDEO_BITPLANE:
- /* uncompressed Buffer, set decoded_buf pointer direct to input stream */
- if( this->buf_uk == NULL )
- this->buf_uk = malloc(this->size);
- xine_fast_memcpy (this->buf_uk, this->buf, this->size);
- break;
- case BUF_VIDEO_BITPLANE_BR1:
- /* create Buffer for decompressed bitmap */
- this->buf_uk = bitplane_decode_byterun1(
- this->buf, /* compressed buffer */
- this->size, /* size of compressed data */
- this->size_uk ); /* size of uncompressed data */
-
- if( this->buf_uk == NULL ) {
- xine_log(this->stream->xine, XINE_LOG_MSG,
- _("bitplane: error doing ByteRun1 decompression\n"));
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HANDLED, 0);
- return;
- }
- /* set pointer to decompressed Buffer */
- break;
- default:
- break;
- }
- bitplane_decode_bitplane( this->buf_uk, /* bitplane buffer */
- this->index_buf, /* index buffer */
- this->width, /* width */
- this->height, /* hight */
- this->num_bitplanes, /* number bitplanes */
- this->bytes_per_pixel); /* used Bytes per pixel */
-
- if ((this->bytes_per_pixel == 1) &&
- (this->is_ham == 0) ) {
- buf_exchange = this->index_buf;
- for (i = 0; i < (this->height * this->width); i++) {
- j = *buf_exchange++ * 4;
- this->yuv_planes.y[i] = this->yuv_palette[j++];
- this->yuv_planes.u[i] = this->yuv_palette[j++];
- this->yuv_planes.v[i] = this->yuv_palette[j];
- }
- }
- if( this->buf_uk_hist == NULL ) {
- this->buf_uk_hist = malloc(this->size_uk);
- xine_fast_memcpy (this->buf_uk_hist, this->buf_uk, this->size_uk);
- xine_fast_memcpy (this->index_buf_hist, this->index_buf,
- (this->num_pixel * this->bytes_per_pixel));
- xine_fast_memcpy (this->yuv_planes_hist.y, this->yuv_planes.y, (this->num_pixel));
- xine_fast_memcpy (this->yuv_planes_hist.u, this->yuv_planes.u, (this->num_pixel));
- xine_fast_memcpy (this->yuv_planes_hist.v, this->yuv_planes.v, (this->num_pixel));
- }
- } else {
- /* when no start-picture is given, create a empty one */
- if( this->buf_uk_hist == NULL ) {
- this->size_uk = (((this->num_pixel) / 8) * this->num_bitplanes);
- this->buf_uk = calloc(this->num_bitplanes, ((this->num_pixel) / 8));
- this->buf_uk_hist = calloc(this->num_bitplanes, ((this->num_pixel) / 8));
- }
- if( this->index_buf == NULL ) {
- this->index_buf = calloc( this->num_pixel, this->bytes_per_pixel );
- this->index_buf_hist = calloc( this->num_pixel, this->bytes_per_pixel );
- }
-
- switch( anhd->operation ) {
- /* also known as IFF-ANIM OPT1 (never seen in real world) */
- case IFF_ANHD_XOR:
- xine_log(this->stream->xine, XINE_LOG_MSG,
- _("bitplane: Anim Opt 1 is not supported at the moment\n"));
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HANDLED, 0);
- return;
- break;
- /* also known as IFF-ANIM OPT2 (never seen in real world) */
- case IFF_ANHD_LDELTA:
- xine_log(this->stream->xine, XINE_LOG_MSG,
- _("bitplane: Anim Opt 2 is not supported at the moment\n"));
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HANDLED, 0);
- return;
- break;
- /* also known as IFF-ANIM OPT3 */
- case IFF_ANHD_SDELTA:
- _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Anim OPT3");
- bitplane_sdelta_opt_3 ( this );
- return;
- break;
- /* also known as IFF-ANIM OPT4 (never seen in real world) */
- case IFF_ANHD_SLDELTA:
- _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Anim OPT4 (SLDELTA)");
- bitplane_set_dlta_short ( this );
- break;
- /* also known as IFF-ANIM OPT5 */
- case IFF_ANHD_BVDELTA:
- _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Anim OPT5 (BVDELTA)");
- bitplane_dlta_5(this);
- break;
- /* IFF-ANIM OPT6 is exactly the same as OPT5, but for stereo-displays */
- /* first picture is on the left display, second on the right, third on */
- /* the left, forth on right, ... Only display left picture on mono display*/
- case IFF_ANHD_STEREOO5:
- _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Anim OPT6 (BVDELTA STEREO)");
- bitplane_dlta_5(this);
- if( this->framenumber % 2 == 0 )
- this->skipframes = 1;
- return;
- break;
- case IFF_ANHD_OPT7:
- if(anhd->bits == 0) {
- _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Anim OPT7 (SHORT)");
- bitplane_dlta_7_short(this);
- } else {
- _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Anim OPT7 (LONG)");
- bitplane_dlta_7_long(this);
- }
- break;
- case IFF_ANHD_OPT8:
- if(anhd->bits == 0) {
- _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Anim OPT8 (SHORT)");
- bitplane_dlta_8_short(this);
- } else {
- _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Anim OPT8 (LONG)");
- bitplane_dlta_8_long(this);
- }
- break;
- case IFF_ANHD_ASCIIJ:
- xine_log(this->stream->xine, XINE_LOG_MSG,
- _("bitplane: Anim ASCIIJ is not supported at the moment\n"));
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HANDLED, 0);
- return;
- break;
- default:
- xine_log(this->stream->xine, XINE_LOG_MSG,
- _("bitplane: This anim-type is not supported at the moment\n"));
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HANDLED, 0);
- return;
- break;
- }
- /* change old bitmap buffer (which now is the new one) with new buffer */
- buf_exchange = this->buf_uk;
- this->buf_uk = this->buf_uk_hist;
- this->buf_uk_hist = buf_exchange;
- /* do the same with the index buffer */
- buf_exchange = this->index_buf;
- this->index_buf = this->index_buf_hist;
- this->index_buf_hist = buf_exchange;
- /* and also with yuv buffer */
- buf_exchange = this->yuv_planes.y;
- this->yuv_planes.y = this->yuv_planes_hist.y;
- this->yuv_planes_hist.y = buf_exchange;
- buf_exchange = this->yuv_planes.u;
- this->yuv_planes.u = this->yuv_planes_hist.u;
- this->yuv_planes_hist.u = buf_exchange;
- buf_exchange = this->yuv_planes.v;
- this->yuv_planes.v = this->yuv_planes_hist.v;
- this->yuv_planes_hist.v = buf_exchange;
- }
-
- if( this->skipframes == 0 ) {
- switch (this->bytes_per_pixel) {
- case 1:
- /* HAM-pictrues need special handling */
- if( this->is_ham ) {
- /* Decode HAM-Pictures to YUV */
- bitplane_decode_ham( this->index_buf, /* HAM-bitplane buffer */
- &(this->yuv_planes), /* YUV buffer */
- this->width, /* width */
- this->height, /* hight */
- this->num_bitplanes, /* number bitplanes */
- this->bytes_per_pixel, /* used Bytes per pixel */
- this->rgb_palette); /* Palette (RGB) */
- }
- break;
- case 3:
- buf_exchange = this->index_buf;
- for (i = 0; i < (this->height * this->width); i++) {
- r = *buf_exchange++;
- g = *buf_exchange++;
- b = *buf_exchange++;
-
- this->yuv_planes.y[i] = COMPUTE_Y(r, g, b);
- this->yuv_planes.u[i] = COMPUTE_U(r, g, b);
- this->yuv_planes.v[i] = COMPUTE_V(r, g, b);
- }
- break;
- default:
- break;
- }
-
- yuv444_to_yuy2(&this->yuv_planes, img->base[0], img->pitches[0]);
-
- img->draw(img, this->stream);
- }
- img->free(img);
-
- this->size = 0;
- if ( buf->decoder_info[1] > 90000 )
- xine_usec_sleep(buf->decoder_info[1]);
- }
- }
-}
-
-/*
- * 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 bitplane_flush (video_decoder_t *this_gen) {
-}
-
-/*
- * This function resets the video decoder.
- */
-static void bitplane_reset (video_decoder_t *this_gen) {
- bitplane_decoder_t *this = (bitplane_decoder_t *) this_gen;
-
- this->size = 0;
-}
-
-static void bitplane_discontinuity (video_decoder_t *this_gen) {
-}
-
-/*
- * This function frees the video decoder instance allocated to the decoder.
- */
-static void bitplane_dispose (video_decoder_t *this_gen) {
- bitplane_decoder_t *this = (bitplane_decoder_t *) this_gen;
-
- if (this->buf) {
- free (this->buf);
- this->buf = NULL;
- }
-
- if (this->buf_uk) {
- free (this->buf_uk);
- this->buf_uk = NULL;
- }
-
- if (this->buf_uk_hist) {
- free (this->buf_uk_hist);
- this->buf_uk_hist = NULL;
- }
-
- if (this->index_buf) {
- free (this->index_buf);
- this->index_buf = NULL;
- }
-
- if (this->index_buf_hist) {
- free (this->index_buf_hist);
- this->index_buf_hist = NULL;
- }
-
- if (this->index_buf) {
- free (this->index_buf);
- this->index_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) {
-
- bitplane_decoder_t *this = (bitplane_decoder_t *) calloc(1, sizeof(bitplane_decoder_t));
-
- this->video_decoder.decode_data = bitplane_decode_data;
- this->video_decoder.flush = bitplane_flush;
- this->video_decoder.reset = bitplane_reset;
- this->video_decoder.discontinuity = bitplane_discontinuity;
- this->video_decoder.dispose = bitplane_dispose;
- this->size = 0;
-
- this->stream = stream;
- this->class = (bitplane_class_t *) class_gen;
-
- this->decoder_ok = 0;
- this->buf = NULL;
- this->buf_uk = NULL;
- this->index_buf = NULL;
- this->index_buf = NULL;
-
- return &this->video_decoder;
-}
-
-static char *get_identifier (video_decoder_class_t *this) {
- return "bitplane";
-}
-
-static char *get_description (video_decoder_class_t *this) {
- return "Raw bitplane video decoder plugin";
-}
-
-static void dispose_class (video_decoder_class_t *this) {
- free (this);
-}
-
-static void *init_plugin (xine_t *xine, void *data) {
-
- bitplane_class_t *this = (bitplane_class_t *) calloc(1, sizeof(bitplane_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 const uint32_t video_types[] = {
- BUF_VIDEO_BITPLANE,
- BUF_VIDEO_BITPLANE_BR1,
- 0
-};
-
-static const decoder_info_t dec_info_video = {
- video_types, /* supported types */
- 1 /* priority */
-};
-
-const plugin_info_t xine_plugin_info[] EXPORTED = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_VIDEO_DECODER, 18, "bitplane", XINE_VERSION_CODE, &dec_info_video, init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
diff --git a/src/libxinevdec/foovideo.c b/src/libxinevdec/foovideo.c
deleted file mode 100644
index 6e1fd0ac3..000000000
--- a/src/libxinevdec/foovideo.c
+++ /dev/null
@@ -1,305 +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * foovideo.c: This is a reference video decoder for the xine multimedia
- * player. It really works too! It will output frames of packed YUY2 data
- * where each byte in the map is the same value, which is 3 larger than the
- * value from the last frame. This creates a slowly rotating solid color
- * frame when the frames are played in succession.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#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;
-} foovideo_class_t;
-
-typedef struct foovideo_decoder_s {
- video_decoder_t video_decoder; /* parent video decoder structure */
-
- foovideo_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 */
-
- /* these are variables exclusive to the foo video decoder */
- unsigned char current_yuv_byte;
-
-} foovideo_decoder_t;
-
-/**************************************************************************
- * foovideo specific decode functions
- *************************************************************************/
-
-/**************************************************************************
- * 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 foovideo_decode_data (video_decoder_t *this_gen,
- buf_element_t *buf) {
-
- foovideo_decoder_t *this = (foovideo_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;
- this->height = bih->biHeight;
- 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;
-
- /* take this opportunity to load the stream/meta info */
- _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "foovideo");
-
- /* do anything else relating to initializing this decoder */
- this->current_yuv_byte = 0;
-
- this->decoder_ok = 1;
-
- 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;
-
- memset(img->base[0], this->current_yuv_byte,
- this->width * this->height * 2);
- this->current_yuv_byte += 3;
-
- img->draw(img, this->stream);
- img->free(img);
-
- this->size = 0;
- }
- }
-}
-
-/*
- * This function is called when xine needs to flush the system.
- */
-static void foovideo_flush (video_decoder_t *this_gen) {
-}
-
-/*
- * This function resets the video decoder.
- */
-static void foovideo_reset (video_decoder_t *this_gen) {
- foovideo_decoder_t *this = (foovideo_decoder_t *) this_gen;
-
- this->size = 0;
-}
-
-/*
- * The decoder should forget any stored pts values here.
- */
-static void foovideo_discontinuity (video_decoder_t *this_gen) {
- foovideo_decoder_t *this = (foovideo_decoder_t *) this_gen;
-
-}
-
-/*
- * This function frees the video decoder instance allocated to the decoder.
- */
-static void foovideo_dispose (video_decoder_t *this_gen) {
-
- foovideo_decoder_t *this = (foovideo_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);
-}
-
-/*
- * 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) {
-
- foovideo_decoder_t *this ;
-
- this = (foovideo_decoder_t *) calloc(1, sizeof(foovideo_decoder_t));
-
- this->video_decoder.decode_data = foovideo_decode_data;
- this->video_decoder.flush = foovideo_flush;
- this->video_decoder.reset = foovideo_reset;
- this->video_decoder.discontinuity = foovideo_discontinuity;
- this->video_decoder.dispose = foovideo_dispose;
- this->size = 0;
-
- this->stream = stream;
- this->class = (foovideo_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 "foovideo";
-}
-
-/*
- * This function returns a slightly longer string describing the video
- * decoder plugin.
- */
-static char *get_description (video_decoder_class_t *this) {
- return "foovideo: reference xine 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) {
-
- foovideo_class_t *this;
-
- this = (foovideo_class_t *) calloc(1, sizeof(foovideo_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 const uint32_t video_types[] = {
- /* BUF_VIDEO_FOOVIDEO, */
- BUF_VIDEO_VQA,
- BUF_VIDEO_SORENSON_V3,
- 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 const 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.
- */
-const plugin_info_t xine_plugin_info[] EXPORTED = {
- /* { type, API, "name", version, special_info, init_function } */
- { PLUGIN_VIDEO_DECODER, 18, "foovideo", XINE_VERSION_CODE, &dec_info_video, init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
diff --git a/src/libxinevdec/gdkpixbuf.c b/src/libxinevdec/gdkpixbuf.c
deleted file mode 100644
index 8815edabe..000000000
--- a/src/libxinevdec/gdkpixbuf.c
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * a gdk-pixbuf-based image video decoder
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdio.h>
-
-#define LOG_MODULE "gdkpixbuf_video_decoder"
-#define LOG_VERBOSE
-/*
-#define LOG
-*/
-
-#include "xine_internal.h"
-#include "video_out.h"
-#include "buffer.h"
-#include "xineutils.h"
-#include "bswap.h"
-
-#include <gdk-pixbuf/gdk-pixbuf.h>
-
-typedef struct {
- video_decoder_class_t decoder_class;
-
- /*
- * private variables
- */
-
-} image_class_t;
-
-
-typedef struct image_decoder_s {
- video_decoder_t video_decoder;
-
- image_class_t *cls;
-
- xine_stream_t *stream;
- int video_open;
-
- GdkPixbufLoader *loader;
-
-} image_decoder_t;
-
-
-static void image_decode_data (video_decoder_t *this_gen, buf_element_t *buf) {
- image_decoder_t *this = (image_decoder_t *) this_gen;
- GError *error = NULL;
-
- if (!this->video_open) {
- lprintf("opening video\n");
- (this->stream->video_out->open) (this->stream->video_out, this->stream);
- this->video_open = 1;
- }
-
- if (this->loader == NULL) {
- this->loader = gdk_pixbuf_loader_new ();
- }
-
- if (gdk_pixbuf_loader_write (this->loader, buf->mem, buf->size, &error) == FALSE) {
- lprintf("error loading image: %s\n", error->message);
- g_error_free (error);
- gdk_pixbuf_loader_close (this->loader, NULL);
- g_object_unref (G_OBJECT (this->loader));
- this->loader = NULL;
- return;
- }
-
- if (buf->decoder_flags & BUF_FLAG_FRAME_END) {
- GdkPixbuf *pixbuf;
- int width, height, x, y, rowstride, n_channels, i;
- guchar *img_buf;
- yuv_planes_t yuv_planes;
- vo_frame_t *img;
-
- /*
- * this->image -> rgb data
- */
- if (gdk_pixbuf_loader_close (this->loader, &error) == FALSE) {
- lprintf("error loading image: %s\n", error->message);
- g_error_free (error);
- g_object_unref (G_OBJECT (this->loader));
- this->loader = NULL;
- return;
- }
-
- pixbuf = gdk_pixbuf_loader_get_pixbuf (this->loader);
- if (pixbuf != NULL)
- g_object_ref (G_OBJECT (pixbuf));
- g_object_unref (this->loader);
- this->loader = NULL;
-
- if (pixbuf == NULL) {
- lprintf("error loading image\n");
- return;
- }
-
- width = gdk_pixbuf_get_width (pixbuf) & ~1; /* must be even for init_yuv_planes */
- height = gdk_pixbuf_get_height (pixbuf);
- img_buf = gdk_pixbuf_get_pixels (pixbuf);
-
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_WIDTH, width);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HEIGHT, height);
-
- lprintf("image loaded successfully\n");
-
- /*
- * rgb data -> yuv_planes
- */
- init_yuv_planes(&yuv_planes, width, height);
-
- n_channels = gdk_pixbuf_get_n_channels (pixbuf);
- rowstride = gdk_pixbuf_get_rowstride (pixbuf);
- i = 0;
- for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++) {
- guchar *p;
- p = img_buf + y * rowstride + x * n_channels;
-
- yuv_planes.y[i] = COMPUTE_Y (p[0], p[1], p[2]);
- yuv_planes.u[i] = COMPUTE_U (p[0], p[1], p[2]);
- yuv_planes.v[i] = COMPUTE_V (p[0], p[1], p[2]);
-
- i++;
- }
- }
- gdk_pixbuf_unref (pixbuf);
-
- /*
- * alloc and draw video frame
- */
- img = this->stream->video_out->get_frame (this->stream->video_out, width,
- height, (double)width/(double)height,
- XINE_IMGFMT_YUY2,
- VO_BOTH_FIELDS);
- img->pts = buf->pts;
- img->duration = 3600;
- img->bad_frame = 0;
-
- yuv444_to_yuy2(&yuv_planes, img->base[0], img->pitches[0]);
- free_yuv_planes(&yuv_planes);
-
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION, img->duration);
-
- img->draw(img, this->stream);
- img->free(img);
- }
-}
-
-
-static void image_flush (video_decoder_t *this_gen) {
- /* image_decoder_t *this = (image_decoder_t *) this_gen; */
-
- /*
- * flush out any frames that are still stored in the decoder
- */
-}
-
-
-static void image_reset (video_decoder_t *this_gen) {
- image_decoder_t *this = (image_decoder_t *) this_gen;
-
- /*
- * reset decoder after engine flush (prepare for new
- * video data not related to recently decoded data)
- */
-
- if (this->loader != NULL) {
- gdk_pixbuf_loader_close (this->loader, NULL);
- g_object_unref (G_OBJECT (this->loader));
- this->loader = NULL;
- }
-}
-
-
-static void image_discontinuity (video_decoder_t *this_gen) {
- /* image_decoder_t *this = (image_decoder_t *) this_gen; */
-
- /*
- * a time reference discontinuity has happened.
- * that is, it must forget any currently held pts value
- */
-}
-
-static void image_dispose (video_decoder_t *this_gen) {
- image_decoder_t *this = (image_decoder_t *) this_gen;
-
- if (this->video_open) {
- lprintf("closing video\n");
-
- this->stream->video_out->close(this->stream->video_out, this->stream);
- this->video_open = 0;
- }
-
- if (this->loader != NULL) {
- gdk_pixbuf_loader_close (this->loader, NULL);
- g_object_unref (G_OBJECT (this->loader));
- this->loader = NULL;
- }
-
- lprintf("closed\n");
- free (this);
-}
-
-
-static video_decoder_t *open_plugin (video_decoder_class_t *class_gen,
- xine_stream_t *stream) {
-
- image_class_t *cls = (image_class_t *) class_gen;
- image_decoder_t *this;
-
- lprintf("opened\n");
-
- g_type_init ();
-
- this = (image_decoder_t *) calloc(1, sizeof(image_decoder_t));
-
- this->video_decoder.decode_data = image_decode_data;
- this->video_decoder.flush = image_flush;
- this->video_decoder.reset = image_reset;
- this->video_decoder.discontinuity = image_discontinuity;
- this->video_decoder.dispose = image_dispose;
- this->cls = cls;
- this->stream = stream;
-
- /*
- * initialisation of privates
- */
-
- return &this->video_decoder;
-}
-
-/*
- * image plugin class
- */
-
-static char *get_identifier (video_decoder_class_t *this) {
- return "gdkpixbuf";
-}
-
-static char *get_description (video_decoder_class_t *this) {
- return "gdk-pixbuf image video decoder plugin";
-}
-
-static void dispose_class (video_decoder_class_t *this_gen) {
- image_class_t *this = (image_class_t *) this_gen;
-
- lprintf("class closed\n");
-
- free (this);
-}
-
-static void *init_class (xine_t *xine, void *data) {
-
- image_class_t *this;
-
- this = (image_class_t *) calloc(1, sizeof(image_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;
-
- /*
- * initialisation of privates
- */
-
- lprintf("class opened\n");
-
- return this;
-}
-
-/*
- * exported plugin catalog entry
- */
-
-static uint32_t supported_types[] = { BUF_VIDEO_IMAGE, BUF_VIDEO_JPEG, 0 };
-
-static const decoder_info_t dec_info_image = {
- supported_types, /* supported types */
- 7 /* priority */
-};
-
-const plugin_info_t xine_plugin_info[] EXPORTED = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_VIDEO_DECODER, 18, "gdkpixbuf", XINE_VERSION_CODE, &dec_info_image, init_class },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
diff --git a/src/libxinevdec/image.c b/src/libxinevdec/image.c
deleted file mode 100644
index 5e166382b..000000000
--- a/src/libxinevdec/image.c
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Copyright (C) 2003-2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * a image video decoder
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdio.h>
-
-#define LOG_MODULE "image_video_decoder"
-#define LOG_VERBOSE
-/*
-#define LOG
-*/
-
-#include <wand/magick_wand.h>
-#ifdef PACKAGE_NAME
-#undef PACKAGE_BUGREPORT
-#undef PACKAGE_NAME
-#undef PACKAGE_STRING
-#undef PACKAGE_TARNAME
-#undef PACKAGE_VERSION
-#endif
-
-#include "xine_internal.h"
-#include "video_out.h"
-#include "buffer.h"
-#include "xineutils.h"
-#include "bswap.h"
-
-#ifdef HAVE_GRAPHICSMAGICK
-# define MAGICK_VERSION 0x670
-#else
-# if !defined(MagickLibVersion) || MagickLibVersion < 0x671
-# define MAGICK_VERSION 0x670
-#else
-# define MAGICK_VERSION MagickLibVersion
-# endif
-#endif
-
-
-typedef struct {
- video_decoder_class_t decoder_class;
-
- /*
- * private variables
- */
-
-} image_class_t;
-
-
-typedef struct image_decoder_s {
- video_decoder_t video_decoder;
-
- image_class_t *cls;
-
- xine_stream_t *stream;
- int video_open;
-
- unsigned char *image;
- int index;
-
-} image_decoder_t;
-
-
-static void image_decode_data (video_decoder_t *this_gen, buf_element_t *buf) {
- image_decoder_t *this = (image_decoder_t *) this_gen;
-
- if (!this->video_open) {
- lprintf("opening video\n");
- (this->stream->video_out->open) (this->stream->video_out, this->stream);
- this->video_open = 1;
- }
-
- xine_buffer_copyin(this->image, this->index, buf->mem, buf->size);
- this->index += buf->size;
-
- if (buf->decoder_flags & BUF_FLAG_FRAME_END) {
- int width, height, i;
- int status;
- MagickWand *wand;
- uint8_t *img_buf, *img_buf_ptr;
- yuv_planes_t yuv_planes;
- vo_frame_t *img;
-
- /*
- * this->image -> rgb data
- */
-#if MAGICK_VERSION < 0x671
- InitializeMagick(NULL);
-#else
- MagickWandGenesis();
-#endif
- wand = NewMagickWand();
- status = MagickReadImageBlob(wand, this->image, this->index);
-
- this->index = 0;
-
- if (!status) {
- DestroyMagickWand(wand);
-#if MAGICK_VERSION < 0x671
- DestroyMagick();
-#else
- MagickWandTerminus();
-#endif
- lprintf("error loading image\n");
- return;
- }
-
- width = MagickGetImageWidth(wand) & ~1; /* must be even for init_yuv_planes */
- height = MagickGetImageHeight(wand);
- img_buf = malloc(width * height * 3);
-#if MAGICK_VERSION < 0x671
- MagickGetImagePixels(wand, 0, 0, width, height, "RGB", CharPixel, img_buf);
- DestroyMagickWand(wand);
- DestroyMagick();
-#else
- MagickExportImagePixels(wand, 0, 0, width, height, "RGB", CharPixel, img_buf);
- DestroyMagickWand(wand);
- MagickWandTerminus();
-#endif
-
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_WIDTH, width);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HEIGHT, height);
-
- lprintf("image loaded successfully\n");
-
- /*
- * rgb data -> yuv_planes
- */
- init_yuv_planes(&yuv_planes, width, height);
-
- img_buf_ptr = img_buf;
- for (i=0; i < width*height; i++) {
- uint8_t r = *(img_buf_ptr++);
- uint8_t g = *(img_buf_ptr++);
- uint8_t b = *(img_buf_ptr++);
-
- yuv_planes.y[i] = COMPUTE_Y(r, g, b);
- yuv_planes.u[i] = COMPUTE_U(r, g, b);
- yuv_planes.v[i] = COMPUTE_V(r, g, b);
- }
- free(img_buf);
-
- /*
- * alloc and draw video frame
- */
- img = this->stream->video_out->get_frame (this->stream->video_out, width,
- height, (double)width/(double)height,
- XINE_IMGFMT_YUY2,
- VO_BOTH_FIELDS);
- img->pts = buf->pts;
- img->duration = 3600;
- img->bad_frame = 0;
-
- yuv444_to_yuy2(&yuv_planes, img->base[0], img->pitches[0]);
- free_yuv_planes(&yuv_planes);
-
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION, img->duration);
-
- img->draw(img, this->stream);
- img->free(img);
- }
-}
-
-
-static void image_flush (video_decoder_t *this_gen) {
- /* image_decoder_t *this = (image_decoder_t *) this_gen; */
-
- /*
- * flush out any frames that are still stored in the decoder
- */
-}
-
-
-static void image_reset (video_decoder_t *this_gen) {
- image_decoder_t *this = (image_decoder_t *) this_gen;
-
- /*
- * reset decoder after engine flush (prepare for new
- * video data not related to recently decoded data)
- */
-
- this->index = 0;
-}
-
-
-static void image_discontinuity (video_decoder_t *this_gen) {
- /* image_decoder_t *this = (image_decoder_t *) this_gen; */
-
- /*
- * a time reference discontinuity has happened.
- * that is, it must forget any currently held pts value
- */
-}
-
-static void image_dispose (video_decoder_t *this_gen) {
- image_decoder_t *this = (image_decoder_t *) this_gen;
-
- if (this->video_open) {
- lprintf("closing video\n");
-
- this->stream->video_out->close(this->stream->video_out, this->stream);
- this->video_open = 0;
- }
-
- xine_buffer_free(this->image);
-
- lprintf("closed\n");
- free (this);
-}
-
-
-static video_decoder_t *open_plugin (video_decoder_class_t *class_gen,
- xine_stream_t *stream) {
-
- image_class_t *cls = (image_class_t *) class_gen;
- image_decoder_t *this;
-
- lprintf("opened\n");
-
- this = (image_decoder_t *) calloc(1, sizeof(image_decoder_t));
-
- this->video_decoder.decode_data = image_decode_data;
- this->video_decoder.flush = image_flush;
- this->video_decoder.reset = image_reset;
- this->video_decoder.discontinuity = image_discontinuity;
- this->video_decoder.dispose = image_dispose;
- this->cls = cls;
- this->stream = stream;
-
- /*
- * initialisation of privates
- */
-
- this->image = xine_buffer_init(10240);
-
- return &this->video_decoder;
-}
-
-/*
- * image plugin class
- */
-
-static char *get_identifier (video_decoder_class_t *this) {
- return "imagevdec";
-}
-
-static char *get_description (video_decoder_class_t *this) {
- return "image video decoder plugin";
-}
-
-static void dispose_class (video_decoder_class_t *this_gen) {
- image_class_t *this = (image_class_t *) this_gen;
-
- lprintf("class closed\n");
-
- free (this);
-}
-
-static void *init_class (xine_t *xine, void *data) {
-
- image_class_t *this;
-
- this = (image_class_t *) calloc(1, sizeof(image_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;
-
- /*
- * initialisation of privates
- */
-
- lprintf("class opened\n");
-
- return this;
-}
-
-/*
- * exported plugin catalog entry
- */
-
-static uint32_t supported_types[] = { BUF_VIDEO_IMAGE,
- 0 };
-
-static const decoder_info_t dec_info_image = {
- supported_types, /* supported types */
- 6 /* priority */
-};
-
-const plugin_info_t xine_plugin_info[] EXPORTED = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_VIDEO_DECODER, 18, "image", XINE_VERSION_CODE, &dec_info_image, init_class },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
diff --git a/src/libxinevdec/rgb.c b/src/libxinevdec/rgb.c
deleted file mode 100644
index 9e28afd90..000000000
--- a/src/libxinevdec/rgb.c
+++ /dev/null
@@ -1,467 +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * Raw RGB "Decoder" by Mike Melanson (melanson@pcisys.net)
- * Actually, this decoder just converts a raw RGB image to a YUY2 map
- * suitable for display under xine.
- *
- * This decoder deals with raw RGB data from Microsoft and Quicktime files.
- * Data from a MS file can be 32-, 24-, 16-, or 8-bit. The latter can also
- * be grayscale, depending on whether a palette is present. Data from a QT
- * file can be 32-, 24-, 16-, 8-, 4-, 2-, or 1-bit. Any resolutions <= 8
- * can also be greyscale depending on what the QT file specifies.
- *
- * One more catch: Raw RGB from a Microsoft file is upside down. This is
- * indicated by a negative height parameter.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#define LOG_MODULE "rgb"
-#define LOG_VERBOSE
-/*
-#define LOG
-*/
-#include "xine_internal.h"
-#include "video_out.h"
-#include "buffer.h"
-#include "xineutils.h"
-#include "bswap.h"
-
-typedef struct {
- video_decoder_class_t decoder_class;
-} rgb_class_t;
-
-typedef struct rgb_decoder_s {
- video_decoder_t video_decoder; /* parent video decoder structure */
-
- rgb_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 bytes_per_pixel;
- int bit_depth;
- int upside_down;
-
- unsigned char yuv_palette[256 * 4];
- yuv_planes_t yuv_planes;
-
-} rgb_decoder_t;
-
-static void rgb_decode_data (video_decoder_t *this_gen,
- buf_element_t *buf) {
-
- rgb_decoder_t *this = (rgb_decoder_t *) this_gen;
- xine_bmiheader *bih;
- palette_entry_t *palette;
- int i;
- int pixel_ptr, row_ptr;
- int palette_index;
- int buf_ptr;
- unsigned int packed_pixel;
- unsigned char r, g, b;
- int pixels_left;
- unsigned char pixel_byte = 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;
-
- 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);
-
- bih = (xine_bmiheader *) buf->content;
- this->width = (bih->biWidth + 3) & ~0x03;
- this->height = (bih->biHeight + 3) & ~0x03;
- if (this->height < 0) {
- this->upside_down = 1;
- this->height = -this->height;
- } else {
- this->upside_down = 0;
- }
- this->ratio = (double)this->width/(double)this->height;
-
- this->bit_depth = bih->biBitCount;
- if (this->bit_depth > 32)
- this->bit_depth &= 0x1F;
- /* round this number up in case of 15 */
- lprintf("width = %d, height = %d, bit_depth = %d\n", this->width, this->height, this->bit_depth);
-
- this->bytes_per_pixel = (this->bit_depth + 1) / 8;
-
- if (this->buf)
- free (this->buf);
-
- /* minimal buffer size */
- this->bufsize = this->width * this->height * this->bytes_per_pixel;
- this->buf = calloc(1, 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_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Raw RGB");
-
- 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;
-
-
- /* iterate through each row */
- buf_ptr = 0;
-
- if (this->upside_down) {
- for (row_ptr = this->yuv_planes.row_width * (this->yuv_planes.row_count - 1);
- row_ptr >= 0; row_ptr -= this->yuv_planes.row_width) {
- for (pixel_ptr = 0; pixel_ptr < this->width; pixel_ptr++) {
-
- if (this->bytes_per_pixel == 1) {
-
- palette_index = this->buf[buf_ptr++];
-
- this->yuv_planes.y[row_ptr + pixel_ptr] =
- this->yuv_palette[palette_index * 4 + 0];
- this->yuv_planes.u[row_ptr + pixel_ptr] =
- this->yuv_palette[palette_index * 4 + 1];
- this->yuv_planes.v[row_ptr + pixel_ptr] =
- this->yuv_palette[palette_index * 4 + 2];
-
- } else if (this->bytes_per_pixel == 2) {
-
- /* ABGR1555 format, little-endian order */
- packed_pixel = _X_LE_16(&this->buf[buf_ptr]);
- buf_ptr += 2;
- UNPACK_BGR15(packed_pixel, r, g, b);
-
- this->yuv_planes.y[row_ptr + pixel_ptr] =
- COMPUTE_Y(r, g, b);
- this->yuv_planes.u[row_ptr + pixel_ptr] =
- COMPUTE_U(r, g, b);
- this->yuv_planes.v[row_ptr + pixel_ptr] =
- COMPUTE_V(r, g, b);
-
- } else {
-
- /* BGR24 or BGRA32 */
- b = this->buf[buf_ptr++];
- g = this->buf[buf_ptr++];
- r = this->buf[buf_ptr++];
-
- /* the next line takes care of 'A' in the 32-bit case */
- buf_ptr += this->bytes_per_pixel - 3;
-
- this->yuv_planes.y[row_ptr + pixel_ptr] =
- COMPUTE_Y(r, g, b);
- this->yuv_planes.u[row_ptr + pixel_ptr] =
- COMPUTE_U(r, g, b);
- this->yuv_planes.v[row_ptr + pixel_ptr] =
- COMPUTE_V(r, g, b);
-
- }
- }
- }
- } else {
-
- for (row_ptr = 0; row_ptr < this->yuv_planes.row_width * this->yuv_planes.row_count; row_ptr += this->yuv_planes.row_width) {
- pixels_left = 0;
- for (pixel_ptr = 0; pixel_ptr < this->width; pixel_ptr++) {
-
- if (this->bit_depth == 1) {
-
- if (pixels_left == 0) {
- pixels_left = 8;
- pixel_byte = *this->buf++;
- }
-
- if (pixel_byte & 0x80) {
- this->yuv_planes.y[row_ptr + pixel_ptr] =
- this->yuv_palette[1 * 4 + 0];
- this->yuv_planes.u[row_ptr + pixel_ptr] =
- this->yuv_palette[1 * 4 + 1];
- this->yuv_planes.v[row_ptr + pixel_ptr] =
- this->yuv_palette[1 * 4 + 2];
- } else {
- this->yuv_planes.y[row_ptr + pixel_ptr] =
- this->yuv_palette[0 * 4 + 0];
- this->yuv_planes.u[row_ptr + pixel_ptr] =
- this->yuv_palette[0 * 4 + 1];
- this->yuv_planes.v[row_ptr + pixel_ptr] =
- this->yuv_palette[0 * 4 + 2];
- }
- pixels_left--;
- pixel_byte <<= 1;
-
- } else if (this->bit_depth == 2) {
-
- if (pixels_left == 0) {
- pixels_left = 4;
- pixel_byte = *this->buf++;
- }
-
- palette_index = (pixel_byte & 0xC0) >> 6;
- this->yuv_planes.y[row_ptr + pixel_ptr] =
- this->yuv_palette[palette_index * 4 + 0];
- this->yuv_planes.u[row_ptr + pixel_ptr] =
- this->yuv_palette[palette_index * 4 + 1];
- this->yuv_planes.v[row_ptr + pixel_ptr] =
- this->yuv_palette[palette_index * 4 + 2];
-
- pixels_left--;
- pixel_byte <<= 2;
-
- } else if (this->bit_depth == 4) {
-
- if (pixels_left == 0) {
- pixels_left = 2;
- pixel_byte = *this->buf++;
- }
-
- palette_index = (pixel_byte & 0xF0) >> 4;
- this->yuv_planes.y[row_ptr + pixel_ptr] =
- this->yuv_palette[palette_index * 4 + 0];
- this->yuv_planes.u[row_ptr + pixel_ptr] =
- this->yuv_palette[palette_index * 4 + 1];
- this->yuv_planes.v[row_ptr + pixel_ptr] =
- this->yuv_palette[palette_index * 4 + 2];
-
- pixels_left--;
- pixel_byte <<= 4;
-
- } else if (this->bytes_per_pixel == 1) {
-
- palette_index = this->buf[buf_ptr++];
-
- this->yuv_planes.y[row_ptr + pixel_ptr] =
- this->yuv_palette[palette_index * 4 + 0];
- this->yuv_planes.u[row_ptr + pixel_ptr] =
- this->yuv_palette[palette_index * 4 + 1];
- this->yuv_planes.v[row_ptr + pixel_ptr] =
- this->yuv_palette[palette_index * 4 + 2];
-
- } else if (this->bytes_per_pixel == 2) {
-
- /* ARGB1555 format, big-endian order */
- packed_pixel = _X_BE_16(&this->buf[buf_ptr]);
- buf_ptr += 2;
- UNPACK_RGB15(packed_pixel, r, g, b);
-
- this->yuv_planes.y[row_ptr + pixel_ptr] =
- COMPUTE_Y(r, g, b);
- this->yuv_planes.u[row_ptr + pixel_ptr] =
- COMPUTE_U(r, g, b);
- this->yuv_planes.v[row_ptr + pixel_ptr] =
- COMPUTE_V(r, g, b);
-
- } else {
-
- /* RGB24 or ARGB32; the next line takes care of 'A' in the
- * 32-bit case */
- buf_ptr += this->bytes_per_pixel - 3;
-
- r = this->buf[buf_ptr++];
- g = this->buf[buf_ptr++];
- b = this->buf[buf_ptr++];
-
- this->yuv_planes.y[row_ptr + pixel_ptr] =
- COMPUTE_Y(r, g, b);
- this->yuv_planes.u[row_ptr + pixel_ptr] =
- COMPUTE_U(r, g, b);
- this->yuv_planes.v[row_ptr + pixel_ptr] =
- COMPUTE_V(r, g, b);
-
- }
- }
- }
- }
-
- 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 rgb_flush (video_decoder_t *this_gen) {
-}
-
-/*
- * This function resets the video decoder.
- */
-static void rgb_reset (video_decoder_t *this_gen) {
- rgb_decoder_t *this = (rgb_decoder_t *) this_gen;
-
- this->size = 0;
-}
-
-static void rgb_discontinuity (video_decoder_t *this_gen) {
-}
-
-/*
- * This function frees the video decoder instance allocated to the decoder.
- */
-static void rgb_dispose (video_decoder_t *this_gen) {
- rgb_decoder_t *this = (rgb_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) {
-
- rgb_decoder_t *this ;
-
- this = (rgb_decoder_t *) calloc(1, sizeof(rgb_decoder_t));
-
- this->video_decoder.decode_data = rgb_decode_data;
- this->video_decoder.flush = rgb_flush;
- this->video_decoder.reset = rgb_reset;
- this->video_decoder.discontinuity = rgb_discontinuity;
- this->video_decoder.dispose = rgb_dispose;
- this->size = 0;
-
- this->stream = stream;
- this->class = (rgb_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 "RGB";
-}
-
-static char *get_description (video_decoder_class_t *this) {
- return "Raw RGB video decoder plugin";
-}
-
-static void dispose_class (video_decoder_class_t *this) {
- free (this);
-}
-
-static void *init_plugin (xine_t *xine, void *data) {
-
- rgb_class_t *this;
-
- this = (rgb_class_t *) calloc(1, sizeof(rgb_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 const uint32_t video_types[] = {
- BUF_VIDEO_RGB,
- 0
- };
-
-static const decoder_info_t dec_info_video = {
- video_types, /* supported types */
- 1 /* priority */
-};
-
-const plugin_info_t xine_plugin_info[] EXPORTED = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_VIDEO_DECODER, 18, "rgb", XINE_VERSION_CODE, &dec_info_video, init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
diff --git a/src/libxinevdec/xine_theora_decoder.c b/src/libxinevdec/xine_theora_decoder.c
deleted file mode 100644
index bf51a8779..000000000
--- a/src/libxinevdec/xine_theora_decoder.c
+++ /dev/null
@@ -1,398 +0,0 @@
-/*
- * Copyright (C) 2001-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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * xine decoder plugin using libtheora
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <inttypes.h>
-#include <string.h>
-#include <pthread.h>
-#include <math.h>
-#include <assert.h>
-#include <theora/theora.h>
-
-#define LOG_MODULE "theora_decoder"
-#define LOG_VERBOSE
-/*
-#define LOG
-*/
-
-#include "xine_internal.h"
-#include "video_out.h"
-#include "buffer.h"
-#include "metronom.h"
-#include "xineutils.h"
-
-typedef struct theora_class_s {
- video_decoder_class_t decoder_class;
-} theora_class_t;
-
-typedef struct theora_decoder_s {
- video_decoder_t theora_decoder;
- theora_class_t *class;
- theora_info t_info;
- theora_comment t_comment;
- theora_state t_state;
- ogg_packet op;
- yuv_buffer yuv;
- xine_stream_t* stream;
- int reject;
- int op_max_size;
- char* packet;
- int done;
- int width, height;
- double ratio;
- int offset_x, offset_y;
- int frame_duration;
- int skipframes;
- int hp_read;
- int initialized;
-} theora_decoder_t;
-
-static void readin_op (theora_decoder_t *this, char* src, int size) {
- if ( this->done+size > this->op_max_size) {
- while (this->op_max_size < this->done+size)
- this->op_max_size=this->op_max_size*2;
- this->packet=realloc(this->packet, this->op_max_size);
- this->op.packet=this->packet;
- }
- xine_fast_memcpy ( this->packet+this->done, src, size);
- this->done=this->done+size;
-}
-
-static void yuv2frame(yuv_buffer *yuv, vo_frame_t *frame, int offset_x, int offset_y) {
- int i;
- int crop_offset;
-
- /* fixme - direct rendering (exchaning pointers) may be possible.
- * frame->base[0] = yuv->y could work if one could change the
- * pitches[0,1,2] values, and rely on the drawing routine using
- * the new pitches. With cropping and offsets, it's a bit trickier,
- * but it would still be possible.
- * Attempts at doing this have yielded nothing but SIGSEVs so far.
- */
-
- /* Copy yuv data onto the frame. Cropping and offset as specified
- * by the frame_width, frame_height, offset_x and offset_y fields
- * in the theora header is carried out.
- */
-
- crop_offset=offset_x+yuv->y_stride*offset_y;
- for(i=0;i<frame->height;i++)
- xine_fast_memcpy(frame->base[0]+frame->pitches[0]*i,
- yuv->y+crop_offset+yuv->y_stride*i,
- frame->width);
-
- crop_offset=(offset_x/2)+(yuv->uv_stride)*(offset_y/2);
- for(i=0;i<frame->height/2;i++){
- xine_fast_memcpy(frame->base[1]+frame->pitches[1]*i,
- yuv->u+crop_offset+yuv->uv_stride*i,
- frame->width/2);
- xine_fast_memcpy(frame->base[2]+frame->pitches[2]*i,
- yuv->v+crop_offset+yuv->uv_stride*i,
- frame->width/2);
-
- }
-}
-
-static int collect_data (theora_decoder_t *this, buf_element_t *buf ) {
- /* Assembles an ogg_packet which was sent with send_ogg_packet over xinebuffers */
- /* this->done, this->rejected, this->op and this->decoder->flags are needed*/
-
- if (buf->decoder_flags & BUF_FLAG_FRAME_START) {
- this->done=0; /*start from the beginnig*/
- this->reject=0;/*new packet - new try*/
-
- /*copy the ogg_packet struct and the sum, correct the adress of the packet*/
- xine_fast_memcpy (&this->op, buf->content, sizeof(ogg_packet));
- this->op.packet=this->packet;
-
- readin_op (this, buf->content + sizeof(ogg_packet), buf->size - sizeof(ogg_packet) );
- /*read the rest of the data*/
-
- } else {
- if (this->done==0 || this->reject) {
- /*we are starting to collect an packet without the beginnig
- reject the rest*/
- printf ("libtheora: rejecting packet\n");
- this->reject=1;
- return 0;
- }
- readin_op (this, buf->content, buf->size );
- }
-
- if ((buf->decoder_flags & BUF_FLAG_FRAME_END) && !this->reject) {
- if ( this->done != this->op.bytes ) {
- printf ("libtheora: A packet changed its size during transfer - rejected\n");
- printf (" size %d should be %ld\n", this->done , this->op.bytes);
- this->op.bytes=this->done;
- }
- return 1;
- }
- return 0;
-}
-
-static void theora_decode_data (video_decoder_t *this_gen, buf_element_t *buf) {
- /*
- * decode data from buf and feed decoded frames to
- * video output
- */
- theora_decoder_t *this = (theora_decoder_t *) this_gen;
- vo_frame_t *frame;
- yuv_buffer yuv;
- int ret;
-
- if (!collect_data(this, buf)) return;
- /*return, until a entire packets is collected*/
-
- if ( (buf->decoder_flags & BUF_FLAG_HEADER) &&
- !(buf->decoder_flags & BUF_FLAG_STDHEADER) ) {
- /*get the first 3 packets and decode the header during preview*/
-
- if (this->hp_read==0) {
- /*decode first hp*/
- if (theora_decode_header(&this->t_info, &this->t_comment, &this->op)>=0) {
- this->hp_read++;
- return;
- }
- }
-
- if (this->hp_read==1) {
- /*decode three header packets*/
- if (theora_decode_header(&this->t_info, &this->t_comment,&this->op)) {
- printf ("libtheora: Was unable to decode header #%d, corrupt stream?\n",this->hp_read);
- } else {
- this->hp_read++;
- return;
- }
- }
-
- if (this->hp_read==2) {
- if (theora_decode_header(&this->t_info, &this->t_comment,&this->op)) {
- printf ("libtheora: Was unable to decode header #%d, corrupt stream?\n",this->hp_read);
- }
- /*headers are now decoded. initialize the decoder*/
- theora_decode_init (&this->t_state, &this->t_info);
-
- lprintf("theora stream is Theora %dx%d %.02f fps video.\n"
- " frame content is %dx%d with offset (%d,%d).\n"
- " pixel aspect is %d:%d.\n",
- this->t_info.width,this->t_info.height,
- (double)this->t_info.fps_numerator/this->t_info.fps_denominator,
- this->t_info.frame_width, this->t_info.frame_height,
- this->t_info.offset_x, this->t_info.offset_y,
- this->t_info.aspect_numerator, this->t_info.aspect_denominator);
-
- this->frame_duration=((int64_t)90000*this->t_info.fps_denominator)/this->t_info.fps_numerator;
- this->width=this->t_info.frame_width;
- this->height=this->t_info.frame_height;
- if (this->t_info.aspect_numerator==0 || this->t_info.aspect_denominator==0)
- /* 0-values are undefined, so don't do any scaling. */
- this->ratio=(double)this->width/(double)this->height;
- else
- /* Yes, this video needs to be scaled. */
- this->ratio=(double)(this->width*this->t_info.aspect_numerator) /
- (double)(this->height*this->t_info.aspect_denominator);
- this->offset_x=this->t_info.offset_x;
- this->offset_y=this->t_info.offset_y;
- this->initialized=1;
- this->hp_read++;
- }
-
- } else if (buf->decoder_flags & BUF_FLAG_HEADER) {
- /*ignore headerpackets*/
-
- return;
-
- } else {
- /*decode videodata*/
-
- if (!this->initialized) {
- printf ("libtheora: cannot decode stream without header\n");
- return;
- }
-
- ret=theora_decode_packetin( &this->t_state, &this->op);
-
- if ( ret!=0) {
- xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "libtheora:Received an bad packet\n");
- } else if (!this->skipframes) {
-
- theora_decode_YUVout(&this->t_state,&yuv);
-
- /*fixme - aspectratio from theora is not considered*/
- frame = this->stream->video_out->get_frame( this->stream->video_out,
- this->width, this->height,
- this->ratio,
- XINE_IMGFMT_YV12,
- VO_BOTH_FIELDS);
- yuv2frame(&yuv, frame, this->offset_x, this->offset_y);
-
- frame->pts = buf->pts;
- frame->duration=this->frame_duration;
- this->skipframes=frame->draw(frame, this->stream);
- frame->free(frame);
- } else {
- this->skipframes=this->skipframes-1;
- }
- }
-}
-
-
-static void theora_flush (video_decoder_t *this_gen) {
- /*
- * flush out any frames that are still stored in the decoder
- */
- theora_decoder_t *this = (theora_decoder_t *) this_gen;
- this->skipframes=0;
-}
-
-static void theora_reset (video_decoder_t *this_gen) {
- /*
- * reset decoder after engine flush (prepare for new
- * video data not related to recently decoded data)
- */
- theora_decoder_t *this = (theora_decoder_t *) this_gen;
- this->skipframes=0;
-}
-
-static void theora_discontinuity (video_decoder_t *this_gen) {
- /*
- * inform decoder that a time reference discontinuity has happened.
- * that is, it must forget any currently held pts value
- */
- theora_decoder_t *this = (theora_decoder_t *) this_gen;
- this->skipframes=0;
-}
-
-static void theora_dispose (video_decoder_t *this_gen) {
- /*
- * close down, free all resources
- */
-
- theora_decoder_t *this = (theora_decoder_t *) this_gen;
-
- lprintf ("dispose \n");
-
- theora_clear (&this->t_state);
- theora_comment_clear (&this->t_comment);
- theora_info_clear (&this->t_info);
- this->stream->video_out->close(this->stream->video_out, this->stream);
- free (this->packet);
- free (this);
-}
-
-static video_decoder_t *theora_open_plugin (video_decoder_class_t *class_gen, xine_stream_t *stream) {
-
- /*
- * open a new instance of this plugin class
- */
-
- theora_decoder_t *this ;
-
- this = (theora_decoder_t *) calloc(1, sizeof(theora_decoder_t));
-
- this->theora_decoder.decode_data = theora_decode_data;
- this->theora_decoder.flush = theora_flush;
- this->theora_decoder.reset = theora_reset;
- this->theora_decoder.discontinuity = theora_discontinuity;
- this->theora_decoder.dispose = theora_dispose;
-
- this->stream = stream;
- this->class = (theora_class_t *) class_gen;
-
- this->op_max_size = 4096;
- this->packet = malloc(this->op_max_size);
-
- this->done = 0;
-
- this->stream = stream;
-
- this->initialized = 0;
-
- theora_comment_init (&this->t_comment);
- theora_info_init (&this->t_info);
- (stream->video_out->open) (stream->video_out, stream);
-
- return &this->theora_decoder;
-
-}
-
-/*
- * theora plugin class
- */
-
-static char *theora_get_identifier (video_decoder_class_t *this) {
- /*
- * return short, human readable identifier for this plugin class
- */
- return "theora video";
-}
-
-static char *theora_get_description (video_decoder_class_t *this) {
- /*
- * return human readable (verbose = 1 line) description for
- * this plugin class
- */
- return "theora video decoder plugin";
-}
-
-static void theora_dispose_class (video_decoder_class_t *this) {
- /*
- * free all class-related resources
- */
- free (this);
-}
-
-static void *init_plugin (xine_t *xine, void *data) {
- /*initialize our plugin*/
- theora_class_t *this;
-
- this = (theora_class_t *) calloc(1, sizeof(theora_class_t));
-
- this->decoder_class.open_plugin = theora_open_plugin;
- this->decoder_class.get_identifier = theora_get_identifier;
- this->decoder_class.get_description = theora_get_description;
- this->decoder_class.dispose = theora_dispose_class;
-
- return this;
-}
-
-/*
- * exported plugin catalog entry
- */
-
-static uint32_t supported_types[] = { BUF_VIDEO_THEORA, 0 };
-
-static const decoder_info_t dec_info_video = {
- supported_types, /* supported types */
- 5 /* priority */
-};
-
-const plugin_info_t xine_plugin_info[] EXPORTED = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_VIDEO_DECODER, 18, "theora", XINE_VERSION_CODE, &dec_info_video, init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};
diff --git a/src/libxinevdec/yuv.c b/src/libxinevdec/yuv.c
deleted file mode 100644
index 6cb1b240c..000000000
--- a/src/libxinevdec/yuv.c
+++ /dev/null
@@ -1,394 +0,0 @@
-/*
- * Copyright (C) 2000-2004 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * YUV "Decoder" by Mike Melanson (melanson@pcisys.net)
- * Actually, this decoder just reorganizes chunks of raw YUV data in such
- * a way that xine can display them.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#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;
-} yuv_class_t;
-
-typedef struct yuv_decoder_s {
- video_decoder_t video_decoder; /* parent video decoder structure */
-
- yuv_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 progressive;
- int top_field_first;
-
-} yuv_decoder_t;
-
-/**************************************************************************
- * 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 yuv_decode_data (video_decoder_t *this_gen,
- buf_element_t *buf) {
-
- yuv_decoder_t *this = (yuv_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);
-
- bih = (xine_bmiheader *) buf->content;
- this->width = (bih->biWidth + 3) & ~0x03;
- this->height = (bih->biHeight + 3) & ~0x03;
-
- if (buf->decoder_flags & BUF_FLAG_ASPECT)
- this->ratio = (double)buf->decoder_info[1] / (double)buf->decoder_info[2];
- else
- this->ratio = (double)this->width / (double)this->height;
-
- this->progressive = buf->decoder_info[3];
- this->top_field_first = buf->decoder_info[4];
-
- if (this->buf) {
- free (this->buf);
- this->buf = NULL;
- }
-
- this->bufsize = VIDEOBUFSIZE;
- this->buf = malloc(this->bufsize);
- this->size = 0;
-
- this->decoder_ok = 1;
-
- /* load the stream/meta info */
- switch (buf->type) {
-
- case BUF_VIDEO_YUY2:
- _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Raw YUY2");
- break;
-
- case BUF_VIDEO_YV12:
- _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Raw YV12");
- break;
-
- case BUF_VIDEO_YVU9:
- _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Raw YVU9");
- break;
-
- case BUF_VIDEO_GREY:
- _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Greyscale YUV");
- break;
-
- case BUF_VIDEO_I420:
- _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "Raw I420");
- break;
-
- }
-
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_WIDTH, this->width);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HEIGHT, this->height);
- _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_RATIO, this->ratio*10000);
-
- return;
- } else if (this->decoder_ok && !(buf->decoder_flags & BUF_FLAG_SPECIAL)) {
- uint8_t *src;
-
- /* if buffer contains an entire frame then there's no need to copy it
- * into our internal buffer */
- if ((buf->decoder_flags & BUF_FLAG_FRAME_START) &&
- (buf->decoder_flags & BUF_FLAG_FRAME_END))
- src = buf->content;
- else {
- 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;
-
- src = this->buf;
- }
-
- if (buf->decoder_flags & BUF_FLAG_FRAME_END) {
-
- if (buf->type == BUF_VIDEO_YUY2) {
-
- img = this->stream->video_out->get_frame (this->stream->video_out,
- this->width, this->height,
- this->ratio, XINE_IMGFMT_YUY2, VO_BOTH_FIELDS);
-
- yuy2_to_yuy2(
- /* src */
- src, this->width*2,
- /* dst */
- img->base[0], img->pitches[0],
- /* width x height */
- this->width, this->height);
-
- } else if (buf->type == BUF_VIDEO_YV12) {
-
- img = this->stream->video_out->get_frame (this->stream->video_out,
- this->width, this->height,
- this->ratio, XINE_IMGFMT_YV12, VO_BOTH_FIELDS);
-
- yv12_to_yv12(
- /* Y */
- src, this->width,
- img->base[0], img->pitches[0],
- /* U */
- src + (this->width * this->height * 5/4), this->width/2,
- img->base[1], img->pitches[1],
- /* V */
- src + (this->width * this->height), this->width/2,
- img->base[2], img->pitches[2],
- /* width x height */
- this->width, this->height);
-
- } else if (buf->type == BUF_VIDEO_I420) {
-
- img = this->stream->video_out->get_frame (this->stream->video_out,
- this->width, this->height,
- this->ratio, XINE_IMGFMT_YV12, VO_BOTH_FIELDS);
-
- yv12_to_yv12(
- /* Y */
- src, this->width,
- img->base[0], img->pitches[0],
- /* U */
- src + (this->width * this->height), this->width/2,
- img->base[1], img->pitches[1],
- /* V */
- src + (this->width * this->height * 5/4), this->width/2,
- img->base[2], img->pitches[2],
- /* width x height */
- this->width, this->height);
-
- } else if (buf->type == BUF_VIDEO_YVU9) {
-
- img = this->stream->video_out->get_frame (this->stream->video_out,
- this->width, this->height,
- this->ratio, XINE_IMGFMT_YV12, VO_BOTH_FIELDS);
-
-
- yuv9_to_yv12(
- /* Y */
- src,
- this->width,
- img->base[0],
- img->pitches[0],
- /* U */
- src + (this->width * this->height),
- this->width / 4,
- img->base[1],
- img->pitches[1],
- /* V */
- src + (this->width * this->height) +
- (this->width * this->height / 16),
- this->width / 4,
- img->base[2],
- img->pitches[2],
- /* width x height */
- this->width,
- this->height);
-
- } else if (buf->type == BUF_VIDEO_GREY) {
-
- img = this->stream->video_out->get_frame (this->stream->video_out,
- this->width, this->height,
- this->ratio, XINE_IMGFMT_YV12, VO_BOTH_FIELDS);
-
- xine_fast_memcpy(img->base[0], src, this->width * this->height);
- memset( img->base[1], 0x80, this->width * this->height / 4 );
- memset( img->base[2], 0x80, this->width * this->height / 4 );
-
- } else {
-
- /* just allocate something to avoid compiler warnings */
- 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 = 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 yuv_flush (video_decoder_t *this_gen) {
-}
-
-/*
- * This function resets the video decoder.
- */
-static void yuv_reset (video_decoder_t *this_gen) {
- yuv_decoder_t *this = (yuv_decoder_t *) this_gen;
-
- this->size = 0;
-}
-
-static void yuv_discontinuity (video_decoder_t *this_gen) {
-}
-
-/*
- * This function frees the video decoder instance allocated to the decoder.
- */
-static void yuv_dispose (video_decoder_t *this_gen) {
- yuv_decoder_t *this = (yuv_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) {
-
- yuv_decoder_t *this ;
-
- this = (yuv_decoder_t *) calloc(1, sizeof(yuv_decoder_t));
-
- this->video_decoder.decode_data = yuv_decode_data;
- this->video_decoder.flush = yuv_flush;
- this->video_decoder.reset = yuv_reset;
- this->video_decoder.discontinuity = yuv_discontinuity;
- this->video_decoder.dispose = yuv_dispose;
- this->size = 0;
-
- this->stream = stream;
- this->class = (yuv_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 "YUV";
-}
-
-static char *get_description (video_decoder_class_t *this) {
- return "Raw YUV video decoder plugin";
-}
-
-static void dispose_class (video_decoder_class_t *this) {
- free (this);
-}
-
-static void *init_plugin (xine_t *xine, void *data) {
-
- yuv_class_t *this;
-
- this = (yuv_class_t *) calloc(1, sizeof(yuv_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 const uint32_t video_types[] = {
- BUF_VIDEO_YUY2,
- BUF_VIDEO_YV12,
- BUF_VIDEO_YVU9,
- BUF_VIDEO_GREY,
- BUF_VIDEO_I420,
- 0
- };
-
-static const decoder_info_t dec_info_video = {
- video_types, /* supported types */
- 1 /* priority */
-};
-
-const plugin_info_t xine_plugin_info[] EXPORTED = {
- /* type, API, "name", version, special_info, init_function */
- { PLUGIN_VIDEO_DECODER, 18, "yuv", XINE_VERSION_CODE, &dec_info_video, init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
-};