mirror of
https://github.com/mpv-player/mpv
synced 2025-03-19 18:05:21 +00:00
Remove 8BPS, MsRLE, MsVideo1, RPZA, SMC
These codecs are now in libavcodec git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@11676 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
651aec8776
commit
1339538d1a
@ -1,394 +0,0 @@
|
|||||||
/*
|
|
||||||
Microsoft Video 1 Decoder
|
|
||||||
|
|
||||||
(C) 2001 Mike Melanson
|
|
||||||
|
|
||||||
The description of the algorithm you can read here:
|
|
||||||
http://www.pcisys.net/~melanson/codecs/
|
|
||||||
|
|
||||||
32bpp support by Alex Beregszaszi
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include "bswap.h"
|
|
||||||
#define quad quad_m
|
|
||||||
|
|
||||||
#define LE_16(x) (le2me_16(*(unsigned short *)(x)))
|
|
||||||
|
|
||||||
#define DECODE_BGR555_TO_BGR888(x) \
|
|
||||||
x.c1_b = (x.c1 >> 7) & 0xF8; \
|
|
||||||
x.c1_g = (x.c1 >> 2) & 0xF8; \
|
|
||||||
x.c1_r = (x.c1 << 3) & 0xF8; \
|
|
||||||
x.c2_b = (x.c2 >> 7) & 0xF8; \
|
|
||||||
x.c2_g = (x.c2 >> 2) & 0xF8; \
|
|
||||||
x.c2_r = (x.c2 << 3) & 0xF8;
|
|
||||||
|
|
||||||
#define DECODE_PALETTE_TO_BGR888(x) \
|
|
||||||
x.c1_b = palette_map[x.c1 * 4 + 2]; \
|
|
||||||
x.c1_g = palette_map[x.c1 * 4 + 1]; \
|
|
||||||
x.c1_r = palette_map[x.c1 * 4 + 0]; \
|
|
||||||
x.c2_b = palette_map[x.c2 * 4 + 2]; \
|
|
||||||
x.c2_g = palette_map[x.c2 * 4 + 1]; \
|
|
||||||
x.c2_r = palette_map[x.c2 * 4 + 0];
|
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned short c1, c2;
|
|
||||||
unsigned char c1_r, c1_g, c1_b;
|
|
||||||
unsigned char c2_r, c2_g, c2_b;
|
|
||||||
} quad[2][2];
|
|
||||||
|
|
||||||
void AVI_Decode_Video1_16(
|
|
||||||
char *encoded,
|
|
||||||
int encoded_size,
|
|
||||||
char *decoded,
|
|
||||||
int width,
|
|
||||||
int height,
|
|
||||||
int bytes_per_pixel)
|
|
||||||
{
|
|
||||||
int block_ptr, pixel_ptr;
|
|
||||||
int total_blocks;
|
|
||||||
int pixel_x, pixel_y; // pixel width and height iterators
|
|
||||||
int block_x, block_y; // block width and height iterators
|
|
||||||
int blocks_wide, blocks_high; // width and height in 4x4 blocks
|
|
||||||
int block_inc;
|
|
||||||
int row_dec;
|
|
||||||
|
|
||||||
// decoding parameters
|
|
||||||
int stream_ptr;
|
|
||||||
unsigned char byte_a, byte_b;
|
|
||||||
unsigned short flags;
|
|
||||||
int skip_blocks;
|
|
||||||
|
|
||||||
stream_ptr = 0;
|
|
||||||
skip_blocks = 0;
|
|
||||||
blocks_wide = width / 4;
|
|
||||||
blocks_high = height / 4;
|
|
||||||
total_blocks = blocks_wide * blocks_high;
|
|
||||||
block_inc = 4 * bytes_per_pixel;
|
|
||||||
row_dec = (width + 4) * bytes_per_pixel;
|
|
||||||
|
|
||||||
for (block_y = blocks_high; block_y > 0; block_y--)
|
|
||||||
{
|
|
||||||
block_ptr = ((block_y * 4) - 1) * (width * bytes_per_pixel);
|
|
||||||
for (block_x = blocks_wide; block_x > 0; block_x--)
|
|
||||||
{
|
|
||||||
// check if this block should be skipped
|
|
||||||
if (skip_blocks)
|
|
||||||
{
|
|
||||||
block_ptr += block_inc;
|
|
||||||
skip_blocks--;
|
|
||||||
total_blocks--;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
pixel_ptr = block_ptr;
|
|
||||||
|
|
||||||
// get the next two bytes in the encoded data stream
|
|
||||||
byte_a = encoded[stream_ptr++];
|
|
||||||
byte_b = encoded[stream_ptr++];
|
|
||||||
|
|
||||||
// check if the decode is finished
|
|
||||||
if ((byte_a == 0) && (byte_b == 0) && (total_blocks == 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// check if this is a skip code
|
|
||||||
else if ((byte_b & 0xFC) == 0x84)
|
|
||||||
{
|
|
||||||
// but don't count the current block
|
|
||||||
skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if this is in the 2- or 8-color classes
|
|
||||||
else if (byte_b < 0x80)
|
|
||||||
{
|
|
||||||
flags = (byte_b << 8) | byte_a;
|
|
||||||
|
|
||||||
quad[0][0].c1 = LE_16(&encoded[stream_ptr]);
|
|
||||||
stream_ptr += 2;
|
|
||||||
quad[0][0].c2 = LE_16(&encoded[stream_ptr]);
|
|
||||||
stream_ptr += 2;
|
|
||||||
|
|
||||||
DECODE_BGR555_TO_BGR888(quad[0][0]);
|
|
||||||
|
|
||||||
if (quad[0][0].c1 & 0x8000)
|
|
||||||
{
|
|
||||||
// 8-color encoding
|
|
||||||
quad[1][0].c1 = LE_16(&encoded[stream_ptr]);
|
|
||||||
stream_ptr += 2;
|
|
||||||
quad[1][0].c2 = LE_16(&encoded[stream_ptr]);
|
|
||||||
stream_ptr += 2;
|
|
||||||
quad[0][1].c1 = LE_16(&encoded[stream_ptr]);
|
|
||||||
stream_ptr += 2;
|
|
||||||
quad[0][1].c2 = LE_16(&encoded[stream_ptr]);
|
|
||||||
stream_ptr += 2;
|
|
||||||
quad[1][1].c1 = LE_16(&encoded[stream_ptr]);
|
|
||||||
stream_ptr += 2;
|
|
||||||
quad[1][1].c2 = LE_16(&encoded[stream_ptr]);
|
|
||||||
stream_ptr += 2;
|
|
||||||
|
|
||||||
DECODE_BGR555_TO_BGR888(quad[0][1]);
|
|
||||||
DECODE_BGR555_TO_BGR888(quad[1][0]);
|
|
||||||
DECODE_BGR555_TO_BGR888(quad[1][1]);
|
|
||||||
|
|
||||||
for (pixel_y = 0; pixel_y < 4; pixel_y++)
|
|
||||||
{
|
|
||||||
for (pixel_x = 0; pixel_x < 4; pixel_x++)
|
|
||||||
{
|
|
||||||
if (flags & 1)
|
|
||||||
{
|
|
||||||
decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c1_r;
|
|
||||||
decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c1_g;
|
|
||||||
decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c1_b;
|
|
||||||
if (bytes_per_pixel == 4) /* 32bpp */
|
|
||||||
pixel_ptr++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c2_r;
|
|
||||||
decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c2_g;
|
|
||||||
decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c2_b;
|
|
||||||
if (bytes_per_pixel == 4) /* 32bpp */
|
|
||||||
pixel_ptr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the next flag ready to go
|
|
||||||
flags >>= 1;
|
|
||||||
}
|
|
||||||
pixel_ptr -= row_dec;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// 2-color encoding
|
|
||||||
for (pixel_y = 0; pixel_y < 4; pixel_y++)
|
|
||||||
{
|
|
||||||
for (pixel_x = 0; pixel_x < 4; pixel_x++)
|
|
||||||
{
|
|
||||||
if (flags & 1)
|
|
||||||
{
|
|
||||||
decoded[pixel_ptr++] = quad[0][0].c1_r;
|
|
||||||
decoded[pixel_ptr++] = quad[0][0].c1_g;
|
|
||||||
decoded[pixel_ptr++] = quad[0][0].c1_b;
|
|
||||||
if (bytes_per_pixel == 4) /* 32bpp */
|
|
||||||
pixel_ptr++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
decoded[pixel_ptr++] = quad[0][0].c2_r;
|
|
||||||
decoded[pixel_ptr++] = quad[0][0].c2_g;
|
|
||||||
decoded[pixel_ptr++] = quad[0][0].c2_b;
|
|
||||||
if (bytes_per_pixel == 4) /* 32bpp */
|
|
||||||
pixel_ptr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the next flag ready to go
|
|
||||||
flags >>= 1;
|
|
||||||
}
|
|
||||||
pixel_ptr -= row_dec;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// otherwise, it's a 1-color block
|
|
||||||
else
|
|
||||||
{
|
|
||||||
quad[0][0].c1 = (byte_b << 8) | byte_a;
|
|
||||||
DECODE_BGR555_TO_BGR888(quad[0][0]);
|
|
||||||
|
|
||||||
for (pixel_y = 0; pixel_y < 4; pixel_y++)
|
|
||||||
{
|
|
||||||
for (pixel_x = 0; pixel_x < 4; pixel_x++)
|
|
||||||
{
|
|
||||||
decoded[pixel_ptr++] = quad[0][0].c1_r;
|
|
||||||
decoded[pixel_ptr++] = quad[0][0].c1_g;
|
|
||||||
decoded[pixel_ptr++] = quad[0][0].c1_b;
|
|
||||||
if (bytes_per_pixel == 4) /* 32bpp */
|
|
||||||
pixel_ptr++;
|
|
||||||
}
|
|
||||||
pixel_ptr -= row_dec;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
block_ptr += block_inc;
|
|
||||||
total_blocks--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AVI_Decode_Video1_8(
|
|
||||||
char *encoded,
|
|
||||||
int encoded_size,
|
|
||||||
char *decoded,
|
|
||||||
int width,
|
|
||||||
int height,
|
|
||||||
unsigned char *palette_map,
|
|
||||||
int bytes_per_pixel)
|
|
||||||
{
|
|
||||||
int block_ptr, pixel_ptr;
|
|
||||||
int total_blocks;
|
|
||||||
int pixel_x, pixel_y; // pixel width and height iterators
|
|
||||||
int block_x, block_y; // block width and height iterators
|
|
||||||
int blocks_wide, blocks_high; // width and height in 4x4 blocks
|
|
||||||
int block_inc;
|
|
||||||
int row_dec;
|
|
||||||
|
|
||||||
// decoding parameters
|
|
||||||
int stream_ptr;
|
|
||||||
unsigned char byte_a, byte_b;
|
|
||||||
unsigned short flags;
|
|
||||||
int skip_blocks;
|
|
||||||
|
|
||||||
stream_ptr = 0;
|
|
||||||
skip_blocks = 0;
|
|
||||||
blocks_wide = width / 4;
|
|
||||||
blocks_high = height / 4;
|
|
||||||
total_blocks = blocks_wide * blocks_high;
|
|
||||||
block_inc = 4 * bytes_per_pixel;
|
|
||||||
row_dec = (width + 4) * bytes_per_pixel;
|
|
||||||
|
|
||||||
for (block_y = blocks_high; block_y > 0; block_y--)
|
|
||||||
{
|
|
||||||
block_ptr = ((block_y * 4) - 1) * (width * bytes_per_pixel);
|
|
||||||
for (block_x = blocks_wide; block_x > 0; block_x--)
|
|
||||||
{
|
|
||||||
// check if this block should be skipped
|
|
||||||
if (skip_blocks)
|
|
||||||
{
|
|
||||||
block_ptr += block_inc;
|
|
||||||
skip_blocks--;
|
|
||||||
total_blocks--;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
pixel_ptr = block_ptr;
|
|
||||||
|
|
||||||
// get the next two bytes in the encoded data stream
|
|
||||||
byte_a = encoded[stream_ptr++];
|
|
||||||
byte_b = encoded[stream_ptr++];
|
|
||||||
|
|
||||||
// check if the decode is finished
|
|
||||||
if ((byte_a == 0) && (byte_b == 0) && (total_blocks == 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// check if this is a skip code
|
|
||||||
else if ((byte_b & 0xFC) == 0x84)
|
|
||||||
{
|
|
||||||
// but don't count the current block
|
|
||||||
skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if this is a 2-color block
|
|
||||||
else if (byte_b < 0x80)
|
|
||||||
{
|
|
||||||
flags = (byte_b << 8) | byte_a;
|
|
||||||
|
|
||||||
quad[0][0].c1 = (unsigned char)encoded[stream_ptr++];
|
|
||||||
quad[0][0].c2 = (unsigned char)encoded[stream_ptr++];
|
|
||||||
|
|
||||||
DECODE_PALETTE_TO_BGR888(quad[0][0]);
|
|
||||||
|
|
||||||
// 2-color encoding
|
|
||||||
for (pixel_y = 0; pixel_y < 4; pixel_y++)
|
|
||||||
{
|
|
||||||
for (pixel_x = 0; pixel_x < 4; pixel_x++)
|
|
||||||
{
|
|
||||||
if (flags & 1)
|
|
||||||
{
|
|
||||||
decoded[pixel_ptr++] = quad[0][0].c1_r;
|
|
||||||
decoded[pixel_ptr++] = quad[0][0].c1_g;
|
|
||||||
decoded[pixel_ptr++] = quad[0][0].c1_b;
|
|
||||||
if (bytes_per_pixel == 4) /* 32bpp */
|
|
||||||
pixel_ptr++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
decoded[pixel_ptr++] = quad[0][0].c2_r;
|
|
||||||
decoded[pixel_ptr++] = quad[0][0].c2_g;
|
|
||||||
decoded[pixel_ptr++] = quad[0][0].c2_b;
|
|
||||||
if (bytes_per_pixel == 4) /* 32bpp */
|
|
||||||
pixel_ptr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the next flag ready to go
|
|
||||||
flags >>= 1;
|
|
||||||
}
|
|
||||||
pixel_ptr -= row_dec;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if it's an 8-color block
|
|
||||||
else if (byte_b >= 0x90)
|
|
||||||
{
|
|
||||||
flags = (byte_b << 8) | byte_a;
|
|
||||||
|
|
||||||
quad[0][0].c1 = (unsigned char)encoded[stream_ptr++];
|
|
||||||
quad[0][0].c2 = (unsigned char)encoded[stream_ptr++];
|
|
||||||
quad[1][0].c1 = (unsigned char)encoded[stream_ptr++];
|
|
||||||
quad[1][0].c2 = (unsigned char)encoded[stream_ptr++];
|
|
||||||
|
|
||||||
quad[0][1].c1 = (unsigned char)encoded[stream_ptr++];
|
|
||||||
quad[0][1].c2 = (unsigned char)encoded[stream_ptr++];
|
|
||||||
quad[1][1].c1 = (unsigned char)encoded[stream_ptr++];
|
|
||||||
quad[1][1].c2 = (unsigned char)encoded[stream_ptr++];
|
|
||||||
|
|
||||||
DECODE_PALETTE_TO_BGR888(quad[0][0]);
|
|
||||||
DECODE_PALETTE_TO_BGR888(quad[0][1]);
|
|
||||||
DECODE_PALETTE_TO_BGR888(quad[1][0]);
|
|
||||||
DECODE_PALETTE_TO_BGR888(quad[1][1]);
|
|
||||||
|
|
||||||
for (pixel_y = 0; pixel_y < 4; pixel_y++)
|
|
||||||
{
|
|
||||||
for (pixel_x = 0; pixel_x < 4; pixel_x++)
|
|
||||||
{
|
|
||||||
if (flags & 1)
|
|
||||||
{
|
|
||||||
decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c1_r;
|
|
||||||
decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c1_g;
|
|
||||||
decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c1_b;
|
|
||||||
if (bytes_per_pixel == 4) /* 32bpp */
|
|
||||||
pixel_ptr++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c2_r;
|
|
||||||
decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c2_g;
|
|
||||||
decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c2_b;
|
|
||||||
if (bytes_per_pixel == 4) /* 32bpp */
|
|
||||||
pixel_ptr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the next flag ready to go
|
|
||||||
flags >>= 1;
|
|
||||||
}
|
|
||||||
pixel_ptr -= row_dec;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// otherwise, it's a 1-color block
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// init c2 along with c1 just so c2 is a known value for macro
|
|
||||||
quad[0][0].c1 = quad[0][0].c2 = byte_a;
|
|
||||||
DECODE_PALETTE_TO_BGR888(quad[0][0]);
|
|
||||||
|
|
||||||
for (pixel_y = 0; pixel_y < 4; pixel_y++)
|
|
||||||
{
|
|
||||||
for (pixel_x = 0; pixel_x < 4; pixel_x++)
|
|
||||||
{
|
|
||||||
decoded[pixel_ptr++] = quad[0][0].c1_r;
|
|
||||||
decoded[pixel_ptr++] = quad[0][0].c1_g;
|
|
||||||
decoded[pixel_ptr++] = quad[0][0].c1_b;
|
|
||||||
if (bytes_per_pixel == 4) /* 32bpp */
|
|
||||||
pixel_ptr++;
|
|
||||||
}
|
|
||||||
pixel_ptr -= row_dec;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
block_ptr += block_inc;
|
|
||||||
total_blocks--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,262 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Apple Video (rpza) QuickTime Decoder for Mplayer
|
|
||||||
* (c) 2002 Roberto Togni
|
|
||||||
*
|
|
||||||
* Fourcc: rpza, azpr
|
|
||||||
*
|
|
||||||
* Some code comes from qtsmc.c by Mike Melanson
|
|
||||||
*
|
|
||||||
* A description of the decoding algorithm can be found here:
|
|
||||||
* http://www.pcisys.net/~melanson/codecs/
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include "bswap.h"
|
|
||||||
#include "mp_msg.h"
|
|
||||||
|
|
||||||
#define BE_16(x) (be2me_16(*(unsigned short *)(x)))
|
|
||||||
#define BE_32(x) (be2me_32(*(unsigned int *)(x)))
|
|
||||||
|
|
||||||
|
|
||||||
#define ADVANCE_BLOCK() \
|
|
||||||
{ \
|
|
||||||
pixel_ptr += block_x_inc; \
|
|
||||||
if (pixel_ptr >= (width * bytes_per_pixel)) \
|
|
||||||
{ \
|
|
||||||
pixel_ptr = 0; \
|
|
||||||
row_ptr += block_y_inc * 4; \
|
|
||||||
} \
|
|
||||||
total_blocks--; \
|
|
||||||
if (total_blocks < 0) \
|
|
||||||
{ \
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_WARN, "block counter just went negative (this should not happen)\n"); \
|
|
||||||
return; \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define PAINT_CURRENT_PIXEL(r, g, b, color) \
|
|
||||||
{ \
|
|
||||||
if (bytes_per_pixel == 2) { \
|
|
||||||
(*(unsigned short*)(&decoded[block_ptr])) = color & 0x7fff; \
|
|
||||||
block_ptr += 2; \
|
|
||||||
} else { \
|
|
||||||
decoded[block_ptr++] = (b); \
|
|
||||||
decoded[block_ptr++] = (g); \
|
|
||||||
decoded[block_ptr++] = (r); \
|
|
||||||
if (bytes_per_pixel == 4) /* 32bpp */ \
|
|
||||||
block_ptr++; \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define COLOR_FIX(col_out, col_in) (col_out) = ((col_in) << 3) | ((col_in) >> 2)
|
|
||||||
|
|
||||||
#define COLOR_TO_RGB(r, g, b, color) \
|
|
||||||
{ \
|
|
||||||
if (bytes_per_pixel != 2) { \
|
|
||||||
unsigned short tmp; \
|
|
||||||
tmp = (color >> 10) & 0x1f; \
|
|
||||||
COLOR_FIX (r, tmp); \
|
|
||||||
tmp = (color >> 5) & 0x1f; \
|
|
||||||
COLOR_FIX (g, tmp); \
|
|
||||||
tmp = color & 0x1f; \
|
|
||||||
COLOR_FIX (b, tmp); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define COLORAB_TO_RGB4(rgb4, color4, colorA, colorB) \
|
|
||||||
{ \
|
|
||||||
unsigned short ta, tb, tt; \
|
|
||||||
if (bytes_per_pixel != 2) { \
|
|
||||||
ta = (colorA >> 10) & 0x1f; \
|
|
||||||
tb = (colorB >> 10) & 0x1f; \
|
|
||||||
COLOR_FIX (rgb4[3][0], ta); \
|
|
||||||
COLOR_FIX (rgb4[0][0], tb); \
|
|
||||||
tt = (11 * ta + 21 * tb) >> 5; \
|
|
||||||
COLOR_FIX (rgb4[1][0], tt); \
|
|
||||||
tt = (21 * ta + 11 * tb) >> 5; \
|
|
||||||
COLOR_FIX (rgb4[2][0], tt); \
|
|
||||||
ta = (colorA >> 5) & 0x1f; \
|
|
||||||
tb = (colorB >> 5) & 0x1f; \
|
|
||||||
COLOR_FIX (rgb4[3][1], ta); \
|
|
||||||
COLOR_FIX (rgb4[0][1], tb); \
|
|
||||||
tt = (11 * ta + 21 * tb) >> 5; \
|
|
||||||
COLOR_FIX (rgb4[1][1], tt); \
|
|
||||||
tt = (21 * ta + 11 * tb) >> 5; \
|
|
||||||
COLOR_FIX (rgb4[2][1], tt); \
|
|
||||||
ta = colorA & 0x1f; \
|
|
||||||
tb = colorB & 0x1f; \
|
|
||||||
COLOR_FIX (rgb4[3][2], ta); \
|
|
||||||
COLOR_FIX (rgb4[0][2], tb); \
|
|
||||||
tt = (11 * ta + 21 * tb) >> 5; \
|
|
||||||
COLOR_FIX (rgb4[1][2], tt); \
|
|
||||||
tt = (21 * ta + 11 * tb) >> 5; \
|
|
||||||
COLOR_FIX (rgb4[2][2], tt); \
|
|
||||||
} else { \
|
|
||||||
color4[3] = colorA; \
|
|
||||||
color4[0] = colorB; \
|
|
||||||
ta = (colorA >> 10) & 0x1f; \
|
|
||||||
tb = (colorB >> 10) & 0x1f; \
|
|
||||||
color4[1] = ((11 * ta + 21 * tb) << 5) & 0x7c00; \
|
|
||||||
color4[2] = ((21 * ta + 11 * tb) << 5) & 0x7c00; \
|
|
||||||
ta = (colorA >> 5) & 0x1f; \
|
|
||||||
tb = (colorB >> 5) & 0x1f; \
|
|
||||||
color4[1] |= (11 * ta + 21 * tb) & 0x3e0; \
|
|
||||||
color4[2] |= (21 * ta + 11 * tb) & 0x3e0; \
|
|
||||||
ta = colorA & 0x1f; \
|
|
||||||
tb = colorB & 0x1f; \
|
|
||||||
color4[1] |= (11 * ta + 21 * tb) >> 5; \
|
|
||||||
color4[2] |= (21 * ta + 11 * tb) >> 5; \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* rpza frame decoder
|
|
||||||
*
|
|
||||||
* Input values:
|
|
||||||
*
|
|
||||||
* *encoded: buffer of encoded data (chunk)
|
|
||||||
* encoded_size: length of encoded buffer
|
|
||||||
* *decoded: buffer where decoded data is written (image buffer)
|
|
||||||
* width: width of decoded frame in pixels
|
|
||||||
* height: height of decoded frame in pixels
|
|
||||||
* bytes_per_pixel: bytes/pixel in output image (color depth)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
void qt_decode_rpza(char *encoded, int encoded_size, char *decoded, int width,
|
|
||||||
int height, int bytes_per_pixel)
|
|
||||||
{
|
|
||||||
|
|
||||||
int stream_ptr = 0;
|
|
||||||
int chunk_size;
|
|
||||||
unsigned char opcode;
|
|
||||||
int n_blocks;
|
|
||||||
unsigned short colorA, colorB;
|
|
||||||
unsigned char r, g, b;
|
|
||||||
unsigned char rgb4[4][3];
|
|
||||||
unsigned short color4[4];
|
|
||||||
unsigned char index, idx;
|
|
||||||
|
|
||||||
int row_ptr = 0;
|
|
||||||
int pixel_ptr = 0;
|
|
||||||
int pixel_x, pixel_y;
|
|
||||||
int row_inc = bytes_per_pixel * (width - 4);
|
|
||||||
int block_x_inc = bytes_per_pixel * 4;
|
|
||||||
int block_y_inc = bytes_per_pixel * width;
|
|
||||||
int block_ptr;
|
|
||||||
int total_blocks;
|
|
||||||
|
|
||||||
|
|
||||||
/* First byte is always 0xe1. Warn if it's different */
|
|
||||||
if ((unsigned char)encoded[stream_ptr] != 0xe1)
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_WARN,
|
|
||||||
"First chunk byte is 0x%02x instead of 0x1e\n",
|
|
||||||
(unsigned char)encoded[stream_ptr]);
|
|
||||||
|
|
||||||
/* Get chunk size, ingnoring first byte */
|
|
||||||
chunk_size = BE_32(&encoded[stream_ptr]) & 0x00FFFFFF;
|
|
||||||
stream_ptr += 4;
|
|
||||||
|
|
||||||
/* If length mismatch use size from MOV file and try to decode anyway */
|
|
||||||
if (chunk_size != encoded_size)
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_WARN, "MOV chunk size != encoded chunk size; using MOV chunk size\n");
|
|
||||||
|
|
||||||
chunk_size = encoded_size;
|
|
||||||
|
|
||||||
/* Number of 4x4 blocks in frame. */
|
|
||||||
total_blocks = (width * height) / (4 * 4);
|
|
||||||
|
|
||||||
/* Process chunk data */
|
|
||||||
while (stream_ptr < chunk_size) {
|
|
||||||
opcode = encoded[stream_ptr++]; /* Get opcode */
|
|
||||||
|
|
||||||
n_blocks = (opcode & 0x1f) +1; /* Extract block counter from opcode */
|
|
||||||
|
|
||||||
/* If opcode MSbit is 0, we need more data to decide what to do */
|
|
||||||
if ((opcode & 0x80) == 0) {
|
|
||||||
colorA = (opcode << 8) | ((unsigned char)encoded[stream_ptr++]);
|
|
||||||
opcode = 0;
|
|
||||||
if ((encoded[stream_ptr] & 0x80) != 0) {
|
|
||||||
/* Must behave as opcode 110xxxxx, using colorA computed above.*/
|
|
||||||
/* Use fake opcode 0x20 to enter switch block at the right place */
|
|
||||||
opcode = 0x20;
|
|
||||||
n_blocks = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
switch (opcode & 0xe0) {
|
|
||||||
/* Skip blocks */
|
|
||||||
case 0x80:
|
|
||||||
while (n_blocks--)
|
|
||||||
ADVANCE_BLOCK();
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* Fill blocks with one color */
|
|
||||||
case 0xa0:
|
|
||||||
colorA = BE_16 (&encoded[stream_ptr]);
|
|
||||||
stream_ptr += 2;
|
|
||||||
COLOR_TO_RGB (r, g, b, colorA);
|
|
||||||
while (n_blocks--) {
|
|
||||||
block_ptr = row_ptr + pixel_ptr;
|
|
||||||
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
|
|
||||||
for (pixel_x = 0; pixel_x < 4; pixel_x++){
|
|
||||||
PAINT_CURRENT_PIXEL(r, g, b, colorA);
|
|
||||||
}
|
|
||||||
block_ptr += row_inc;
|
|
||||||
}
|
|
||||||
ADVANCE_BLOCK();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* Fill blocks with 4 colors */
|
|
||||||
case 0xc0:
|
|
||||||
colorA = BE_16 (&encoded[stream_ptr]);
|
|
||||||
stream_ptr += 2;
|
|
||||||
case 0x20:
|
|
||||||
colorB = BE_16 (&encoded[stream_ptr]);
|
|
||||||
stream_ptr += 2;
|
|
||||||
COLORAB_TO_RGB4 (rgb4, color4, colorA, colorB);
|
|
||||||
while (n_blocks--) {
|
|
||||||
block_ptr = row_ptr + pixel_ptr;
|
|
||||||
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
|
|
||||||
index = encoded[stream_ptr++];
|
|
||||||
for (pixel_x = 0; pixel_x < 4; pixel_x++){
|
|
||||||
idx = (index >> (2 * (3 - pixel_x))) & 0x03;
|
|
||||||
PAINT_CURRENT_PIXEL(rgb4[idx][0], rgb4[idx][1], rgb4[idx][2], color4[idx]);
|
|
||||||
}
|
|
||||||
block_ptr += row_inc;
|
|
||||||
}
|
|
||||||
ADVANCE_BLOCK();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* Fill block with 16 colors */
|
|
||||||
case 0x00:
|
|
||||||
block_ptr = row_ptr + pixel_ptr;
|
|
||||||
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
|
|
||||||
for (pixel_x = 0; pixel_x < 4; pixel_x++){
|
|
||||||
/* We already have color of upper left pixel */
|
|
||||||
if ((pixel_y != 0) || (pixel_x !=0)) {
|
|
||||||
colorA = BE_16 (&encoded[stream_ptr]);
|
|
||||||
stream_ptr += 2;
|
|
||||||
}
|
|
||||||
COLOR_TO_RGB (r, g, b, colorA);
|
|
||||||
PAINT_CURRENT_PIXEL(r, g, b, colorA);
|
|
||||||
}
|
|
||||||
block_ptr += row_inc;
|
|
||||||
}
|
|
||||||
ADVANCE_BLOCK();
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* Unknown opcode */
|
|
||||||
default:
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_HINT, "Unknown opcode %d in rpza chunk."
|
|
||||||
" Skip remaining %lu bytes of chunk data.\n", opcode,
|
|
||||||
chunk_size - stream_ptr);
|
|
||||||
return;
|
|
||||||
} /* Opcode switch */
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,513 +0,0 @@
|
|||||||
/*
|
|
||||||
Apple Graphics (SMC) Decoder for MPlayer
|
|
||||||
by Mike Melanson
|
|
||||||
Special thanks for Roberto Togni <rtogni@bresciaonline.it> for
|
|
||||||
tracking down the final, nagging bugs.
|
|
||||||
|
|
||||||
The description of the decoding algorithm can be found here:
|
|
||||||
http://www.pcisys.net/~melanson/codecs/
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "config.h"
|
|
||||||
#include "bswap.h"
|
|
||||||
#include "mp_msg.h"
|
|
||||||
|
|
||||||
#define BE_16(x) (be2me_16(*(unsigned short *)(x)))
|
|
||||||
#define BE_32(x) (be2me_32(*(unsigned int *)(x)))
|
|
||||||
|
|
||||||
#define COLORS_PER_TABLE 256
|
|
||||||
#define BYTES_PER_COLOR 4
|
|
||||||
|
|
||||||
#define CPAIR 2
|
|
||||||
#define CQUAD 4
|
|
||||||
#define COCTET 8
|
|
||||||
|
|
||||||
static unsigned char *color_pairs;
|
|
||||||
static unsigned char *color_quads;
|
|
||||||
static unsigned char *color_octets;
|
|
||||||
|
|
||||||
static int color_pair_index;
|
|
||||||
static int color_quad_index;
|
|
||||||
static int color_octet_index;
|
|
||||||
|
|
||||||
static int smc_initialized;
|
|
||||||
|
|
||||||
// returns 0 if successfully initialized (enough memory was available),
|
|
||||||
// non-zero on failure
|
|
||||||
int qt_init_decode_smc(void)
|
|
||||||
{
|
|
||||||
// be pessimistic to start
|
|
||||||
smc_initialized = 0;
|
|
||||||
|
|
||||||
// allocate memory for the 3 palette tables
|
|
||||||
if ((color_pairs = (unsigned char *)malloc(
|
|
||||||
COLORS_PER_TABLE * BYTES_PER_COLOR * 2)) == 0)
|
|
||||||
return 1;
|
|
||||||
if ((color_quads = (unsigned char *)malloc(
|
|
||||||
COLORS_PER_TABLE * BYTES_PER_COLOR * 4)) == 0)
|
|
||||||
return 1;
|
|
||||||
if ((color_octets = (unsigned char *)malloc(
|
|
||||||
COLORS_PER_TABLE * BYTES_PER_COLOR * 8)) == 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
// if execution got this far, initialization succeeded
|
|
||||||
smc_initialized = 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define GET_BLOCK_COUNT \
|
|
||||||
(opcode & 0x10) ? (1 + encoded[stream_ptr++]) : 1 + (opcode & 0x0F);
|
|
||||||
#define ADVANCE_BLOCK() \
|
|
||||||
{ \
|
|
||||||
pixel_ptr += block_x_inc; \
|
|
||||||
if (pixel_ptr >= byte_width) \
|
|
||||||
{ \
|
|
||||||
pixel_ptr = 0; \
|
|
||||||
row_ptr += block_y_inc * 4; \
|
|
||||||
} \
|
|
||||||
total_blocks--; \
|
|
||||||
if (total_blocks < 0) \
|
|
||||||
{ \
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_WARN, "block counter just went negative (this should not happen)\n"); \
|
|
||||||
return; \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
void qt_decode_smc(
|
|
||||||
unsigned char *encoded,
|
|
||||||
int encoded_size,
|
|
||||||
unsigned char *decoded,
|
|
||||||
int pixel_width,
|
|
||||||
int pixel_height,
|
|
||||||
unsigned char *palette_map,
|
|
||||||
int bytes_per_pixel)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int stream_ptr = 0;
|
|
||||||
int chunk_size;
|
|
||||||
unsigned char opcode;
|
|
||||||
int n_blocks;
|
|
||||||
unsigned int color_flags;
|
|
||||||
unsigned int color_flags_a;
|
|
||||||
unsigned int color_flags_b;
|
|
||||||
unsigned int flag_mask;
|
|
||||||
|
|
||||||
int byte_width = pixel_width * bytes_per_pixel; // width of a row in bytes
|
|
||||||
int byte_height = pixel_height * byte_width; // max image size, basically
|
|
||||||
int row_ptr = 0;
|
|
||||||
int pixel_ptr = 0;
|
|
||||||
int pixel_x, pixel_y;
|
|
||||||
int row_inc = bytes_per_pixel * (pixel_width - 4);
|
|
||||||
int block_x_inc = bytes_per_pixel * 4;
|
|
||||||
int block_y_inc = bytes_per_pixel * pixel_width;
|
|
||||||
int block_ptr;
|
|
||||||
int prev_block_ptr;
|
|
||||||
int prev_block_ptr1, prev_block_ptr2;
|
|
||||||
int prev_block_flag;
|
|
||||||
int total_blocks;
|
|
||||||
int color_table_index; // indexes to color pair, quad, or octet tables
|
|
||||||
int color_index; // indexes into palette map
|
|
||||||
|
|
||||||
if (!smc_initialized)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// reset color tables
|
|
||||||
color_pair_index = 0;
|
|
||||||
color_quad_index = 0;
|
|
||||||
color_octet_index = 0;
|
|
||||||
|
|
||||||
chunk_size = BE_32(&encoded[stream_ptr]) & 0x00FFFFFF;
|
|
||||||
stream_ptr += 4;
|
|
||||||
if (chunk_size != encoded_size)
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_WARN, "MOV chunk size != encoded chunk size; using MOV chunk size\n");
|
|
||||||
|
|
||||||
chunk_size = encoded_size;
|
|
||||||
total_blocks = (pixel_width * pixel_height) / (4 * 4);
|
|
||||||
|
|
||||||
// traverse through the blocks
|
|
||||||
while (total_blocks)
|
|
||||||
{
|
|
||||||
// sanity checks
|
|
||||||
// make sure stream ptr hasn't gone out of bounds
|
|
||||||
if (stream_ptr > chunk_size)
|
|
||||||
{
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_ERR,
|
|
||||||
"SMC decoder just went out of bounds (stream ptr = %d, chunk size = %d)\n",
|
|
||||||
stream_ptr, chunk_size);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// make sure the row pointer hasn't gone wild
|
|
||||||
if (row_ptr >= byte_height)
|
|
||||||
{
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_ERR,
|
|
||||||
"SMC decoder just went out of bounds (row ptr = %d, height = %d)\n",
|
|
||||||
row_ptr, byte_height);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
opcode = encoded[stream_ptr++];
|
|
||||||
switch (opcode & 0xF0)
|
|
||||||
{
|
|
||||||
// skip n blocks
|
|
||||||
case 0x00:
|
|
||||||
case 0x10:
|
|
||||||
n_blocks = GET_BLOCK_COUNT;
|
|
||||||
while (n_blocks--)
|
|
||||||
ADVANCE_BLOCK();
|
|
||||||
break;
|
|
||||||
|
|
||||||
// repeat last block n times
|
|
||||||
case 0x20:
|
|
||||||
case 0x30:
|
|
||||||
n_blocks = GET_BLOCK_COUNT;
|
|
||||||
|
|
||||||
// sanity check
|
|
||||||
if ((row_ptr == 0) && (pixel_ptr == 0))
|
|
||||||
{
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_WARN,
|
|
||||||
"encountered repeat block opcode (%02X) but no blocks rendered yet\n",
|
|
||||||
opcode & 0xF0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// figure out where the previous block started
|
|
||||||
if (pixel_ptr == 0)
|
|
||||||
prev_block_ptr1 = (row_ptr - block_y_inc * 4) +
|
|
||||||
byte_width - block_x_inc;
|
|
||||||
else
|
|
||||||
prev_block_ptr1 = row_ptr + pixel_ptr - block_x_inc;
|
|
||||||
|
|
||||||
while (n_blocks--)
|
|
||||||
{
|
|
||||||
block_ptr = row_ptr + pixel_ptr;
|
|
||||||
prev_block_ptr = prev_block_ptr1;
|
|
||||||
for (pixel_y = 0; pixel_y < 4; pixel_y++)
|
|
||||||
{
|
|
||||||
for (pixel_x = 0; pixel_x < 4; pixel_x++)
|
|
||||||
{
|
|
||||||
decoded[block_ptr++] = decoded[prev_block_ptr++];
|
|
||||||
decoded[block_ptr++] = decoded[prev_block_ptr++];
|
|
||||||
decoded[block_ptr++] = decoded[prev_block_ptr++];
|
|
||||||
if (bytes_per_pixel == 4) /* 32bpp */
|
|
||||||
{
|
|
||||||
block_ptr++;
|
|
||||||
prev_block_ptr++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
block_ptr += row_inc;
|
|
||||||
prev_block_ptr += row_inc;
|
|
||||||
}
|
|
||||||
ADVANCE_BLOCK();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
// repeat previous pair of blocks n times
|
|
||||||
case 0x40:
|
|
||||||
case 0x50:
|
|
||||||
n_blocks = GET_BLOCK_COUNT;
|
|
||||||
n_blocks *= 2;
|
|
||||||
|
|
||||||
// sanity check
|
|
||||||
if ((row_ptr == 0) && (pixel_ptr < 2 * block_x_inc))
|
|
||||||
{
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_WARN,
|
|
||||||
"encountered repeat block opcode (%02X) but not enough blocks rendered yet\n",
|
|
||||||
opcode & 0xF0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// figure out where the previous 2 blocks started
|
|
||||||
if (pixel_ptr == 0)
|
|
||||||
prev_block_ptr1 = (row_ptr - block_y_inc * 4) +
|
|
||||||
byte_width - block_x_inc * 2;
|
|
||||||
else if (pixel_ptr == block_x_inc)
|
|
||||||
prev_block_ptr1 = (row_ptr - block_y_inc * 4) +
|
|
||||||
byte_width - block_x_inc;
|
|
||||||
else
|
|
||||||
prev_block_ptr1 = row_ptr + pixel_ptr - block_x_inc * 2;
|
|
||||||
|
|
||||||
if (pixel_ptr == 0)
|
|
||||||
prev_block_ptr2 = (row_ptr - block_y_inc * 4) +
|
|
||||||
(byte_width - block_x_inc);
|
|
||||||
else
|
|
||||||
prev_block_ptr2 = row_ptr + pixel_ptr - block_x_inc;
|
|
||||||
|
|
||||||
prev_block_flag = 0;
|
|
||||||
while (n_blocks--)
|
|
||||||
{
|
|
||||||
block_ptr = row_ptr + pixel_ptr;
|
|
||||||
if (prev_block_flag)
|
|
||||||
prev_block_ptr = prev_block_ptr2;
|
|
||||||
else
|
|
||||||
prev_block_ptr = prev_block_ptr1;
|
|
||||||
prev_block_flag = !prev_block_flag;
|
|
||||||
|
|
||||||
for (pixel_y = 0; pixel_y < 4; pixel_y++)
|
|
||||||
{
|
|
||||||
for (pixel_x = 0; pixel_x < 4; pixel_x++)
|
|
||||||
{
|
|
||||||
decoded[block_ptr++] = decoded[prev_block_ptr++];
|
|
||||||
decoded[block_ptr++] = decoded[prev_block_ptr++];
|
|
||||||
decoded[block_ptr++] = decoded[prev_block_ptr++];
|
|
||||||
if (bytes_per_pixel == 4) /* 32bpp */
|
|
||||||
{
|
|
||||||
block_ptr++;
|
|
||||||
prev_block_ptr++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
block_ptr += row_inc;
|
|
||||||
prev_block_ptr += row_inc;
|
|
||||||
}
|
|
||||||
ADVANCE_BLOCK();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
// 1-color block encoding
|
|
||||||
case 0x60:
|
|
||||||
case 0x70:
|
|
||||||
n_blocks = GET_BLOCK_COUNT;
|
|
||||||
color_index = encoded[stream_ptr++] * 4;
|
|
||||||
|
|
||||||
while (n_blocks--)
|
|
||||||
{
|
|
||||||
block_ptr = row_ptr + pixel_ptr;
|
|
||||||
for (pixel_y = 0; pixel_y < 4; pixel_y++)
|
|
||||||
{
|
|
||||||
for (pixel_x = 0; pixel_x < 4; pixel_x++)
|
|
||||||
{
|
|
||||||
decoded[block_ptr++] = palette_map[color_index + 0];
|
|
||||||
decoded[block_ptr++] = palette_map[color_index + 1];
|
|
||||||
decoded[block_ptr++] = palette_map[color_index + 2];
|
|
||||||
if (bytes_per_pixel == 4) /* 32bpp */
|
|
||||||
block_ptr++;
|
|
||||||
}
|
|
||||||
block_ptr += row_inc;
|
|
||||||
}
|
|
||||||
ADVANCE_BLOCK();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
// 2-color block encoding
|
|
||||||
case 0x80:
|
|
||||||
case 0x90:
|
|
||||||
n_blocks = (opcode & 0x0F) + 1;
|
|
||||||
|
|
||||||
// figure out which color pair to use to paint the 2-color block
|
|
||||||
if ((opcode & 0xF0) == 0x80)
|
|
||||||
{
|
|
||||||
// fetch the next 2 colors from bytestream and store in next
|
|
||||||
// available entry in the color pair table
|
|
||||||
for (i = 0; i < CPAIR; i++)
|
|
||||||
{
|
|
||||||
color_index = encoded[stream_ptr++] * BYTES_PER_COLOR;
|
|
||||||
color_table_index = CPAIR * BYTES_PER_COLOR * color_pair_index +
|
|
||||||
(i * BYTES_PER_COLOR);
|
|
||||||
color_pairs[color_table_index + 0] = palette_map[color_index + 0];
|
|
||||||
color_pairs[color_table_index + 1] = palette_map[color_index + 1];
|
|
||||||
color_pairs[color_table_index + 2] = palette_map[color_index + 2];
|
|
||||||
}
|
|
||||||
// this is the base index to use for this block
|
|
||||||
color_table_index = CPAIR * BYTES_PER_COLOR * color_pair_index;
|
|
||||||
color_pair_index++;
|
|
||||||
if (color_pair_index == COLORS_PER_TABLE)
|
|
||||||
color_pair_index = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
color_table_index = CPAIR * BYTES_PER_COLOR * encoded[stream_ptr++];
|
|
||||||
|
|
||||||
while (n_blocks--)
|
|
||||||
{
|
|
||||||
color_flags = BE_16(&encoded[stream_ptr]);
|
|
||||||
stream_ptr += 2;
|
|
||||||
flag_mask = 0x8000;
|
|
||||||
block_ptr = row_ptr + pixel_ptr;
|
|
||||||
for (pixel_y = 0; pixel_y < 4; pixel_y++)
|
|
||||||
{
|
|
||||||
for (pixel_x = 0; pixel_x < 4; pixel_x++)
|
|
||||||
{
|
|
||||||
if (color_flags & flag_mask)
|
|
||||||
color_index = color_table_index + BYTES_PER_COLOR;
|
|
||||||
else
|
|
||||||
color_index = color_table_index;
|
|
||||||
flag_mask >>= 1;
|
|
||||||
|
|
||||||
decoded[block_ptr++] = color_pairs[color_index + 0];
|
|
||||||
decoded[block_ptr++] = color_pairs[color_index + 1];
|
|
||||||
decoded[block_ptr++] = color_pairs[color_index + 2];
|
|
||||||
if (bytes_per_pixel == 4) /* 32bpp */
|
|
||||||
block_ptr++;
|
|
||||||
}
|
|
||||||
block_ptr += row_inc;
|
|
||||||
}
|
|
||||||
ADVANCE_BLOCK();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
// 4-color block encoding
|
|
||||||
case 0xA0:
|
|
||||||
case 0xB0:
|
|
||||||
n_blocks = (opcode & 0x0F) + 1;
|
|
||||||
|
|
||||||
// figure out which color quad to use to paint the 4-color block
|
|
||||||
if ((opcode & 0xF0) == 0xA0)
|
|
||||||
{
|
|
||||||
// fetch the next 4 colors from bytestream and store in next
|
|
||||||
// available entry in the color quad table
|
|
||||||
for (i = 0; i < CQUAD; i++)
|
|
||||||
{
|
|
||||||
color_index = encoded[stream_ptr++] * BYTES_PER_COLOR;
|
|
||||||
color_table_index = CQUAD * BYTES_PER_COLOR * color_quad_index +
|
|
||||||
(i * BYTES_PER_COLOR);
|
|
||||||
color_quads[color_table_index + 0] = palette_map[color_index + 0];
|
|
||||||
color_quads[color_table_index + 1] = palette_map[color_index + 1];
|
|
||||||
color_quads[color_table_index + 2] = palette_map[color_index + 2];
|
|
||||||
}
|
|
||||||
// this is the base index to use for this block
|
|
||||||
color_table_index = CQUAD * BYTES_PER_COLOR * color_quad_index;
|
|
||||||
color_quad_index++;
|
|
||||||
if (color_quad_index == COLORS_PER_TABLE)
|
|
||||||
color_quad_index = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
color_table_index = CQUAD * BYTES_PER_COLOR * encoded[stream_ptr++];
|
|
||||||
|
|
||||||
while (n_blocks--)
|
|
||||||
{
|
|
||||||
color_flags = BE_32(&encoded[stream_ptr]);
|
|
||||||
stream_ptr += 4;
|
|
||||||
// flag mask actually acts as a bit shift count here
|
|
||||||
flag_mask = 30;
|
|
||||||
block_ptr = row_ptr + pixel_ptr;
|
|
||||||
for (pixel_y = 0; pixel_y < 4; pixel_y++)
|
|
||||||
{
|
|
||||||
for (pixel_x = 0; pixel_x < 4; pixel_x++)
|
|
||||||
{
|
|
||||||
color_index = color_table_index + (BYTES_PER_COLOR *
|
|
||||||
((color_flags >> flag_mask) & 0x03));
|
|
||||||
flag_mask -= 2;
|
|
||||||
|
|
||||||
decoded[block_ptr++] = color_quads[color_index + 0];
|
|
||||||
decoded[block_ptr++] = color_quads[color_index + 1];
|
|
||||||
decoded[block_ptr++] = color_quads[color_index + 2];
|
|
||||||
if (bytes_per_pixel == 4) /* 32bpp */
|
|
||||||
block_ptr++;
|
|
||||||
}
|
|
||||||
block_ptr += row_inc;
|
|
||||||
}
|
|
||||||
ADVANCE_BLOCK();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
// 8-color block encoding
|
|
||||||
case 0xC0:
|
|
||||||
case 0xD0:
|
|
||||||
n_blocks = (opcode & 0x0F) + 1;
|
|
||||||
|
|
||||||
// figure out which color octet to use to paint the 8-color block
|
|
||||||
if ((opcode & 0xF0) == 0xC0)
|
|
||||||
{
|
|
||||||
// fetch the next 8 colors from bytestream and store in next
|
|
||||||
// available entry in the color octet table
|
|
||||||
for (i = 0; i < COCTET; i++)
|
|
||||||
{
|
|
||||||
color_index = encoded[stream_ptr++] * BYTES_PER_COLOR;
|
|
||||||
color_table_index = COCTET * BYTES_PER_COLOR * color_octet_index +
|
|
||||||
(i * BYTES_PER_COLOR);
|
|
||||||
color_octets[color_table_index + 0] = palette_map[color_index + 0];
|
|
||||||
color_octets[color_table_index + 1] = palette_map[color_index + 1];
|
|
||||||
color_octets[color_table_index + 2] = palette_map[color_index + 2];
|
|
||||||
}
|
|
||||||
// this is the base index to use for this block
|
|
||||||
color_table_index = COCTET * BYTES_PER_COLOR * color_octet_index;
|
|
||||||
color_octet_index++;
|
|
||||||
if (color_octet_index == COLORS_PER_TABLE)
|
|
||||||
color_octet_index = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
color_table_index = COCTET * BYTES_PER_COLOR * encoded[stream_ptr++];
|
|
||||||
|
|
||||||
while (n_blocks--)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
For this input:
|
|
||||||
01 23 45 67 89 AB
|
|
||||||
This is the output:
|
|
||||||
flags_a = xx012456, flags_b = xx89A37B
|
|
||||||
*/
|
|
||||||
// build the color flags
|
|
||||||
color_flags_a = color_flags_b = 0;
|
|
||||||
color_flags_a =
|
|
||||||
(encoded[stream_ptr + 0] << 16) |
|
|
||||||
((encoded[stream_ptr + 1] & 0xF0) << 8) |
|
|
||||||
((encoded[stream_ptr + 2] & 0xF0) << 4) |
|
|
||||||
((encoded[stream_ptr + 2] & 0x0F) << 4) |
|
|
||||||
((encoded[stream_ptr + 3] & 0xF0) >> 4);
|
|
||||||
color_flags_b =
|
|
||||||
(encoded[stream_ptr + 4] << 16) |
|
|
||||||
((encoded[stream_ptr + 5] & 0xF0) << 8) |
|
|
||||||
((encoded[stream_ptr + 1] & 0x0F) << 8) |
|
|
||||||
((encoded[stream_ptr + 3] & 0x0F) << 4) |
|
|
||||||
(encoded[stream_ptr + 5] & 0x0F);
|
|
||||||
stream_ptr += 6;
|
|
||||||
|
|
||||||
color_flags = color_flags_a;
|
|
||||||
// flag mask actually acts as a bit shift count here
|
|
||||||
flag_mask = 21;
|
|
||||||
block_ptr = row_ptr + pixel_ptr;
|
|
||||||
for (pixel_y = 0; pixel_y < 4; pixel_y++)
|
|
||||||
{
|
|
||||||
// reload flags at third row (iteration pixel_y == 2)
|
|
||||||
if (pixel_y == 2)
|
|
||||||
{
|
|
||||||
color_flags = color_flags_b;
|
|
||||||
flag_mask = 21;
|
|
||||||
}
|
|
||||||
for (pixel_x = 0; pixel_x < 4; pixel_x++)
|
|
||||||
{
|
|
||||||
color_index = color_table_index + (BYTES_PER_COLOR *
|
|
||||||
((color_flags >> flag_mask) & 0x07));
|
|
||||||
flag_mask -= 3;
|
|
||||||
|
|
||||||
decoded[block_ptr++] = color_octets[color_index + 0];
|
|
||||||
decoded[block_ptr++] = color_octets[color_index + 1];
|
|
||||||
decoded[block_ptr++] = color_octets[color_index + 2];
|
|
||||||
if (bytes_per_pixel == 4) /* 32bpp */
|
|
||||||
block_ptr++;
|
|
||||||
}
|
|
||||||
block_ptr += row_inc;
|
|
||||||
}
|
|
||||||
ADVANCE_BLOCK();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
// 16-color block encoding (every pixel is a different color)
|
|
||||||
case 0xE0:
|
|
||||||
n_blocks = (opcode & 0x0F) + 1;
|
|
||||||
|
|
||||||
while (n_blocks--)
|
|
||||||
{
|
|
||||||
block_ptr = row_ptr + pixel_ptr;
|
|
||||||
for (pixel_y = 0; pixel_y < 4; pixel_y++)
|
|
||||||
{
|
|
||||||
for (pixel_x = 0; pixel_x < 4; pixel_x++)
|
|
||||||
{
|
|
||||||
color_index = encoded[stream_ptr++] * BYTES_PER_COLOR;
|
|
||||||
decoded[block_ptr++] = palette_map[color_index + 0];
|
|
||||||
decoded[block_ptr++] = palette_map[color_index + 1];
|
|
||||||
decoded[block_ptr++] = palette_map[color_index + 2];
|
|
||||||
if (bytes_per_pixel == 4) /* 32bpp */
|
|
||||||
block_ptr++;
|
|
||||||
}
|
|
||||||
block_ptr += row_inc;
|
|
||||||
}
|
|
||||||
ADVANCE_BLOCK();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0xF0:
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_HINT, "0xF0 opcode seen in SMC chunk (MPlayer developers would like to know)\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,435 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include "mp_msg.h"
|
|
||||||
|
|
||||||
#include "vd_internal.h"
|
|
||||||
|
|
||||||
static vd_info_t info = {
|
|
||||||
"Microsoft RLE decoder",
|
|
||||||
"msrle",
|
|
||||||
"Mike Melanson",
|
|
||||||
"Mike Melanson",
|
|
||||||
"native codec"
|
|
||||||
};
|
|
||||||
|
|
||||||
LIBVD_EXTERN(msrle)
|
|
||||||
|
|
||||||
// to set/get/query special features/parameters
|
|
||||||
static int control(sh_video_t *sh,int cmd,void* arg,...){
|
|
||||||
return CONTROL_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
// init driver
|
|
||||||
static int init(sh_video_t *sh){
|
|
||||||
unsigned char *palette_map = NULL;
|
|
||||||
unsigned char *orig_map = (unsigned char *)sh->bih+40;
|
|
||||||
int i;
|
|
||||||
unsigned short color;
|
|
||||||
unsigned char r, g, b;
|
|
||||||
int bits_per_pixel = sh->codec->outfmt[sh->outfmtidx] & 255;
|
|
||||||
|
|
||||||
// convert the palette for the requested output format
|
|
||||||
switch (bits_per_pixel)
|
|
||||||
{
|
|
||||||
case 15:
|
|
||||||
case 16:
|
|
||||||
if ((palette_map =
|
|
||||||
(unsigned char *)malloc(sh->bih->biClrUsed * 2)) == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (i = 0; i < sh->bih->biClrUsed; i++)
|
|
||||||
{
|
|
||||||
r = orig_map[i * 4 + 2];
|
|
||||||
g = orig_map[i * 4 + 1];
|
|
||||||
b = orig_map[i * 4 + 0];
|
|
||||||
if (bits_per_pixel == 15)
|
|
||||||
color = ((r>>3)<<10) | ((g>>3)<<5) | ((b>>3));
|
|
||||||
else
|
|
||||||
color = ((r>>3)<<11) | ((g>>2)<<5) | ((b>>3));
|
|
||||||
palette_map[i * 2 + 1] = color >> 8;
|
|
||||||
palette_map[i * 2 + 0] = color & 0xFF;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 24:
|
|
||||||
case 32:
|
|
||||||
if ((palette_map =
|
|
||||||
(unsigned char *)malloc(sh->bih->biClrUsed * 4)) == NULL)
|
|
||||||
return 0;
|
|
||||||
memcpy(palette_map, orig_map, sh->bih->biClrUsed * 4);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
sh->context = palette_map;
|
|
||||||
|
|
||||||
return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_BGR24);
|
|
||||||
}
|
|
||||||
|
|
||||||
// uninit driver
|
|
||||||
static void uninit(sh_video_t *sh){
|
|
||||||
unsigned char *palette_map = (unsigned char *)sh->context;
|
|
||||||
|
|
||||||
free(palette_map);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define FETCH_NEXT_STREAM_BYTE() \
|
|
||||||
if (stream_ptr >= encoded_size) \
|
|
||||||
{ \
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_WARN, \
|
|
||||||
"MS RLE: stream ptr just went out of bounds (1)\n"); \
|
|
||||||
return; \
|
|
||||||
} \
|
|
||||||
stream_byte = encoded[stream_ptr++];
|
|
||||||
|
|
||||||
void decode_msrle4(
|
|
||||||
unsigned char *encoded,
|
|
||||||
int encoded_size,
|
|
||||||
unsigned char *decoded,
|
|
||||||
int width,
|
|
||||||
int height,
|
|
||||||
unsigned char *palette_map,
|
|
||||||
int bits_per_pixel)
|
|
||||||
{
|
|
||||||
int bytes_per_pixel = (bits_per_pixel + 1) / 8;
|
|
||||||
unsigned char r1, g1, b1; // for 24/32 bpp
|
|
||||||
unsigned char r2, g2, b2;
|
|
||||||
unsigned char color_hi1, color_lo1; // for 15/16 bpp
|
|
||||||
unsigned char color_hi2, color_lo2;
|
|
||||||
int stream_ptr = 0;
|
|
||||||
unsigned char rle_code;
|
|
||||||
unsigned char extra_byte;
|
|
||||||
unsigned char stream_byte;
|
|
||||||
int frame_size = width * height * bytes_per_pixel;
|
|
||||||
int pixel_ptr = 0;
|
|
||||||
int row_dec = width * bytes_per_pixel;
|
|
||||||
int row_ptr = (height - 1) * row_dec;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
r1 = r2 = g1 = g2 = b1 = b2 =
|
|
||||||
color_hi1 = color_hi2 = color_lo1 = color_lo2 = 0;
|
|
||||||
while (row_ptr >= 0)
|
|
||||||
{
|
|
||||||
FETCH_NEXT_STREAM_BYTE();
|
|
||||||
rle_code = stream_byte;
|
|
||||||
if (rle_code == 0)
|
|
||||||
{
|
|
||||||
// fetch the next byte to see how to handle escape code
|
|
||||||
FETCH_NEXT_STREAM_BYTE();
|
|
||||||
if (stream_byte == 0)
|
|
||||||
{
|
|
||||||
// line is done, goto the next one
|
|
||||||
row_ptr -= row_dec;
|
|
||||||
pixel_ptr = 0;
|
|
||||||
}
|
|
||||||
else if (stream_byte == 1)
|
|
||||||
// decode is done
|
|
||||||
return;
|
|
||||||
else if (stream_byte == 2)
|
|
||||||
{
|
|
||||||
// reposition frame decode coordinates
|
|
||||||
FETCH_NEXT_STREAM_BYTE();
|
|
||||||
pixel_ptr += stream_byte * bytes_per_pixel;
|
|
||||||
FETCH_NEXT_STREAM_BYTE();
|
|
||||||
row_ptr -= stream_byte * row_dec;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// copy pixels from encoded stream
|
|
||||||
rle_code = ((stream_byte + 1) & (~1)) / 2;
|
|
||||||
extra_byte = rle_code & 0x01;
|
|
||||||
if ((row_ptr + pixel_ptr + stream_byte * bytes_per_pixel > frame_size) ||
|
|
||||||
(row_ptr < 0))
|
|
||||||
{
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_WARN,
|
|
||||||
"MS RLE: frame ptr just went out of bounds (1)\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < rle_code; i++)
|
|
||||||
{
|
|
||||||
if (pixel_ptr >= row_dec)
|
|
||||||
break;
|
|
||||||
if (bytes_per_pixel == 2)
|
|
||||||
{
|
|
||||||
color_hi1 = palette_map[(encoded[stream_ptr + i] >> 4) * 2 + 0];
|
|
||||||
color_lo1 = palette_map[(encoded[stream_ptr + i] >> 4) * 2 + 1];
|
|
||||||
decoded[row_ptr + pixel_ptr + 0] = color_hi1;
|
|
||||||
decoded[row_ptr + pixel_ptr + 1] = color_lo1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
r1 = palette_map[(encoded[stream_ptr + i] >> 4) * 4 + 2];
|
|
||||||
g1 = palette_map[(encoded[stream_ptr + i] >> 4) * 4 + 1];
|
|
||||||
b1 = palette_map[(encoded[stream_ptr + i] >> 4) * 4 + 0];
|
|
||||||
decoded[row_ptr + pixel_ptr + 0] = b1;
|
|
||||||
decoded[row_ptr + pixel_ptr + 1] = g1;
|
|
||||||
decoded[row_ptr + pixel_ptr + 2] = r1;
|
|
||||||
}
|
|
||||||
pixel_ptr += bytes_per_pixel;
|
|
||||||
|
|
||||||
if (i + 1 == rle_code && (stream_byte & 1) != 0)
|
|
||||||
break;
|
|
||||||
if (pixel_ptr >= row_dec)
|
|
||||||
break;
|
|
||||||
if (bytes_per_pixel == 2)
|
|
||||||
{
|
|
||||||
color_hi1 = palette_map[(encoded[stream_ptr + i] & 0x0F) * 2 + 0];
|
|
||||||
color_lo1 = palette_map[(encoded[stream_ptr + i] & 0x0F) * 2 + 1];
|
|
||||||
decoded[row_ptr + pixel_ptr + 0] = color_hi1;
|
|
||||||
decoded[row_ptr + pixel_ptr + 1] = color_lo1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
r1 = palette_map[(encoded[stream_ptr + i] & 0x0F) * 4 + 2];
|
|
||||||
g1 = palette_map[(encoded[stream_ptr + i] & 0x0F) * 4 + 1];
|
|
||||||
b1 = palette_map[(encoded[stream_ptr + i] & 0x0F) * 4 + 0];
|
|
||||||
decoded[row_ptr + pixel_ptr + 0] = b1;
|
|
||||||
decoded[row_ptr + pixel_ptr + 1] = g1;
|
|
||||||
decoded[row_ptr + pixel_ptr + 2] = r1;
|
|
||||||
}
|
|
||||||
pixel_ptr += bytes_per_pixel;
|
|
||||||
}
|
|
||||||
stream_ptr += rle_code;
|
|
||||||
|
|
||||||
// if the RLE code is odd, skip a byte in the stream
|
|
||||||
if (extra_byte)
|
|
||||||
stream_ptr++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// decode a run of data
|
|
||||||
FETCH_NEXT_STREAM_BYTE();
|
|
||||||
if (bytes_per_pixel == 2)
|
|
||||||
{
|
|
||||||
color_hi1 = palette_map[(stream_byte >> 4) * 2 + 0];
|
|
||||||
color_lo1 = palette_map[(stream_byte >> 4) * 2 + 1];
|
|
||||||
color_hi2 = palette_map[(stream_byte & 0x0F) * 2 + 0];
|
|
||||||
color_lo2 = palette_map[(stream_byte & 0x0F) * 2 + 1];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
r1 = palette_map[(stream_byte >> 4) * 4 + 2];
|
|
||||||
g1 = palette_map[(stream_byte >> 4) * 4 + 1];
|
|
||||||
b1 = palette_map[(stream_byte >> 4) * 4 + 0];
|
|
||||||
r2 = palette_map[(stream_byte & 0x0F) * 4 + 2];
|
|
||||||
g2 = palette_map[(stream_byte & 0x0F) * 4 + 1];
|
|
||||||
b2 = palette_map[(stream_byte & 0x0F) * 4 + 0];
|
|
||||||
}
|
|
||||||
for (i = 0; i < rle_code; i++)
|
|
||||||
{
|
|
||||||
if (pixel_ptr >= row_dec)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if ((i & 1) == 0)
|
|
||||||
{
|
|
||||||
if (bytes_per_pixel == 2)
|
|
||||||
{
|
|
||||||
decoded[row_ptr + pixel_ptr + 0] = color_hi1;
|
|
||||||
decoded[row_ptr + pixel_ptr + 1] = color_lo1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
decoded[row_ptr + pixel_ptr + 0] = b1;
|
|
||||||
decoded[row_ptr + pixel_ptr + 1] = g1;
|
|
||||||
decoded[row_ptr + pixel_ptr + 2] = r1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (bytes_per_pixel == 2)
|
|
||||||
{
|
|
||||||
decoded[row_ptr + pixel_ptr + 0] = color_hi2;
|
|
||||||
decoded[row_ptr + pixel_ptr + 1] = color_lo2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
decoded[row_ptr + pixel_ptr + 0] = b2;
|
|
||||||
decoded[row_ptr + pixel_ptr + 1] = g2;
|
|
||||||
decoded[row_ptr + pixel_ptr + 2] = r2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pixel_ptr += bytes_per_pixel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// one last sanity check on the way out
|
|
||||||
if (stream_ptr < encoded_size)
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_WARN,
|
|
||||||
"MS RLE: ended frame decode with bytes left over (%d < %d)\n",
|
|
||||||
stream_ptr, encoded_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void decode_msrle8(
|
|
||||||
unsigned char *encoded,
|
|
||||||
int encoded_size,
|
|
||||||
unsigned char *decoded,
|
|
||||||
int width,
|
|
||||||
int height,
|
|
||||||
unsigned char *palette_map,
|
|
||||||
int bits_per_pixel)
|
|
||||||
{
|
|
||||||
int bytes_per_pixel = (bits_per_pixel + 1) / 8;
|
|
||||||
unsigned char r, g, b; // for 24/32 bpp
|
|
||||||
unsigned char color_hi, color_lo; // for 15/16 bpp
|
|
||||||
int stream_ptr = 0;
|
|
||||||
unsigned char rle_code;
|
|
||||||
unsigned char extra_byte;
|
|
||||||
unsigned char stream_byte;
|
|
||||||
int frame_size = width * height * bytes_per_pixel;
|
|
||||||
int pixel_ptr = 0;
|
|
||||||
int row_dec = width * bytes_per_pixel;
|
|
||||||
int row_ptr = (height - 1) * row_dec;
|
|
||||||
|
|
||||||
r = g = b = color_hi = color_lo = 0;
|
|
||||||
while (row_ptr >= 0)
|
|
||||||
{
|
|
||||||
FETCH_NEXT_STREAM_BYTE();
|
|
||||||
rle_code = stream_byte;
|
|
||||||
if (rle_code == 0)
|
|
||||||
{
|
|
||||||
// fetch the next byte to see how to handle escape code
|
|
||||||
FETCH_NEXT_STREAM_BYTE();
|
|
||||||
if (stream_byte == 0)
|
|
||||||
{
|
|
||||||
// line is done, goto the next one
|
|
||||||
row_ptr -= row_dec;
|
|
||||||
pixel_ptr = 0;
|
|
||||||
}
|
|
||||||
else if (stream_byte == 1)
|
|
||||||
// decode is done
|
|
||||||
return;
|
|
||||||
else if (stream_byte == 2)
|
|
||||||
{
|
|
||||||
// reposition frame decode coordinates
|
|
||||||
FETCH_NEXT_STREAM_BYTE();
|
|
||||||
pixel_ptr += stream_byte * bytes_per_pixel;
|
|
||||||
FETCH_NEXT_STREAM_BYTE();
|
|
||||||
row_ptr -= stream_byte * row_dec;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// copy pixels from encoded stream
|
|
||||||
if ((row_ptr + pixel_ptr + stream_byte * bytes_per_pixel > frame_size) ||
|
|
||||||
(row_ptr < 0))
|
|
||||||
{
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_WARN,
|
|
||||||
"MS RLE: frame ptr just went out of bounds (1)\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
rle_code = stream_byte;
|
|
||||||
extra_byte = stream_byte & 0x01;
|
|
||||||
if (stream_ptr + rle_code + extra_byte > encoded_size)
|
|
||||||
{
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_WARN,
|
|
||||||
"MS RLE: stream ptr just went out of bounds (2)\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (rle_code--)
|
|
||||||
{
|
|
||||||
FETCH_NEXT_STREAM_BYTE();
|
|
||||||
if (bytes_per_pixel == 2)
|
|
||||||
{
|
|
||||||
color_hi = palette_map[stream_byte * 2 + 0];
|
|
||||||
color_lo = palette_map[stream_byte * 2 + 1];
|
|
||||||
decoded[row_ptr + pixel_ptr + 0] = color_hi;
|
|
||||||
decoded[row_ptr + pixel_ptr + 1] = color_lo;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
r = palette_map[stream_byte * 4 + 2];
|
|
||||||
g = palette_map[stream_byte * 4 + 1];
|
|
||||||
b = palette_map[stream_byte * 4 + 0];
|
|
||||||
decoded[row_ptr + pixel_ptr + 0] = b;
|
|
||||||
decoded[row_ptr + pixel_ptr + 1] = g;
|
|
||||||
decoded[row_ptr + pixel_ptr + 2] = r;
|
|
||||||
}
|
|
||||||
pixel_ptr += bytes_per_pixel;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the RLE code is odd, skip a byte in the stream
|
|
||||||
if (extra_byte)
|
|
||||||
stream_ptr++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// decode a run of data
|
|
||||||
if ((row_ptr + pixel_ptr + stream_byte * bytes_per_pixel > frame_size) ||
|
|
||||||
(row_ptr < 0))
|
|
||||||
{
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_WARN,
|
|
||||||
"MS RLE: frame ptr just went out of bounds (2)\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FETCH_NEXT_STREAM_BYTE();
|
|
||||||
|
|
||||||
if (bytes_per_pixel == 2)
|
|
||||||
{
|
|
||||||
color_hi = palette_map[stream_byte * 2 + 0];
|
|
||||||
color_lo = palette_map[stream_byte * 2 + 1];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
r = palette_map[stream_byte * 4 + 2];
|
|
||||||
g = palette_map[stream_byte * 4 + 1];
|
|
||||||
b = palette_map[stream_byte * 4 + 0];
|
|
||||||
}
|
|
||||||
while(rle_code--)
|
|
||||||
{
|
|
||||||
if (bytes_per_pixel == 2)
|
|
||||||
{
|
|
||||||
decoded[row_ptr + pixel_ptr + 0] = color_hi;
|
|
||||||
decoded[row_ptr + pixel_ptr + 1] = color_lo;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
decoded[row_ptr + pixel_ptr + 0] = b;
|
|
||||||
decoded[row_ptr + pixel_ptr + 1] = g;
|
|
||||||
decoded[row_ptr + pixel_ptr + 2] = r;
|
|
||||||
}
|
|
||||||
pixel_ptr += bytes_per_pixel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// one last sanity check on the way out
|
|
||||||
if (stream_ptr < encoded_size)
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_WARN,
|
|
||||||
"MS RLE: ended frame decode with bytes left over (%d < %d)\n",
|
|
||||||
stream_ptr, encoded_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
|
|
||||||
if (sh->format == 1)
|
|
||||||
decode_msrle8(
|
|
||||||
data,len, mpi->planes[0],
|
|
||||||
sh->disp_w, sh->disp_h,
|
|
||||||
(unsigned char *)sh->context,
|
|
||||||
mpi->imgfmt & 255);
|
|
||||||
else if (sh->format == 2)
|
|
||||||
decode_msrle4(
|
|
||||||
data,len, mpi->planes[0],
|
|
||||||
sh->disp_w, sh->disp_h,
|
|
||||||
(unsigned char *)sh->context,
|
|
||||||
mpi->imgfmt & 255);
|
|
||||||
else
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_WARN,
|
|
||||||
"MS RLE: Don't know how to decode format %08X", sh->format);
|
|
||||||
|
|
||||||
return mpi;
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include "mp_msg.h"
|
|
||||||
|
|
||||||
#include "vd_internal.h"
|
|
||||||
|
|
||||||
static vd_info_t info = {
|
|
||||||
"Microsoft Video 1 / CRAM decoder",
|
|
||||||
"msvidc",
|
|
||||||
"A'rpi",
|
|
||||||
"Mike Melanson",
|
|
||||||
"native codec"
|
|
||||||
};
|
|
||||||
|
|
||||||
LIBVD_EXTERN(msvidc)
|
|
||||||
|
|
||||||
// to set/get/query special features/parameters
|
|
||||||
static int control(sh_video_t *sh,int cmd,void* arg,...){
|
|
||||||
return CONTROL_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
// init driver
|
|
||||||
static int init(sh_video_t *sh){
|
|
||||||
return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_BGR24);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
void AVI_Decode_Video1_16(
|
|
||||||
char *encoded,
|
|
||||||
int encoded_size,
|
|
||||||
char *decoded,
|
|
||||||
int width,
|
|
||||||
int height,
|
|
||||||
int bytes_per_pixel);
|
|
||||||
|
|
||||||
void AVI_Decode_Video1_8(
|
|
||||||
char *encoded,
|
|
||||||
int encoded_size,
|
|
||||||
char *decoded,
|
|
||||||
int width,
|
|
||||||
int height,
|
|
||||||
unsigned char *palette_map,
|
|
||||||
int bytes_per_pixel);
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
|
|
||||||
if (sh->bih->biBitCount == 16)
|
|
||||||
AVI_Decode_Video1_16(
|
|
||||||
data, len, mpi->planes[0],
|
|
||||||
sh->disp_w, sh->disp_h,
|
|
||||||
mpi->bpp/8);
|
|
||||||
else
|
|
||||||
AVI_Decode_Video1_8(
|
|
||||||
data, len, mpi->planes[0],
|
|
||||||
sh->disp_w, sh->disp_h,
|
|
||||||
(unsigned char *)sh->bih+40,
|
|
||||||
mpi->bpp/8);
|
|
||||||
|
|
||||||
return mpi;
|
|
||||||
}
|
|
@ -1,228 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* QuickTime 8BPS decoder for Mplayer
|
|
||||||
* (c) 2003 Roberto Togni
|
|
||||||
*
|
|
||||||
* Fourcc: 8BPS
|
|
||||||
*
|
|
||||||
* Supports 8bpp (paletted), 24bpp and 32bpp (4th plane ignored)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include "bswap.h"
|
|
||||||
|
|
||||||
#include "mp_msg.h"
|
|
||||||
|
|
||||||
#include "vd_internal.h"
|
|
||||||
|
|
||||||
|
|
||||||
static vd_info_t info = {
|
|
||||||
"8BPS Video decoder",
|
|
||||||
"qt8bps",
|
|
||||||
"Roberto Togni",
|
|
||||||
"Roberto Togni",
|
|
||||||
"native codec"
|
|
||||||
};
|
|
||||||
|
|
||||||
LIBVD_EXTERN(qt8bps)
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Decoder context
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
unsigned char planes;
|
|
||||||
unsigned char planemap[4];
|
|
||||||
unsigned char *palette;
|
|
||||||
} qt8bps_context_t;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Internal function prototypes
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// to set/get/query special features/parameters
|
|
||||||
static int control(sh_video_t *sh,int cmd,void* arg,...)
|
|
||||||
{
|
|
||||||
qt8bps_context_t *hc = (qt8bps_context_t *) sh->context; // Decoder context
|
|
||||||
|
|
||||||
if (cmd == VDCTRL_QUERY_FORMAT)
|
|
||||||
switch (hc->planes) {
|
|
||||||
case 1:
|
|
||||||
if (*((int*)arg) == IMGFMT_BGR8)
|
|
||||||
return CONTROL_TRUE;
|
|
||||||
else
|
|
||||||
return CONTROL_FALSE;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
case 4:
|
|
||||||
if ((*((int*)arg) == IMGFMT_BGR24) || (*((int*)arg) == IMGFMT_BGR32))
|
|
||||||
return CONTROL_TRUE;
|
|
||||||
else
|
|
||||||
return CONTROL_FALSE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return CONTROL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return CONTROL_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Init 8BPS decoder
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static int init(sh_video_t *sh)
|
|
||||||
{
|
|
||||||
int vo_ret; // Video output init ret value
|
|
||||||
qt8bps_context_t *hc; // Decoder context
|
|
||||||
BITMAPINFOHEADER *bih = sh->bih;
|
|
||||||
|
|
||||||
if ((hc = malloc(sizeof(qt8bps_context_t))) == NULL) {
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Can't allocate memory for 8BPS decoder context.\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
sh->context = (void *)hc;
|
|
||||||
hc->palette = NULL;
|
|
||||||
|
|
||||||
switch (bih->biBitCount) {
|
|
||||||
case 8:
|
|
||||||
hc->planes = 1;
|
|
||||||
hc->planemap[0] = 0; // 1st plane is palette indexes
|
|
||||||
if (bih->biSize > sizeof(BITMAPINFOHEADER)) {
|
|
||||||
hc->palette = (unsigned char *)malloc(256*4);
|
|
||||||
memcpy(hc->palette, (unsigned char*)bih + sizeof(BITMAPINFOHEADER), 256*4);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 24:
|
|
||||||
hc->planes = 3;
|
|
||||||
hc->planemap[0] = 2; // 1st plane is red
|
|
||||||
hc->planemap[1] = 1; // 2nd plane is green
|
|
||||||
hc->planemap[2] = 0; // 3rd plane is blue
|
|
||||||
break;
|
|
||||||
case 32:
|
|
||||||
hc->planes = 4;
|
|
||||||
hc->planemap[0] = 2; // 1st plane is red
|
|
||||||
hc->planemap[1] = 1; // 2nd plane is green
|
|
||||||
hc->planemap[2] = 0; // 3rd plane is blue
|
|
||||||
hc->planemap[3] = 3; // 4th plane is alpha???
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_WARN, "[8BPS] Ignoring 4th (alpha?) plane.\n");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[8BPS] Unsupported color depth: %u.\n", bih->biBitCount);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize video output device
|
|
||||||
*/
|
|
||||||
vo_ret = mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_BGR24);
|
|
||||||
|
|
||||||
return vo_ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Uninit 8BPS decoder
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static void uninit(sh_video_t *sh)
|
|
||||||
{
|
|
||||||
qt8bps_context_t *hc = (qt8bps_context_t *) sh->context; // Decoder context
|
|
||||||
|
|
||||||
if (sh->context) {
|
|
||||||
if (hc->palette)
|
|
||||||
free (hc->palette);
|
|
||||||
free(sh->context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Decode a frame
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags)
|
|
||||||
{
|
|
||||||
mp_image_t* mpi;
|
|
||||||
unsigned char *encoded = (unsigned char *)data;
|
|
||||||
qt8bps_context_t *hc = (qt8bps_context_t *) sh->context; // Decoder context
|
|
||||||
unsigned char *outptr, *pixptr;
|
|
||||||
unsigned int height = sh->disp_h; // Real image height
|
|
||||||
unsigned int dlen, p, row;
|
|
||||||
unsigned char *lp, *dp;
|
|
||||||
unsigned char count;
|
|
||||||
unsigned int px_inc;
|
|
||||||
unsigned int planes = hc->planes;
|
|
||||||
unsigned char *planemap = hc->planemap;
|
|
||||||
|
|
||||||
|
|
||||||
// Skipped frame
|
|
||||||
if(len <= 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* Get output image buffer */
|
|
||||||
mpi=mpcodecs_get_image(sh, MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE, sh->disp_w, sh->disp_h);
|
|
||||||
if (!mpi) {
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Can't allocate mpi image for 8BPS codec.\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
outptr = mpi->planes[0]; // Output image pointer
|
|
||||||
px_inc = mpi->bpp/8;
|
|
||||||
|
|
||||||
/* Set data pointer after line lengths */
|
|
||||||
dp = encoded + hc->planes*(height << 1);
|
|
||||||
|
|
||||||
/* Ignore alpha plane, don't know what to do with it */
|
|
||||||
if (planes == 4)
|
|
||||||
planes--;
|
|
||||||
|
|
||||||
for (p = 0; p < planes; p++) {
|
|
||||||
/* Lines length pointer for this plane */
|
|
||||||
lp = encoded + p*(height << 1);
|
|
||||||
|
|
||||||
/* Decode a plane */
|
|
||||||
for(row = 0; row < height; row++) {
|
|
||||||
pixptr = outptr + row * mpi->stride[0] + planemap[p];
|
|
||||||
dlen = be2me_16(*(unsigned short *)(lp+row*2));
|
|
||||||
/* Decode a row of this plane */
|
|
||||||
while(dlen > 0) {
|
|
||||||
if ((count = *dp++) <= 127) {
|
|
||||||
count++;
|
|
||||||
dlen -= count + 1;
|
|
||||||
while(count--) {
|
|
||||||
*pixptr = *dp++;
|
|
||||||
pixptr += px_inc;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
count = 257 - count;
|
|
||||||
while(count--) {
|
|
||||||
*pixptr = *dp;
|
|
||||||
pixptr += px_inc;
|
|
||||||
}
|
|
||||||
dp++;
|
|
||||||
dlen -= 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hc->palette)
|
|
||||||
mpi->planes[1] = hc->palette;
|
|
||||||
|
|
||||||
return mpi;
|
|
||||||
}
|
|
@ -1,53 +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 Apple Video",
|
|
||||||
"qtrpza",
|
|
||||||
"Roberto Togni",
|
|
||||||
"Roberto Togni",
|
|
||||||
"native codec"
|
|
||||||
};
|
|
||||||
|
|
||||||
LIBVD_EXTERN(qtrpza)
|
|
||||||
|
|
||||||
// to set/get/query special features/parameters
|
|
||||||
static int control(sh_video_t *sh,int cmd,void* arg,...){
|
|
||||||
return CONTROL_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
// init driver
|
|
||||||
static int init(sh_video_t *sh){
|
|
||||||
return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_BGR15);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
void qt_decode_rpza(char *encoded, int encodec_size, char *decodec, int width, int height, int bytes_per_pixel);
|
|
||||||
|
|
||||||
// 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){ // temporary!
|
|
||||||
printf("couldn't allocate image for qtrpza codec\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
qt_decode_rpza(data, len, mpi->planes[0], sh->disp_w, sh->disp_h,
|
|
||||||
mpi->bpp/8);
|
|
||||||
|
|
||||||
return mpi;
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include "mp_msg.h"
|
|
||||||
|
|
||||||
#include "vd_internal.h"
|
|
||||||
|
|
||||||
static vd_info_t info = {
|
|
||||||
"Apple Graphics (SMC) decoder",
|
|
||||||
"qtsmc",
|
|
||||||
"A'rpi",
|
|
||||||
"Mike Melanson",
|
|
||||||
"native codec"
|
|
||||||
};
|
|
||||||
|
|
||||||
LIBVD_EXTERN(qtsmc)
|
|
||||||
|
|
||||||
// to set/get/query special features/parameters
|
|
||||||
static int control(sh_video_t *sh,int cmd,void* arg,...){
|
|
||||||
return CONTROL_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
int qt_init_decode_smc(void);
|
|
||||||
|
|
||||||
// init driver
|
|
||||||
static int init(sh_video_t *sh){
|
|
||||||
if (qt_init_decode_smc() != 0){
|
|
||||||
mp_msg(MSGT_DECVIDEO, MSGL_ERR, "SMC decoder could not allocate enough memory");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_BGR24);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
void qt_decode_smc(
|
|
||||||
unsigned char *encoded,
|
|
||||||
int encoded_size,
|
|
||||||
unsigned char *decoded,
|
|
||||||
int width,
|
|
||||||
int height,
|
|
||||||
unsigned char *palette_map,
|
|
||||||
int bytes_per_pixel);
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
|
|
||||||
qt_decode_smc(
|
|
||||||
data,len, mpi->planes[0],
|
|
||||||
sh->disp_w, sh->disp_h,
|
|
||||||
(unsigned char *)sh->bih+40,
|
|
||||||
mpi->bpp/8);
|
|
||||||
|
|
||||||
return mpi;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user