summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormelanson <melanson@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-12-23 22:20:46 +0000
committermelanson <melanson@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-12-23 22:20:46 +0000
commit512c294b4865e2fab1d99f079eda64c517cdb252 (patch)
treeab5fa60362a3df64f056fc6a032a6c3cb003b03f
parent7bbe389f7e3aadfbe5d4f81b773753d12c4dd048 (diff)
downloadmpv-512c294b4865e2fab1d99f079eda64c517cdb252.tar.bz2
mpv-512c294b4865e2fab1d99f079eda64c517cdb252.tar.xz
This commit adds initial support for Quicktime Animation (RLE) video. It
also fixes a FLI function name (FLI is not an AVI decoder). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@3688 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--Makefile2
-rw-r--r--codec-cfg.c1
-rw-r--r--codec-cfg.h1
-rw-r--r--dec_video.c38
-rw-r--r--etc/codecs.conf8
-rw-r--r--fli.c2
-rw-r--r--qtrle.c125
7 files changed, 166 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index c5f534c959..aa82083ce8 100644
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,7 @@ MANDIR = ${prefix}/man
# a BSD compatible 'install' program
INSTALL = install
-SRCS_COMMON = ima4.c xacodec.c cpudetect.c mp_msg.c ac3-iec958.c dec_audio.c dec_video.c msvidc.c cinepak.c fli.c codec-cfg.c cfgparser.c my_profile.c
+SRCS_COMMON = ima4.c xacodec.c cpudetect.c mp_msg.c ac3-iec958.c dec_audio.c dec_video.c msvidc.c cinepak.c fli.c qtrle.c codec-cfg.c cfgparser.c my_profile.c
SRCS_MENCODER = mencoder.c $(SRCS_COMMON) libao2/afmt.c divx4_vbr.c libvo/aclib.c libvo/img_format.c
SRCS_MPLAYER = mplayer.c $(SRCS_COMMON) find_sub.c subreader.c lirc_mp.c mixer.c spudec.c
diff --git a/codec-cfg.c b/codec-cfg.c
index 68ab3e5045..101d800cf5 100644
--- a/codec-cfg.c
+++ b/codec-cfg.c
@@ -232,6 +232,7 @@ static short get_driver(char *s,int audioflag)
"msvidc",
"fli",
"cinepak",
+ "qtrle",
NULL
};
char **drv=audioflag?audiodrv:videodrv;
diff --git a/codec-cfg.h b/codec-cfg.h
index c2bb91f0a9..5b1eb5fa94 100644
--- a/codec-cfg.h
+++ b/codec-cfg.h
@@ -47,6 +47,7 @@
#define VFM_MSVIDC 11
#define VFM_FLI 12
#define VFM_CINEPAK 13
+#define VFM_QTRLE 14
#ifndef GUID_TYPE
#define GUID_TYPE
diff --git a/dec_video.c b/dec_video.c
index 9050921646..5db3a2b41f 100644
--- a/dec_video.c
+++ b/dec_video.c
@@ -111,7 +111,7 @@ void AVI_Decode_Video1_8(
unsigned char *palette_map,
int bytes_per_pixel);
-void AVI_Decode_Fli(
+void Decode_Fli(
unsigned char *encoded,
int encoded_size,
unsigned char *decoded,
@@ -119,6 +119,14 @@ void AVI_Decode_Fli(
int height,
int bytes_per_pixel);
+void qt_decode_rle(
+ unsigned char *encoded,
+ int encoded_size,
+ unsigned char *decoded,
+ int width,
+ int height,
+ int encoded_bpp,
+ int bytes_per_pixel);
//**************************************************************************//
// The OpenDivX stuff:
@@ -522,16 +530,20 @@ switch(sh_video->codec->driver){
}
}
break;
- case VFM_MSVIDC: {
- int bpp=((out_fmt&255)+7)/8; // RGB only
- sh_video->our_out_buffer =
- (char*)memalign(64, sh_video->disp_w*sh_video->disp_h*bpp); // FIXME!!!
- }
- break;
- case VFM_FLI: {
+ case VFM_MSVIDC:
+ case VFM_FLI:
+ case VFM_QTRLE:
+ {
int bpp=((out_fmt&255)+7)/8; // RGB only
sh_video->our_out_buffer =
(char*)memalign(64, sh_video->disp_w*sh_video->disp_h*bpp); // FIXME!!!
+if ((sh_video->codec->driver == VFM_QTRLE) && (sh_video->bih->biBitCount != 24))
+ printf (
+ " *** 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",
+ sh_video->bih->biBitCount);
+
}
break;
}
@@ -785,9 +797,17 @@ if(verbose>1){
blit_frame = 3;
break;
case VFM_FLI:
- AVI_Decode_Fli(
+ Decode_Fli(
+ start, in_size, sh_video->our_out_buffer,
+ sh_video->disp_w, sh_video->disp_h,
+ ((out_fmt&255)+7)/8);
+ blit_frame = 3;
+ break;
+ case VFM_QTRLE:
+ qt_decode_rle(
start, in_size, sh_video->our_out_buffer,
sh_video->disp_w, sh_video->disp_h,
+ sh_video->bih->biBitCount,
((out_fmt&255)+7)/8);
blit_frame = 3;
break;
diff --git a/etc/codecs.conf b/etc/codecs.conf
index 96e36bb975..f68dcdd5b4 100644
--- a/etc/codecs.conf
+++ b/etc/codecs.conf
@@ -302,6 +302,14 @@ videocodec video1
driver msvidc
out BGR32,BGR24
+videocodec qtrle
+ info "Quicktime Animation (RLE)"
+ status working
+; codec fourcc = "rle "
+ format 0x20656C72
+ driver qtrle
+ out BGR32,BGR24
+
; =============== WINDOWS DLL's ==============
videocodec vp3
diff --git a/fli.c b/fli.c
index fee3cfbcd8..bae16c2edc 100644
--- a/fli.c
+++ b/fli.c
@@ -25,7 +25,7 @@
// to index 4-byte entries
static unsigned char palette[256 * 4];
-void AVI_Decode_Fli(
+void Decode_Fli(
unsigned char *encoded,
int encoded_size,
unsigned char *decoded,
diff --git a/qtrle.c b/qtrle.c
new file mode 100644
index 0000000000..6d46f9b32c
--- /dev/null
+++ b/qtrle.c
@@ -0,0 +1,125 @@
+/*
+ Quicktime Animation (RLE) Decoder for MPlayer
+
+ (C) 2001 Mike Melanson
+*/
+
+#include "config.h"
+#include "bswap.h"
+
+#define BE_16(x) (be2me_16(*(unsigned short *)(x)))
+#define BE_32(x) (be2me_32(*(unsigned int *)(x)))
+
+// 256 RGB entries; 25% of these bytes will be unused, but it's faster
+// to index 4-byte entries
+static unsigned char palette[256 * 4];
+
+void qt_decode_rle24(
+ unsigned char *encoded,
+ int encoded_size,
+ unsigned char *decoded,
+ int width,
+ int height,
+ int bytes_per_pixel)
+{
+ int stream_ptr;
+ int header;
+ int start_line;
+ int lines_to_change;
+ signed char rle_code;
+ int row_ptr, pixel_ptr;
+ int row_inc = bytes_per_pixel * width;
+ unsigned char r, g, b;
+
+ // check if this frame is even supposed to change
+ if (encoded_size < 8)
+ return;
+
+ // start after the chunk size
+ stream_ptr = 4;
+
+ // fetch the header
+ header = BE_16(&encoded[stream_ptr]);
+ stream_ptr += 2;
+
+ // if a header is present, fetch additional decoding parameters
+ if (header & 0x0008)
+ {
+ start_line = BE_16(&encoded[stream_ptr]);
+ stream_ptr += 4;
+ lines_to_change = BE_16(&encoded[stream_ptr]);
+ stream_ptr += 4;
+ }
+ else
+ {
+ start_line = 0;
+ lines_to_change = height;
+ }
+
+ row_ptr = row_inc * start_line;
+ while (lines_to_change--)
+ {
+ pixel_ptr = row_ptr + ((encoded[stream_ptr++] - 1) * bytes_per_pixel);
+
+ while ((rle_code = (signed char)encoded[stream_ptr++]) != -1)
+ {
+ if (rle_code == 0)
+ // there's another skip code in the stream
+ pixel_ptr += ((encoded[stream_ptr++] - 1) * bytes_per_pixel);
+ else if (rle_code < 0)
+ {
+ // decode the run length code
+ rle_code = -rle_code;
+ r = encoded[stream_ptr++];
+ g = encoded[stream_ptr++];
+ b = encoded[stream_ptr++];
+ while (rle_code--)
+ {
+ decoded[pixel_ptr++] = b;
+ decoded[pixel_ptr++] = g;
+ decoded[pixel_ptr++] = r;
+ if (bytes_per_pixel == 4)
+ pixel_ptr++;
+ }
+ }
+ else
+ {
+ // copy pixels directly to output
+ while (rle_code--)
+ {
+ decoded[pixel_ptr++] = encoded[stream_ptr + 2];
+ decoded[pixel_ptr++] = encoded[stream_ptr + 1];
+ decoded[pixel_ptr++] = encoded[stream_ptr + 0];
+ stream_ptr += 3;
+ if (bytes_per_pixel == 4)
+ pixel_ptr++;
+ }
+ }
+ }
+
+ row_ptr += row_inc;
+ }
+}
+
+void qt_decode_rle(
+ unsigned char *encoded,
+ int encoded_size,
+ unsigned char *decoded,
+ int width,
+ int height,
+ int encoded_bpp,
+ int bytes_per_pixel)
+{
+ switch (encoded_bpp)
+ {
+ case 24:
+ qt_decode_rle24(
+ encoded,
+ encoded_size,
+ decoded,
+ width,
+ height,
+ bytes_per_pixel);
+ break;
+ }
+}