diff options
Diffstat (limited to 'libmpcodecs')
-rw-r--r-- | libmpcodecs/Makefile | 4 | ||||
-rw-r--r-- | libmpcodecs/native/fli.c | 380 | ||||
-rw-r--r-- | libmpcodecs/vd.c | 6 | ||||
-rw-r--r-- | libmpcodecs/vd_fli.c | 64 | ||||
-rw-r--r-- | libmpcodecs/vd_lcl.c | 718 | ||||
-rw-r--r-- | libmpcodecs/vd_qtrle.c | 128 |
6 files changed, 2 insertions, 1298 deletions
diff --git a/libmpcodecs/Makefile b/libmpcodecs/Makefile index 0721f2168c..3a5ba1676c 100644 --- a/libmpcodecs/Makefile +++ b/libmpcodecs/Makefile @@ -10,7 +10,7 @@ AUDIO_SRCS_OPT=ad_acm.c ad_dshow.c ad_dmo.c ad_qtaudio.c ad_ffmpeg.c ad_faad.c a AUDIO_SRCS=dec_audio.c ad.c $(AUDIO_SRCS_LIB) $(AUDIO_SRCS_NAT) $(AUDIO_SRCS_OPT) VIDEO_SRCS_LIB=vd_libmpeg2.c vd_nuv.c vd_lzo.c -VIDEO_SRCS_NAT=vd_null.c vd_cinepak.c vd_raw.c vd_hmblck.c vd_fli.c vd_qtrle.c vd_roqvideo.c vd_cyuv.c vd_mpegpes.c vd_lcl.c vd_mtga.c vd_sgi.c +VIDEO_SRCS_NAT=vd_null.c vd_cinepak.c vd_raw.c vd_hmblck.c vd_roqvideo.c vd_cyuv.c vd_mpegpes.c vd_mtga.c vd_sgi.c VIDEO_SRCS_OPT=vd_realvid.c vd_ffmpeg.c vd_dshow.c vd_dmo.c vd_vfw.c vd_vfwex.c vd_odivx.c vd_divx4.c vd_zrmjpeg.c vd_xanim.c vd_xvid.c vd_xvid4.c vd_libdv.c vd_qtvideo.c vd_theora.c VIDEO_SRCS=dec_video.c vd.c $(VIDEO_SRCS_NAT) $(VIDEO_SRCS_LIB) $(VIDEO_SRCS_OPT) @@ -21,7 +21,7 @@ endif ENCODER_SRCS=ve.c ve_divx4.c ve_lavc.c ve_vfw.c ve_raw.c ve_libdv.c ve_xvid.c ve_xvid4.c ve_qtvideo.c ve_nuv.c -NATIVE_SRCS=native/RTjpegN.c native/cinepak.c native/fli.c native/minilzo.c native/nuppelvideo.c native/qtrle.c native/roqav.c native/xa_gsm.c native/decode144.c native/decode288.c +NATIVE_SRCS=native/RTjpegN.c native/cinepak.c native/minilzo.c native/nuppelvideo.c native/qtrle.c native/roqav.c native/xa_gsm.c native/decode144.c native/decode288.c ifeq ($(FAME),yes) VFILTER_SRCS += vf_fame.c diff --git a/libmpcodecs/native/fli.c b/libmpcodecs/native/fli.c deleted file mode 100644 index 9de0d14321..0000000000 --- a/libmpcodecs/native/fli.c +++ /dev/null @@ -1,380 +0,0 @@ -/* - FLI Decoder for MPlayer - - (C) 2001 Mike Melanson - - 32bpp support by Alex Beregszaszi - - Additional code and bug fixes by Roberto Togni - - For information on the FLI format, as well as various traps to - avoid while programming one, visit: - http://www.pcisys.net/~melanson/codecs/ -*/ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "config.h" -#include "bswap.h" -#include "mp_msg.h" - -#define LE_16(x) (le2me_16(*(unsigned short *)(x))) -#define LE_32(x) (le2me_32(*(unsigned int *)(x))) - -#define FLI_256_COLOR 4 -#define FLI_DELTA 7 -#define FLI_COLOR 11 -#define FLI_LC 12 -#define FLI_BLACK 13 -#define FLI_BRUN 15 -#define FLI_COPY 16 -#define FLI_MINI 18 - -// 256 RGB entries; 25% of these bytes will be unused, but it's faster -// to index 4-byte entries -#define PALETTE_SIZE 1024 -static unsigned char palette[PALETTE_SIZE]; - -void *init_fli_decoder(int width, int height) -{ - memset(palette, 0, PALETTE_SIZE); - - return malloc(width * height * sizeof (unsigned char)); -} - -void decode_fli_frame( - unsigned char *encoded, - int encoded_size, - unsigned char *decoded, - int width, - int height, - int bytes_per_pixel, - void *context) -{ - int stream_ptr = 0; - int stream_ptr_after_color_chunk; - int pixel_ptr; - int palette_ptr1; - int palette_ptr2; - unsigned char palette_idx1; - unsigned char palette_idx2; - - unsigned int frame_size; - int num_chunks; - - unsigned int chunk_size; - int chunk_type; - - int i, j; - - int color_packets; - int color_changes; - int color_scale; - - int lines; - int compressed_lines; - int starting_line; - signed short line_packets; - int y_ptr; - int line_inc = width * bytes_per_pixel; - signed char byte_run; - int pixel_skip; - int update_whole_frame = 0; // Palette change flag - unsigned char *fli_ghost_image = (unsigned char *)context; - int ghost_pixel_ptr; - int ghost_y_ptr; - - frame_size = LE_32(&encoded[stream_ptr]); - stream_ptr += 6; // skip the magic number - num_chunks = LE_16(&encoded[stream_ptr]); - stream_ptr += 10; // skip padding - - // iterate through the chunks - frame_size -= 16; - while ((frame_size > 0) && (num_chunks > 0)) - { - chunk_size = LE_32(&encoded[stream_ptr]); - stream_ptr += 4; - chunk_type = LE_16(&encoded[stream_ptr]); - stream_ptr += 2; - - switch (chunk_type) - { - case FLI_256_COLOR: - case FLI_COLOR: - stream_ptr_after_color_chunk = stream_ptr + chunk_size - 6; - if (chunk_type == FLI_COLOR) - color_scale = 4; - else - color_scale = 1; - // set up the palette - color_packets = LE_16(&encoded[stream_ptr]); - stream_ptr += 2; - palette_ptr1 = 0; - for (i = 0; i < color_packets; i++) - { - // first byte is how many colors to skip - palette_ptr1 += (encoded[stream_ptr++] * 4); - // wrap around, for good measure - if (palette_ptr1 >= PALETTE_SIZE) - palette_ptr1 = 0; - // next byte indicates how many entries to change - color_changes = encoded[stream_ptr++]; - // if there are 0 color changes, there are actually 256 - if (color_changes == 0) - color_changes = 256; - for (j = 0; j < color_changes; j++) - { - palette[palette_ptr1++] = encoded[stream_ptr + 2] * color_scale; - palette[palette_ptr1++] = encoded[stream_ptr + 1] * color_scale; - palette[palette_ptr1++] = encoded[stream_ptr + 0] * color_scale; - palette_ptr1++; - stream_ptr += 3; - } - } - - // color chunks sometimes have weird 16-bit alignment issues; - // therefore, take the hardline approach and set the stream_ptr - // to the value calculate w.r.t. the size specified by the color - // chunk header - stream_ptr = stream_ptr_after_color_chunk; - - /* Palette has changed, must update frame */ - update_whole_frame = 1; - break; - - case FLI_DELTA: - y_ptr = ghost_y_ptr = 0; - compressed_lines = LE_16(&encoded[stream_ptr]); - stream_ptr += 2; - while (compressed_lines > 0) - { - line_packets = LE_16(&encoded[stream_ptr]); - stream_ptr += 2; - if (line_packets < 0) - { - line_packets = -line_packets; - y_ptr += (line_packets * line_inc); - ghost_y_ptr += (line_packets * width); - } - else - { - pixel_ptr = y_ptr; - ghost_pixel_ptr = ghost_y_ptr; - for (i = 0; i < line_packets; i++) - { - // account for the skip bytes - pixel_skip = encoded[stream_ptr++]; - pixel_ptr += pixel_skip * bytes_per_pixel; - ghost_pixel_ptr += pixel_skip; - byte_run = encoded[stream_ptr++]; - if (byte_run < 0) - { - byte_run = -byte_run; - palette_ptr1 = (palette_idx1 = encoded[stream_ptr++]) * 4; - palette_ptr2 = (palette_idx2 = encoded[stream_ptr++]) * 4; - for (j = 0; j < byte_run; j++) - { - fli_ghost_image[ghost_pixel_ptr++] = palette_idx1; - decoded[pixel_ptr++] = palette[palette_ptr1 + 0]; - decoded[pixel_ptr++] = palette[palette_ptr1 + 1]; - decoded[pixel_ptr++] = palette[palette_ptr1 + 2]; - if (bytes_per_pixel == 4) /* 32bpp */ - pixel_ptr++; - - fli_ghost_image[ghost_pixel_ptr++] = palette_idx2; - decoded[pixel_ptr++] = palette[palette_ptr2 + 0]; - decoded[pixel_ptr++] = palette[palette_ptr2 + 1]; - decoded[pixel_ptr++] = palette[palette_ptr2 + 2]; - if (bytes_per_pixel == 4) /* 32bpp */ - pixel_ptr++; - } - } - else - { - for (j = 0; j < byte_run * 2; j++) - { - palette_ptr1 = (palette_idx1 = encoded[stream_ptr++]) * 4; - fli_ghost_image[ghost_pixel_ptr++] = palette_idx1; - decoded[pixel_ptr++] = palette[palette_ptr1 + 0]; - decoded[pixel_ptr++] = palette[palette_ptr1 + 1]; - decoded[pixel_ptr++] = palette[palette_ptr1 + 2]; - if (bytes_per_pixel == 4) /* 32bpp */ - pixel_ptr++; - } - } - } - y_ptr += line_inc; - ghost_y_ptr += width; - compressed_lines--; - } - } - break; - - case FLI_LC: - // line compressed - starting_line = LE_16(&encoded[stream_ptr]); - stream_ptr += 2; - y_ptr = starting_line * line_inc; - ghost_y_ptr = starting_line * width; - - compressed_lines = LE_16(&encoded[stream_ptr]); - stream_ptr += 2; - while (compressed_lines > 0) - { - pixel_ptr = y_ptr; - ghost_pixel_ptr = ghost_y_ptr; - line_packets = encoded[stream_ptr++]; - if (line_packets > 0) - { - for (i = 0; i < line_packets; i++) - { - // account for the skip bytes - pixel_skip = encoded[stream_ptr++]; - pixel_ptr += pixel_skip * bytes_per_pixel; - ghost_pixel_ptr += pixel_skip; - byte_run = encoded[stream_ptr++]; - if (byte_run > 0) - { - for (j = 0; j < byte_run; j++) - { - palette_ptr1 = (palette_idx1 = encoded[stream_ptr++]) * 4; - fli_ghost_image[ghost_pixel_ptr++] = palette_idx1; - decoded[pixel_ptr++] = palette[palette_ptr1 + 0]; - decoded[pixel_ptr++] = palette[palette_ptr1 + 1]; - decoded[pixel_ptr++] = palette[palette_ptr1 + 2]; - if (bytes_per_pixel == 4) /* 32bpp */ - pixel_ptr++; - } - } - else - { - byte_run = -byte_run; - palette_ptr1 = (palette_idx1 = encoded[stream_ptr++]) * 4; - for (j = 0; j < byte_run; j++) - { - fli_ghost_image[ghost_pixel_ptr++] = palette_idx1; - decoded[pixel_ptr++] = palette[palette_ptr1 + 0]; - decoded[pixel_ptr++] = palette[palette_ptr1 + 1]; - decoded[pixel_ptr++] = palette[palette_ptr1 + 2]; - if (bytes_per_pixel == 4) /* 32bpp */ - pixel_ptr++; - } - } - } - } - - y_ptr += line_inc; - ghost_y_ptr += width; - compressed_lines--; - } - break; - - case FLI_BLACK: - // set the whole frame to color 0 (which is usually black) by - // clearing the ghost image and trigger a full frame update - memset(fli_ghost_image, 0, width * height * sizeof(unsigned char)); - update_whole_frame = 1; - break; - - case FLI_BRUN: - // byte run compression - y_ptr = 0; - ghost_y_ptr = 0; - for (lines = 0; lines < height; lines++) - { - pixel_ptr = y_ptr; - ghost_pixel_ptr = ghost_y_ptr; - line_packets = encoded[stream_ptr++]; - for (i = 0; i < line_packets; i++) - { - byte_run = encoded[stream_ptr++]; - if (byte_run > 0) - { - palette_ptr1 = (palette_idx1 = encoded[stream_ptr++]) * 4; - for (j = 0; j < byte_run; j++) - { - fli_ghost_image[ghost_pixel_ptr++] = palette_idx1; - decoded[pixel_ptr++] = palette[palette_ptr1 + 0]; - decoded[pixel_ptr++] = palette[palette_ptr1 + 1]; - decoded[pixel_ptr++] = palette[palette_ptr1 + 2]; - if (bytes_per_pixel == 4) /* 32bpp */ - pixel_ptr++; - } - } - else // copy bytes if byte_run < 0 - { - byte_run = -byte_run; - for (j = 0; j < byte_run; j++) - { - palette_ptr1 = (palette_idx1 = encoded[stream_ptr++]) * 4; - fli_ghost_image[ghost_pixel_ptr++] = palette_idx1; - decoded[pixel_ptr++] = palette[palette_ptr1 + 0]; - decoded[pixel_ptr++] = palette[palette_ptr1 + 1]; - decoded[pixel_ptr++] = palette[palette_ptr1 + 2]; - if (bytes_per_pixel == 4) /* 32bpp */ - pixel_ptr++; - } - } - } - - y_ptr += line_inc; - ghost_y_ptr += width; - } - break; - - case FLI_COPY: - // copy the chunk (uncompressed frame) to the ghost image and - // schedule the whole frame to be updated - if (chunk_size - 6 > width * height) - { - mp_msg(MSGT_DECVIDEO, MSGL_WARN, - "FLI: in chunk FLI_COPY : source data (%d bytes) bigger than image," \ - " skipping chunk\n", - chunk_size - 6); - break; - } - else - memcpy(fli_ghost_image, &encoded[stream_ptr], chunk_size - 6); - stream_ptr += chunk_size - 6; - update_whole_frame = 1; - break; - - case FLI_MINI: - // sort of a thumbnail? disregard this chunk... - stream_ptr += chunk_size - 6; - break; - - default: - mp_msg (MSGT_DECVIDEO, MSGL_WARN, - "FLI: Unrecognized chunk type: %d\n", chunk_type); - break; - } - - frame_size -= chunk_size; - num_chunks--; - } - - if (update_whole_frame) - { - pixel_ptr = ghost_pixel_ptr = 0; - while (pixel_ptr < (width * height * bytes_per_pixel)) - { - palette_ptr1 = fli_ghost_image[ghost_pixel_ptr++] * 4; - decoded[pixel_ptr++] = palette[palette_ptr1 + 0]; - decoded[pixel_ptr++] = palette[palette_ptr1 + 1]; - decoded[pixel_ptr++] = palette[palette_ptr1 + 2]; - if (bytes_per_pixel == 4) /* 32bpp */ - pixel_ptr++; - } - } - - // by the end of the chunk, the stream ptr should equal the frame - // size (minus 1, possibly); if it doesn't, issue a warning - if ((stream_ptr != encoded_size) && (stream_ptr != encoded_size - 1)) - mp_msg(MSGT_DECVIDEO, MSGL_WARN, - " warning: processed FLI chunk where encoded size = %d\n" \ - " and final chunk ptr = %d\n", - encoded_size, stream_ptr); -} diff --git a/libmpcodecs/vd.c b/libmpcodecs/vd.c index d125e40f3b..cb29b79fda 100644 --- a/libmpcodecs/vd.c +++ b/libmpcodecs/vd.c @@ -40,8 +40,6 @@ extern vd_functions_t mpcodecs_vd_divx4; extern vd_functions_t mpcodecs_vd_raw; extern vd_functions_t mpcodecs_vd_hmblck; extern vd_functions_t mpcodecs_vd_xanim; -extern vd_functions_t mpcodecs_vd_fli; -extern vd_functions_t mpcodecs_vd_qtrle; extern vd_functions_t mpcodecs_vd_roqvideo; extern vd_functions_t mpcodecs_vd_cyuv; extern vd_functions_t mpcodecs_vd_nuv; @@ -55,7 +53,6 @@ extern vd_functions_t mpcodecs_vd_zrmjpeg; extern vd_functions_t mpcodecs_vd_realvid; extern vd_functions_t mpcodecs_vd_xvid; extern vd_functions_t mpcodecs_vd_libdv; -extern vd_functions_t mpcodecs_vd_lcl; extern vd_functions_t mpcodecs_vd_lzo; extern vd_functions_t mpcodecs_vd_qtvideo; @@ -85,8 +82,6 @@ vd_functions_t* mpcodecs_vd_drivers[] = { &mpcodecs_vd_lzo, &mpcodecs_vd_raw, &mpcodecs_vd_hmblck, - &mpcodecs_vd_fli, - &mpcodecs_vd_qtrle, &mpcodecs_vd_roqvideo, &mpcodecs_vd_cyuv, &mpcodecs_vd_nuv, @@ -117,7 +112,6 @@ vd_functions_t* mpcodecs_vd_drivers[] = { #ifdef HAVE_LIBDV095 &mpcodecs_vd_libdv, #endif - &mpcodecs_vd_lcl, #if defined(USE_QTX_CODECS) || defined(MACOSX) &mpcodecs_vd_qtvideo, #endif diff --git a/libmpcodecs/vd_fli.c b/libmpcodecs/vd_fli.c deleted file mode 100644 index 0d81aeb77d..0000000000 --- a/libmpcodecs/vd_fli.c +++ /dev/null @@ -1,64 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> - -#include "config.h" -#include "mp_msg.h" - -#include "vd_internal.h" - -static vd_info_t info = { - "Autodesk FLI/FLC Animation decoder", - "fli", - "A'rpi", - "Mike Melanson", - "native codec" -}; - -LIBVD_EXTERN(fli) - -// to set/get/query special features/parameters -static int control(sh_video_t *sh,int cmd,void* arg,...){ - return CONTROL_UNKNOWN; -} - -void *init_fli_decoder(int width, int height); - -void decode_fli_frame( - unsigned char *encoded, - int encoded_size, - unsigned char *decoded, - int width, - int height, - int bytes_per_pixel, - void *context); - -// init driver -static int init(sh_video_t *sh){ - if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_BGR24)) return 0; - sh->context = init_fli_decoder(sh->disp_w, sh->disp_h); - return 1; -} - -// uninit driver -static void uninit(sh_video_t *sh){ -} - -//mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); - -// decode a frame -static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ - mp_image_t* mpi; - if(len<=0) return NULL; // skipped frame - - mpi=mpcodecs_get_image(sh, MP_IMGTYPE_STATIC, MP_IMGFLAG_PRESERVE, - sh->disp_w, sh->disp_h); - if(!mpi) return NULL; - - decode_fli_frame( - data, len, mpi->planes[0], - sh->disp_w, sh->disp_h, - mpi->bpp/8, - sh->context); - - return mpi; -} diff --git a/libmpcodecs/vd_lcl.c b/libmpcodecs/vd_lcl.c deleted file mode 100644 index b5b08f4cf1..0000000000 --- a/libmpcodecs/vd_lcl.c +++ /dev/null @@ -1,718 +0,0 @@ -/* - * - * LCL (LossLess Codec Library) Decoder for Mplayer - * (c) 2002, 2003 Roberto Togni - * - * Fourcc: MSZH, ZLIB - * - * Win32 dll: - * Ver2.23 By Kenji Oshima 2000.09.20 - * avimszh.dll, avizlib.dll - * - * A description of the decoding algorithm can be found here: - * http://www.pcisys.net/~melanson/codecs - * - */ - -#include <stdio.h> -#include <stdlib.h> - -#include "config.h" - -#ifdef HAVE_ZLIB -#include <zlib.h> -#endif - -#include "mp_msg.h" - -#include "vd_internal.h" - - -static vd_info_t info = { - "LCL Video decoder", - "lcl", - "Roberto Togni", - "Roberto Togni", - "native codec" -}; - -LIBVD_EXTERN(lcl) - - -#define BMPTYPE_YUV 1 -#define BMPTYPE_RGB 2 - -#define IMGTYPE_YUV111 0 -#define IMGTYPE_YUV422 1 -#define IMGTYPE_RGB24 2 -#define IMGTYPE_YUV411 3 -#define IMGTYPE_YUV211 4 -#define IMGTYPE_YUV420 5 - -#define COMP_MSZH 0 -#define COMP_MSZH_NOCOMP 1 -#define COMP_ZLIB_HISPEED 1 -#define COMP_ZLIB_HICOMP 9 -#define COMP_ZLIB_NORMAL -1 - -#define FLAG_MULTITHREAD 1 -#define FLAG_NULLFRAME 2 -#define FLAG_PNGFILTER 4 -#define FLAGMASK_UNUSED 0xf8 - -#define CODEC_MSZH 1 -#define CODEC_ZLIB 3 - -#define FOURCC_MSZH mmioFOURCC('M','S','Z','H') -#define FOURCC_ZLIB mmioFOURCC('Z','L','I','B') - -/* - * Decoder context - */ -typedef struct { - // Image type - int imgtype; - // Compression type - int compression; - // Flags - int flags; - // Codec type - int codec; - // Decompressed data size - unsigned int decomp_size; - // Decompression buffer - unsigned char* decomp_buf; -#ifdef HAVE_ZLIB - z_stream zstream; -#endif -} lcl_context_t; - - -/* - * Internal function prototypes - */ - - -// to set/get/query special features/parameters -static int control(sh_video_t *sh,int cmd,void* arg,...) -{ - return CONTROL_UNKNOWN; -} - - -/* - * - * Init LCL decoder - * - */ -static int init(sh_video_t *sh) -{ - int vo_ret; // Video output init ret value - int zret; // Zlib return code - lcl_context_t *hc; // Decoder context - BITMAPINFOHEADER *bih = sh->bih; - int basesize = bih->biWidth * bih->biHeight; - - if ((hc = malloc(sizeof(lcl_context_t))) == NULL) { - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Can't allocate memory for LCL decoder context.\n"); - return 0; - } - - sh->context = (void *)hc; - -#ifdef HAVE_ZLIB - // Needed if zlib unused or init aborted before inflateInit - memset(&(hc->zstream), 0, sizeof(z_stream)); -#endif - - if ((bih->biCompression != FOURCC_MSZH) && (bih->biCompression != FOURCC_ZLIB)) { - mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[LCL] Unknown BITMAPHEADER fourcc.\n"); - return 0; - } - - if (bih->biSize < sizeof(BITMAPINFOHEADER) + 8) { - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] BITMAPHEADER size too small.\n"); - return 0; - } - - /* Detect codec type */ - switch (hc->codec = *((char *)bih + sizeof(BITMAPINFOHEADER) + 7)) { - case CODEC_MSZH: - mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Codec is MSZH.\n"); - break; - case CODEC_ZLIB: - mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Codec is ZLIB.\n"); - break; - default: - mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[LCL] Unknown codec id %d. Trusting fourcc.\n", hc->codec); - switch (bih->biCompression) { - case FOURCC_MSZH: - hc->codec = CODEC_MSZH; - break; - case FOURCC_ZLIB: - hc->codec = CODEC_ZLIB; - break; - default: - mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[LCL] BUG! Unknown coded id and fourcc. Why am I here?.\n"); - return 0; - } - } - - - /* Detect image type */ - switch (hc->imgtype = *((char *)bih + sizeof(BITMAPINFOHEADER) + 4)) { - case IMGTYPE_YUV111: - hc->decomp_size = basesize * 3; - mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Image type is YUV 1:1:1.\n"); - break; - case IMGTYPE_YUV422: - hc->decomp_size = basesize * 2; - mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Image type is YUV 4:2:2.\n"); - break; - case IMGTYPE_RGB24: - hc->decomp_size = basesize * 3; - mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Image type is RGB 24.\n"); - break; - case IMGTYPE_YUV411: - hc->decomp_size = basesize / 2 * 3; - mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Image type is YUV 4:1:1.\n"); - break; - case IMGTYPE_YUV211: - hc->decomp_size = basesize * 2; - mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Image type is YUV 2:1:1.\n"); - break; - case IMGTYPE_YUV420: - hc->decomp_size = basesize / 2 * 3; - mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Image type is YUV 4:2:0.\n"); - break; - default: - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] Unsupported image format %d.\n", hc->imgtype); - return 0; - } - - /* Detect compression method */ - hc->compression = *((char *)bih + sizeof(BITMAPINFOHEADER) + 5); - switch (hc->codec) { - case CODEC_MSZH: - switch (hc->compression) { - case COMP_MSZH: - mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Compression enabled.\n"); - break; - case COMP_MSZH_NOCOMP: - hc->decomp_size = 0; - mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] No compression.\n"); - break; - default: - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] Unsupported compression format for MSZH (%d).\n", hc->compression); - return 0; - } - break; - case CODEC_ZLIB: -#ifdef HAVE_ZLIB - switch (hc->compression) { - case COMP_ZLIB_HISPEED: - mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] High speed compression.\n"); - break; - case COMP_ZLIB_HICOMP: - mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] High compression.\n"); - break; - case COMP_ZLIB_NORMAL: - mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Normal compression.\n"); - break; - default: - if ((hc->compression < Z_NO_COMPRESSION) || (hc->compression > Z_BEST_COMPRESSION)) { - mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Unusupported compression level for ZLIB: (%d).\n", hc->compression); - return 0; - } - mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Compression level for ZLIB: (%d).\n", hc->compression); - } -#else - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] Zlib support not compiled.\n"); - return 0; -#endif - break; - default: - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] BUG! Unknown codec in compression switch.\n"); - return 0; - } - - /* Allocate decompression buffer */ - /* 4*8 max oveflow space for mszh decomp algorithm */ - if (hc->decomp_size) { - if ((hc->decomp_buf = malloc(hc->decomp_size+4*8)) == NULL) { - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] Can't allocate decompression buffer.\n"); - return 0; - } - } - - /* Detect flags */ - hc->flags = *((char *)bih + sizeof(BITMAPINFOHEADER) + 6); - if (hc->flags & FLAG_MULTITHREAD) - mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Multithread encoder flag set.\n"); - if (hc->flags & FLAG_NULLFRAME) - mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] Nullframe insertion flag set.\n"); - if ((hc->codec == CODEC_ZLIB) && (hc->flags & FLAG_PNGFILTER)) - mp_msg(MSGT_DECVIDEO, MSGL_INFO, "[LCL] PNG filter flag set.\n"); - if (hc->flags & FLAGMASK_UNUSED) - mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[LCL] Unknown flag set (%d).\n", hc->flags); - - /* If needed init zlib */ - if (hc->codec == CODEC_ZLIB) { -#ifdef HAVE_ZLIB - hc->zstream.zalloc = Z_NULL; - hc->zstream.zfree = Z_NULL; - hc->zstream.opaque = Z_NULL; - zret = inflateInit(&(hc->zstream)); - if (zret != Z_OK) { - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] Inflate init error: %d\n", zret); - return 0; - } -#else - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] Zlib support not compiled.\n"); - return 0; -#endif - } - - /* - * Initialize video output device - */ - vo_ret = mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_BGR24); - - return vo_ret; -} - - - - -/* - * - * Uninit LCL decoder - * - */ -static void uninit(sh_video_t *sh) -{ - lcl_context_t *hc = (lcl_context_t *) sh->context; // Decoder context - - if (sh->context) { -#ifdef HAVE_ZLIB - inflateEnd(&hc->zstream); -#endif - free(sh->context); - } -} - - - -inline unsigned char fix (int pix14) -{ - int tmp; - - tmp = (pix14 + 0x80000) >> 20; - if (tmp < 0) - return 0; - if (tmp > 255) - return 255; - return tmp; -} - - - -inline unsigned char get_b (unsigned char yq, signed char bq) -{ - return fix((yq << 20) + bq * 1858076); -} - - - -inline unsigned char get_g (unsigned char yq, signed char bq, signed char rq) -{ - return fix((yq << 20) - bq * 360857 - rq * 748830); -} - - - -inline unsigned char get_r (unsigned char yq, signed char rq) -{ - return fix((yq << 20) + rq * 1470103); -} - - -int mszh_decomp(unsigned char * srcptr, int srclen, unsigned char * destptr); - -/* - * - * Decode a frame - * - */ -static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags) -{ - mp_image_t* mpi; - int pixel_ptr; - int row, col; - unsigned char *encoded = (unsigned char *)data; - lcl_context_t *hc = (lcl_context_t *) sh->context; // Decoder context - unsigned char *outptr; - int width = sh->disp_w; // Real image width - int height = sh->disp_h; // Real image height -#ifdef HAVE_ZLIB - int zret; // Zlib return code -#endif - unsigned int mszh_dlen; - unsigned char yq, y1q, uq, vq; - int uqvq; - unsigned int mthread_inlen, mthread_outlen; - - // Skipped frame - if(len <= 0) - return NULL; - - /* Get output image buffer */ - mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0, sh->disp_w, sh->disp_h); - if (!mpi) { - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Can't allocate mpi image for lcl codec.\n"); - return NULL; - } - - outptr = mpi->planes[0]; // Output image pointer - - - /* Decompress frame */ - switch (hc->codec) { - case CODEC_MSZH: - switch (hc->compression) { - case COMP_MSZH: - if (hc->flags & FLAG_MULTITHREAD) { - mthread_inlen = *((unsigned int*)encoded); - mthread_outlen = *((unsigned int*)(encoded+4)); - mszh_dlen = mszh_decomp(encoded + 8, mthread_inlen, hc->decomp_buf); - if (mthread_outlen != mszh_dlen) { - mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[LCL] MSZH: mthread1 decoded size differs (%d != %d)\n", - mthread_outlen, mszh_dlen); - } - mszh_dlen = mszh_decomp(encoded + 8 + mthread_inlen, len - mthread_inlen, - hc->decomp_buf + mthread_outlen); - if ((hc->decomp_size - mthread_outlen) != mszh_dlen) { - mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[LCL] MSZH: mthread2 decoded size differs (%d != %d)\n", - hc->decomp_size - mthread_outlen, mszh_dlen); - } - encoded = hc->decomp_buf; - len = hc->decomp_size; - } else { - mszh_dlen = mszh_decomp(encoded, len, hc->decomp_buf); - if (hc->decomp_size != mszh_dlen) { - mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[LCL] MSZH: decoded size differs (%d != %d)\n", - hc->decomp_size, mszh_dlen); - } - encoded = hc->decomp_buf; - len = mszh_dlen; - } - break; - case COMP_MSZH_NOCOMP: - break; - default: - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] BUG! Unknown MSZH compression in frame decoder.\n"); - return 0; - } - break; - case CODEC_ZLIB: -#ifdef HAVE_ZLIB - zret = inflateReset(&(hc->zstream)); - if (zret != Z_OK) { - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] ZLIB: inflate reset error: %d\n", zret); - return 0; - } - if (hc->flags & FLAG_MULTITHREAD) { - mthread_inlen = *((unsigned int*)encoded); - mthread_outlen = *((unsigned int*)(encoded+4)); - hc->zstream.next_in = encoded + 8; - hc->zstream.avail_in = mthread_inlen; - hc->zstream.next_out = hc->decomp_buf; - hc->zstream.avail_out = mthread_outlen; - zret = inflate(&(hc->zstream), Z_FINISH); - if ((zret != Z_OK) && (zret != Z_STREAM_END)) { - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] ZLIB: mthread1 inflate error: %d\n", zret); - return 0; - } - if (mthread_outlen != (unsigned int)(hc->zstream.total_out)) { - mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[LCL] ZLIB: mthread1 decoded size differs (%u != %lu)\n", - mthread_outlen, hc->zstream.total_out); - } - zret = inflateReset(&(hc->zstream)); - if (zret != Z_OK) { - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] ZLIB: mthread2 inflate reset error: %d\n", zret); - return 0; - } - hc->zstream.next_in = encoded + 8 + mthread_inlen; - hc->zstream.avail_in = len - mthread_inlen; - hc->zstream.next_out = hc->decomp_buf + mthread_outlen; - hc->zstream.avail_out = mthread_outlen; - zret = inflate(&(hc->zstream), Z_FINISH); - if ((zret != Z_OK) && (zret != Z_STREAM_END)) { - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] ZLIB: mthread2 inflate error: %d\n", zret); - return 0; - } - if ((hc->decomp_size - mthread_outlen) != (unsigned int)(hc->zstream.total_out)) { - mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[LCL] ZLIB: mthread2 decoded size differs (%d != %lu)\n", - hc->decomp_size - mthread_outlen, hc->zstream.total_out); - } - } else { - hc->zstream.next_in = data; - hc->zstream.avail_in = len; - hc->zstream.next_out = hc->decomp_buf; - hc->zstream.avail_out = hc->decomp_size; - zret = inflate(&(hc->zstream), Z_FINISH); - if ((zret != Z_OK) && (zret != Z_STREAM_END)) { - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] ZLIB: inflate error: %d\n", zret); - return 0; - } - if (hc->decomp_size != (unsigned int)(hc->zstream.total_out)) { - mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[LCL] ZLIB: decoded size differs (%d != %lu)\n", - hc->decomp_size, hc->zstream.total_out); - } - } - encoded = hc->decomp_buf; - len = hc->decomp_size;; -#else - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] BUG! Zlib support not compiled in frame decoder.\n"); - return 0; -#endif - break; - default: - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] BUG! Unknown codec in frame decoder compression switch.\n"); - return 0; - } - - - /* Apply PNG filter */ - if ((hc->codec == CODEC_ZLIB) && (hc->flags & FLAG_PNGFILTER)) { - switch (hc->imgtype) { - case IMGTYPE_YUV111: - case IMGTYPE_RGB24: - for (row = 0; row < height; row++) { - pixel_ptr = row * width * 3; - yq = encoded[pixel_ptr++]; - uqvq = encoded[pixel_ptr++]; - uqvq+=(encoded[pixel_ptr++] << 8); - for (col = 1; col < width; col++) { - encoded[pixel_ptr] = yq -= encoded[pixel_ptr]; - uqvq -= (encoded[pixel_ptr+1] | (encoded[pixel_ptr+2]<<8)); - encoded[pixel_ptr+1] = (uqvq) & 0xff; - encoded[pixel_ptr+2] = ((uqvq)>>8) & 0xff; - pixel_ptr += 3; - } - } - break; - case IMGTYPE_YUV422: - for (row = 0; row < height; row++) { - pixel_ptr = row * width * 2; - yq = uq = vq =0; - for (col = 0; col < width/4; col++) { - encoded[pixel_ptr] = yq -= encoded[pixel_ptr]; - encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1]; - encoded[pixel_ptr+2] = yq -= encoded[pixel_ptr+2]; - encoded[pixel_ptr+3] = yq -= encoded[pixel_ptr+3]; - encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4]; - encoded[pixel_ptr+5] = uq -= encoded[pixel_ptr+5]; - encoded[pixel_ptr+6] = vq -= encoded[pixel_ptr+6]; - encoded[pixel_ptr+7] = vq -= encoded[pixel_ptr+7]; - pixel_ptr += 8; - } - } - break; - case IMGTYPE_YUV411: - for (row = 0; row < height; row++) { - pixel_ptr = row * width / 2 * 3; - yq = uq = vq =0; - for (col = 0; col < width/4; col++) { - encoded[pixel_ptr] = yq -= encoded[pixel_ptr]; - encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1]; - encoded[pixel_ptr+2] = yq -= encoded[pixel_ptr+2]; - encoded[pixel_ptr+3] = yq -= encoded[pixel_ptr+3]; - encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4]; - encoded[pixel_ptr+5] = vq -= encoded[pixel_ptr+5]; - pixel_ptr += 6; - } - } - break; - case IMGTYPE_YUV211: - for (row = 0; row < height; row++) { - pixel_ptr = row * width * 2; - yq = uq = vq =0; - for (col = 0; col < width/2; col++) { - encoded[pixel_ptr] = yq -= encoded[pixel_ptr]; - encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1]; - encoded[pixel_ptr+2] = uq -= encoded[pixel_ptr+2]; - encoded[pixel_ptr+3] = vq -= encoded[pixel_ptr+3]; - pixel_ptr += 4; - } - } - break; - case IMGTYPE_YUV420: - for (row = 0; row < height/2; row++) { - pixel_ptr = row * width * 3; - yq = y1q = uq = vq =0; - for (col = 0; col < width/2; col++) { - encoded[pixel_ptr] = yq -= encoded[pixel_ptr]; - encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1]; - encoded[pixel_ptr+2] = y1q -= encoded[pixel_ptr+2]; - encoded[pixel_ptr+3] = y1q -= encoded[pixel_ptr+3]; - encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4]; - encoded[pixel_ptr+5] = vq -= encoded[pixel_ptr+5]; - pixel_ptr += 6; - } - } - break; - break; - default: - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] BUG! Unknown imagetype in pngfilter switch.\n"); - return 0; - } - } - - /* Convert colorspace */ - switch (hc->imgtype) { - case IMGTYPE_YUV111: - for (row = height - 1; row >= 0; row--) { - pixel_ptr = row * mpi->stride[0]; - for (col = 0; col < width; col++) { - outptr[pixel_ptr++] = get_b(encoded[0], encoded[1]); - outptr[pixel_ptr++] = get_g(encoded[0], encoded[1], encoded[2]); - outptr[pixel_ptr++] = get_r(encoded[0], encoded[2]); - encoded += 3; - } - } - break; - case IMGTYPE_YUV422: - for (row = height - 1; row >= 0; row--) { - pixel_ptr = row * mpi->stride[0]; - for (col = 0; col < width/4; col++) { - outptr[pixel_ptr++] = get_b(encoded[0], encoded[4]); - outptr[pixel_ptr++] = get_g(encoded[0], encoded[4], encoded[6]); - outptr[pixel_ptr++] = get_r(encoded[0], encoded[6]); - outptr[pixel_ptr++] = get_b(encoded[1], encoded[4]); - outptr[pixel_ptr++] = get_g(encoded[1], encoded[4], encoded[6]); - outptr[pixel_ptr++] = get_r(encoded[1], encoded[6]); - outptr[pixel_ptr++] = get_b(encoded[2], encoded[5]); - outptr[pixel_ptr++] = get_g(encoded[2], encoded[5], encoded[7]); - outptr[pixel_ptr++] = get_r(encoded[2], encoded[7]); - outptr[pixel_ptr++] = get_b(encoded[3], encoded[5]); - outptr[pixel_ptr++] = get_g(encoded[3], encoded[5], encoded[7]); - outptr[pixel_ptr++] = get_r(encoded[3], encoded[7]); - encoded += 8; - } - } - break; - case IMGTYPE_RGB24: - for (row = height - 1; row >= 0; row--) { - pixel_ptr = row * mpi->stride[0]; - for (col = 0; col < width; col++) { - outptr[pixel_ptr++] = encoded[0]; - outptr[pixel_ptr++] = encoded[1]; - outptr[pixel_ptr++] = encoded[2]; - encoded += 3; - } - } - break; - case IMGTYPE_YUV411: - for (row = height - 1; row >= 0; row--) { - pixel_ptr = row * mpi->stride[0]; - for (col = 0; col < width/4; col++) { - outptr[pixel_ptr++] = get_b(encoded[0], encoded[4]); - outptr[pixel_ptr++] = get_g(encoded[0], encoded[4], encoded[5]); - outptr[pixel_ptr++] = get_r(encoded[0], encoded[5]); - outptr[pixel_ptr++] = get_b(encoded[1], encoded[4]); - outptr[pixel_ptr++] = get_g(encoded[1], encoded[4], encoded[5]); - outptr[pixel_ptr++] = get_r(encoded[1], encoded[5]); - outptr[pixel_ptr++] = get_b(encoded[2], encoded[4]); - outptr[pixel_ptr++] = get_g(encoded[2], encoded[4], encoded[5]); - outptr[pixel_ptr++] = get_r(encoded[2], encoded[5]); - outptr[pixel_ptr++] = get_b(encoded[3], encoded[4]); - outptr[pixel_ptr++] = get_g(encoded[3], encoded[4], encoded[5]); - outptr[pixel_ptr++] = get_r(encoded[3], encoded[5]); - encoded += 6; - } - } - break; - case IMGTYPE_YUV211: - for (row = height - 1; row >= 0; row--) { - pixel_ptr = row * mpi->stride[0]; - for (col = 0; col < width/2; col++) { - outptr[pixel_ptr++] = get_b(encoded[0], encoded[2]); - outptr[pixel_ptr++] = get_g(encoded[0], encoded[2], encoded[3]); - outptr[pixel_ptr++] = get_r(encoded[0], encoded[3]); - outptr[pixel_ptr++] = get_b(encoded[1], encoded[2]); - outptr[pixel_ptr++] = get_g(encoded[1], encoded[2], encoded[3]); - outptr[pixel_ptr++] = get_r(encoded[1], encoded[3]); - encoded += 4; - } - } - break; - case IMGTYPE_YUV420: - for (row = height / 2 - 1; row >= 0; row--) { - pixel_ptr = 2 * row * mpi->stride[0]; - for (col = 0; col < width/2; col++) { - outptr[pixel_ptr] = get_b(encoded[0], encoded[4]); - outptr[pixel_ptr+1] = get_g(encoded[0], encoded[4], encoded[5]); - outptr[pixel_ptr+2] = get_r(encoded[0], encoded[5]); - outptr[pixel_ptr+3] = get_b(encoded[1], encoded[4]); - outptr[pixel_ptr+4] = get_g(encoded[1], encoded[4], encoded[5]); - outptr[pixel_ptr+5] = get_r(encoded[1], encoded[5]); - outptr[pixel_ptr-mpi->stride[0]] = get_b(encoded[2], encoded[4]); - outptr[pixel_ptr-mpi->stride[0]+1] = get_g(encoded[2], encoded[4], encoded[5]); - outptr[pixel_ptr-mpi->stride[0]+2] = get_r(encoded[2], encoded[5]); - outptr[pixel_ptr-mpi->stride[0]+3] = get_b(encoded[3], encoded[4]); - outptr[pixel_ptr-mpi->stride[0]+4] = get_g(encoded[3], encoded[4], encoded[5]); - outptr[pixel_ptr-mpi->stride[0]+5] = get_r(encoded[3], encoded[5]); - pixel_ptr += 6; - encoded += 6; - } - } - break; - default: - mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[LCL] BUG! Unknown imagetype in image decoder.\n"); - return 0; - } - - return mpi; -} - - - -int mszh_decomp(unsigned char * srcptr, int srclen, unsigned char * destptr) -{ - unsigned char *destptr_bak = destptr; - unsigned char mask = 0; - unsigned char maskbit = 0; - unsigned int ofs, cnt; - - while (srclen > 0) { - if (maskbit == 0) { - mask = *(srcptr++); - maskbit = 8; - srclen--; - continue; - } - if ((mask & (1 << (--maskbit))) == 0) { - *(destptr++) = *(srcptr++); - *(destptr++) = *(srcptr++); - *(destptr++) = *(srcptr++); - *(destptr++) = *(srcptr++); - srclen -= 4; - } else { - ofs = *(srcptr++); - cnt = *(srcptr++); - ofs += cnt * 256;; - cnt = ((cnt >> 3) & 0x1f) + 1; - ofs &= 0x7ff; - srclen -= 2; - cnt *= 4; - for (; cnt > 0; cnt--) { - *(destptr) = *(destptr - ofs); - destptr++; - } - } - } - - return (destptr - destptr_bak); -} - diff --git a/libmpcodecs/vd_qtrle.c b/libmpcodecs/vd_qtrle.c deleted file mode 100644 index 5f43257327..0000000000 --- a/libmpcodecs/vd_qtrle.c +++ /dev/null @@ -1,128 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> - -#include "config.h" -#include "mp_msg.h" - -#include "vd_internal.h" - -static vd_info_t info = { - "Quicktime Animation (RLE) decoder", - "qtrle", - "A'rpi", - "Mike Melanson", - "native codec" -}; - -LIBVD_EXTERN(qtrle) - -typedef struct { - int depth; - void *palette; -} vd_qtrle_ctx; - -// to set/get/query special features/parameters -static int control(sh_video_t *sh,int cmd,void* arg,...){ - vd_qtrle_ctx *ctx = sh->context; - switch(cmd) - { - case VDCTRL_QUERY_FORMAT: - { - int req_format = *((int*)arg); - - /* qtrle24 supports 32bit output too */ - if ((req_format == (IMGFMT_BGR|ctx->depth)) || - ((IMGFMT_BGR_DEPTH(req_format) == 32) && (ctx->depth == 24)) || - ((IMGFMT_BGR_DEPTH(req_format) == 24) && (ctx->depth == 32))) - return(CONTROL_TRUE); - else - return(CONTROL_FALSE); - } - } - return CONTROL_UNKNOWN; -} - -// init driver -static int init(sh_video_t *sh){ - vd_qtrle_ctx *ctx; - - ctx = sh->context = malloc(sizeof(vd_qtrle_ctx)); - if (!ctx) - return(0); - memset(ctx, 0, sizeof(vd_qtrle_ctx)); - - if (!sh->bih) - return(0); - ctx->depth = sh->bih->biBitCount; - - switch(ctx->depth) - { - case 2: - case 4: - case 8: - if (sh->bih->biSize > 40) - { - ctx->palette = malloc(sh->bih->biSize-40); - memcpy(ctx->palette, sh->bih+40, sh->bih->biSize-40); - } - break; - case 16: - ctx->depth--; /* this is the trick ;) */ - break; - case 32: - mp_msg(MSGT_DECVIDEO,MSGL_INFO,"[qtrle] 32 bpp file, alpha channel will be ignored.\n"); - case 24: - break; - default: - mp_msg(MSGT_DECVIDEO,MSGL_ERR, - "*** FYI: This Quicktime file is using %d-bit RLE Animation\n" \ - "encoding, which is not yet supported by MPlayer. But if you upload\n" \ - "this Quicktime file to the MPlayer FTP, the team could look at it.\n", - ctx->depth); - return(0); - } - - return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_BGR|ctx->depth); -} - -// uninit driver -static void uninit(sh_video_t *sh){ - vd_qtrle_ctx *ctx = sh->context; - - if (ctx->palette) - free(ctx->palette); - free(ctx); -} - -//mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); - -void qt_decode_rle( - unsigned char *encoded, - int encoded_size, - unsigned char *decoded, - int width, - int height, - int encoded_bpp, - int bytes_per_pixel); - -// decode a frame -static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ - vd_qtrle_ctx *ctx = sh->context; - mp_image_t* mpi; - if(len<=0) return NULL; // skipped frame - - mpi=mpcodecs_get_image(sh, MP_IMGTYPE_STATIC, MP_IMGFLAG_PRESERVE, - sh->disp_w, sh->disp_h); - if(!mpi) return NULL; - - qt_decode_rle( - data,len, mpi->planes[0], - sh->disp_w, sh->disp_h, - sh->bih->biBitCount, - mpi->bpp/8); - - if (ctx->palette) - mpi->planes[1] = ctx->palette; - - return mpi; -} |