Commit 2fdf638b authored by Mike Melanson's avatar Mike Melanson

New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &

Video-1, Apple RPZA, Cinepak, Westwood IMA ADPCM

Originally committed as revision 2324 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent f2f6134b
...@@ -16,4 +16,6 @@ Michael Niedermayer ...@@ -16,4 +16,6 @@ Michael Niedermayer
Franois Revol Franois Revol
Dieter Shirley Dieter Shirley
Juan J. Sierralta Juan J. Sierralta
Ewald Snel
Roberto Togni
Lionel Ulmer Lionel Ulmer
version <next>:
- Microsoft RLE video decoder
- Microsoft Video-1 decoder
- Apple Video (RPZA) decoder
- Cinepak decoder
- Sega FILM (CPK) file demuxer
- Westwood multimedia support (VQA/AUD file demuxer, audio decoder)
version 0.4.8: version 0.4.8:
- MPEG2 video encoding (Michael) - MPEG2 video encoding (Michael)
......
...@@ -628,6 +628,10 @@ library: ...@@ -628,6 +628,10 @@ library:
@tab format used in various Interplay computer games @tab format used in various Interplay computer games
@item WC3 Movie @tab @tab X @item WC3 Movie @tab @tab X
@tab multimedia format used in Origin's Wing Commander III computer game @tab multimedia format used in Origin's Wing Commander III computer game
@item Sega FILM/CPK @tab @tab X
@tab used in many Sega Saturn console games
@item Westwood Studios VQA/AUD @tab @tab X
@tab Multimedia formats used in Westwood Studios games
@end multitable @end multitable
@code{X} means that the encoding (resp. decoding) is supported. @code{X} means that the encoding (resp. decoding) is supported.
...@@ -682,6 +686,10 @@ following image formats are supported: ...@@ -682,6 +686,10 @@ following image formats are supported:
@item Id RoQ @tab @tab X @tab used in Quake III, Jedi Knight 2, other computer games @item Id RoQ @tab @tab X @tab used in Quake III, Jedi Knight 2, other computer games
@item Xan/WC3 @tab @tab X @tab used in Wing Commander III .MVE files @item Xan/WC3 @tab @tab X @tab used in Wing Commander III .MVE files
@item Interplay Video @tab @tab X @tab used in Interplay .MVE files @item Interplay Video @tab @tab X @tab used in Interplay .MVE files
@item Apple Video @tab @tab X @tab fourcc: rpza
@item Cinepak @tab @tab X
@item Microsoft RLE @tab @tab X
@item Microsoft Video-1 @tab @tab X
@end multitable @end multitable
@code{X} means that the encoding (resp. decoding) is supported. @code{X} means that the encoding (resp. decoding) is supported.
...@@ -710,6 +718,8 @@ solutions. ...@@ -710,6 +718,8 @@ solutions.
@tab used in some Sega Saturn console games @tab used in some Sega Saturn console games
@item Duck DK4 IMA ADPCM @tab @tab X @item Duck DK4 IMA ADPCM @tab @tab X
@tab used in some Sega Saturn console games @tab used in some Sega Saturn console games
@item Westwood Studios IMA ADPCM @tab @tab X
@tab used in Westwood Studios games likes Command and Conquer
@item RA144 @tab @tab X @item RA144 @tab @tab X
@tab Real 14400 bit/s codec @tab Real 14400 bit/s codec
@item RA288 @tab @tab X @item RA288 @tab @tab X
......
...@@ -17,7 +17,8 @@ OBJS= common.o utils.o mem.o allcodecs.o \ ...@@ -17,7 +17,8 @@ OBJS= common.o utils.o mem.o allcodecs.o \
ratecontrol.o adpcm.o eval.o dv.o error_resilience.o \ ratecontrol.o adpcm.o eval.o dv.o error_resilience.o \
fft.o mdct.o mace.o huffyuv.o cyuv.o opts.o raw.o h264.o golomb.o \ fft.o mdct.o mace.o huffyuv.o cyuv.o opts.o raw.o h264.o golomb.o \
vp3.o asv1.o 4xm.o cabac.o ffv1.o ra144.o ra288.o vcr1.o cljr.o \ vp3.o asv1.o 4xm.o cabac.o ffv1.o ra144.o ra288.o vcr1.o cljr.o \
roqvideo.o dpcm.o interplayvideo.o xan.o roqvideo.o dpcm.o interplayvideo.o xan.o rpza.o cinepak.o msrle.o \
msvideo1.o
ifeq ($(AMR_NB),yes) ifeq ($(AMR_NB),yes)
ifeq ($(AMR_NB_FIXED),yes) ifeq ($(AMR_NB_FIXED),yes)
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
* @file adpcm.c * @file adpcm.c
* ADPCM codecs. * ADPCM codecs.
* First version by Francois Revol revol@free.fr * First version by Francois Revol revol@free.fr
* Fringe ADPCM codecs (e.g., DK3 and DK4) * Fringe ADPCM codecs (e.g., DK3, DK4, Westwood)
* by Mike Melanson (melanson@pcisys.net) * by Mike Melanson (melanson@pcisys.net)
* *
* Features and limitations: * Features and limitations:
...@@ -658,6 +658,25 @@ static int adpcm_decode_frame(AVCodecContext *avctx, ...@@ -658,6 +658,25 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
*samples++ = c->status[0].predictor - c->status[1].predictor; *samples++ = c->status[0].predictor - c->status[1].predictor;
} }
break; break;
case CODEC_ID_ADPCM_IMA_WS:
/* no per-block initialization; just start decoding the data */
while (src < buf + buf_size) {
if (st) {
*samples++ = adpcm_ima_expand_nibble(&c->status[0],
(src[0] >> 4) & 0x0F);
*samples++ = adpcm_ima_expand_nibble(&c->status[1],
src[0] & 0x0F);
} else {
*samples++ = adpcm_ima_expand_nibble(&c->status[0],
(src[0] >> 4) & 0x0F);
*samples++ = adpcm_ima_expand_nibble(&c->status[0],
src[0] & 0x0F);
}
src++;
}
break;
default: default:
*data_size = 0; *data_size = 0;
return -1; return -1;
...@@ -692,6 +711,7 @@ ADPCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt); ...@@ -692,6 +711,7 @@ ADPCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
ADPCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav); ADPCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
ADPCM_CODEC(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3); ADPCM_CODEC(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3);
ADPCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4); ADPCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4);
ADPCM_CODEC(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws);
ADPCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms); ADPCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
ADPCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm); ADPCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
......
...@@ -123,6 +123,10 @@ void avcodec_register_all(void) ...@@ -123,6 +123,10 @@ void avcodec_register_all(void)
register_avcodec(&roq_decoder); register_avcodec(&roq_decoder);
register_avcodec(&interplay_video_decoder); register_avcodec(&interplay_video_decoder);
register_avcodec(&xan_wc3_decoder); register_avcodec(&xan_wc3_decoder);
register_avcodec(&rpza_decoder);
register_avcodec(&cinepak_decoder);
register_avcodec(&msrle_decoder);
register_avcodec(&msvideo1_decoder);
#ifdef CONFIG_AC3 #ifdef CONFIG_AC3
register_avcodec(&ac3_decoder); register_avcodec(&ac3_decoder);
#endif #endif
...@@ -163,6 +167,7 @@ PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt); ...@@ -163,6 +167,7 @@ PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav); PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
PCM_CODEC(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3); PCM_CODEC(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3);
PCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4); PCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4);
PCM_CODEC(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws);
PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms); PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm); PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
......
...@@ -74,6 +74,11 @@ enum CodecID { ...@@ -74,6 +74,11 @@ enum CodecID {
CODEC_ID_INTERPLAY_VIDEO, CODEC_ID_INTERPLAY_VIDEO,
CODEC_ID_XAN_WC3, CODEC_ID_XAN_WC3,
CODEC_ID_XAN_WC4, CODEC_ID_XAN_WC4,
CODEC_ID_RPZA,
CODEC_ID_CINEPAK,
CODEC_ID_WS_VQA,
CODEC_ID_MSRLE,
CODEC_ID_MSVIDEO1,
/* various pcm "codecs" */ /* various pcm "codecs" */
CODEC_ID_PCM_S16LE, CODEC_ID_PCM_S16LE,
...@@ -90,6 +95,7 @@ enum CodecID { ...@@ -90,6 +95,7 @@ enum CodecID {
CODEC_ID_ADPCM_IMA_WAV, CODEC_ID_ADPCM_IMA_WAV,
CODEC_ID_ADPCM_IMA_DK3, CODEC_ID_ADPCM_IMA_DK3,
CODEC_ID_ADPCM_IMA_DK4, CODEC_ID_ADPCM_IMA_DK4,
CODEC_ID_ADPCM_IMA_WS,
CODEC_ID_ADPCM_MS, CODEC_ID_ADPCM_MS,
CODEC_ID_ADPCM_4XM, CODEC_ID_ADPCM_4XM,
...@@ -1419,6 +1425,10 @@ extern AVCodec mdec_decoder; ...@@ -1419,6 +1425,10 @@ extern AVCodec mdec_decoder;
extern AVCodec roq_decoder; extern AVCodec roq_decoder;
extern AVCodec interplay_video_decoder; extern AVCodec interplay_video_decoder;
extern AVCodec xan_wc3_decoder; extern AVCodec xan_wc3_decoder;
extern AVCodec rpza_decoder;
extern AVCodec cinepak_decoder;
extern AVCodec msrle_decoder;
extern AVCodec msvideo1_decoder;
extern AVCodec ra_144_decoder; extern AVCodec ra_144_decoder;
extern AVCodec ra_288_decoder; extern AVCodec ra_288_decoder;
extern AVCodec roq_dpcm_decoder; extern AVCodec roq_dpcm_decoder;
...@@ -1445,6 +1455,7 @@ PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt); ...@@ -1445,6 +1455,7 @@ PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav); PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
PCM_CODEC(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3); PCM_CODEC(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3);
PCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4); PCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4);
PCM_CODEC(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws);
PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms); PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm); PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
......
This diff is collapsed.
/*
* Micrsoft RLE Video Decoder
* Copyright (C) 2003 the ffmpeg project
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* @file msrle.c
* MS RLE Video Decoder by Mike Melanson (melanson@pcisys.net)
* For more information about the MS RLE format, visit:
* http://www.pcisys.net/~melanson/codecs/
*
* The MS RLE decoder outputs PAL8 colorspace data.
*
* Note that this decoder expects the palette colors from the end of the
* BITMAPINFO header passed through extradata.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "common.h"
#include "avcodec.h"
#include "dsputil.h"
typedef struct MsrleContext {
AVCodecContext *avctx;
AVFrame frame;
AVFrame prev_frame;
unsigned char *buf;
int size;
unsigned int palette[256];
} MsrleContext;
#define FETCH_NEXT_STREAM_BYTE() \
if (stream_ptr >= s->size) \
{ \
printf(" MS RLE: stream ptr just went out of bounds (1)\n"); \
return; \
} \
stream_byte = s->buf[stream_ptr++];
static void msrle_decode_pal8(MsrleContext *s)
{
int stream_ptr = 0;
unsigned char rle_code;
unsigned char extra_byte;
unsigned char stream_byte;
int pixel_ptr = 0;
int row_dec = s->frame.linesize[0];
int row_ptr = (s->avctx->height - 1) * row_dec;
int frame_size = row_dec * s->avctx->height;
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;
FETCH_NEXT_STREAM_BYTE();
row_ptr -= stream_byte * row_dec;
} else {
/* copy pixels from encoded stream */
if ((row_ptr + pixel_ptr + stream_byte > frame_size) ||
(row_ptr < 0)) {
printf(" 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 > s->size) {
printf(" MS RLE: stream ptr just went out of bounds (2)\n");
return;
}
while (rle_code--) {
FETCH_NEXT_STREAM_BYTE();
s->frame.data[0][row_ptr + pixel_ptr] = stream_byte;
pixel_ptr++;
}
/* 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 > frame_size) ||
(row_ptr < 0)) {
printf(" MS RLE: frame ptr just went out of bounds (2)\n");
return;
}
FETCH_NEXT_STREAM_BYTE();
while(rle_code--) {
s->frame.data[0][row_ptr + pixel_ptr] = stream_byte;
pixel_ptr++;
}
}
}
/* make the palette available */
memcpy(s->frame.data[1], s->palette, 256 * 4);
/* one last sanity check on the way out */
if (stream_ptr < s->size)
printf(" MS RLE: ended frame decode with bytes left over (%d < %d)\n",
stream_ptr, s->size);
}
static int msrle_decode_init(AVCodecContext *avctx)
{
MsrleContext *s = (MsrleContext *)avctx->priv_data;
int i, j;
unsigned char *palette;
s->avctx = avctx;
avctx->pix_fmt = PIX_FMT_PAL8;
avctx->has_b_frames = 0;
s->frame.data[0] = s->prev_frame.data[0] = NULL;
/* convert palette */
palette = (unsigned char *)s->avctx->extradata;
memset (s->palette, 0, 256 * 4);
for (i = 0, j = 0; i < s->avctx->extradata_size / 4; i++, j += 4)
s->palette[i] =
(palette[j + 2] << 16) |
(palette[j + 1] << 8) |
(palette[j + 0] << 0);
return 0;
}
static int msrle_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
MsrleContext *s = (MsrleContext *)avctx->priv_data;
s->buf = buf;
s->size = buf_size;
if (avctx->get_buffer(avctx, &s->frame)) {
printf (" MS RLE: get_buffer() failed\n");
return -1;
}
/* grossly inefficient, but...oh well */
memcpy(s->frame.data[0], s->prev_frame.data[0],
s->frame.linesize[0] * s->avctx->height);
msrle_decode_pal8(s);
if (s->frame.data[0])
avctx->release_buffer(avctx, &s->frame);
/* shuffle frames */
s->prev_frame = s->frame;
*data_size = sizeof(AVFrame);
*(AVFrame*)data = s->frame;
/* report that the buffer was completely consumed */
return buf_size;
}
static int msrle_decode_end(AVCodecContext *avctx)
{
MsrleContext *s = (MsrleContext *)avctx->priv_data;
/* release the last frame */
if (s->prev_frame.data[0])
avctx->release_buffer(avctx, &s->prev_frame);
return 0;
}
AVCodec msrle_decoder = {
"msrle",
CODEC_TYPE_VIDEO,
CODEC_ID_MSRLE,
sizeof(MsrleContext),
msrle_decode_init,
NULL,
msrle_decode_end,
msrle_decode_frame,
CODEC_CAP_DR1,
};
This diff is collapsed.
/*
* Quicktime Video (RPZA) Video Decoder
* Copyright (C) 2003 the ffmpeg project
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/**
* @file rpza.c
* QT RPZA Video Decoder by Roberto Togni <rtogni@bresciaonline.it>
* For more information about the RPZA format, visit:
* http://www.pcisys.net/~melanson/codecs/
*
* The RPZA decoder outputs RGB555 colorspace data.
*
* Note that this decoder reads big endian RGB555 pixel values from the
* bytestream, arranges them in the host's endian order, and outputs
* them to the final rendered map in the same host endian order. This is
* intended behavior as the ffmpeg documentation states that RGB555 pixels
* shall be stored in native CPU endianness.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "common.h"
#include "avcodec.h"
#include "dsputil.h"
typedef struct RpzaContext {
AVCodecContext *avctx;
DSPContext dsp;
AVFrame frame;
AVFrame prev_frame;
unsigned char *buf;
int size;
} RpzaContext;
#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
(((uint8_t*)(x))[1] << 16) | \
(((uint8_t*)(x))[2] << 8) | \
((uint8_t*)(x))[3])
#define ADVANCE_BLOCK() \
{ \
pixel_ptr += 4; \
if (pixel_ptr >= width) \
{ \
pixel_ptr = 0; \
row_ptr += stride * 4; \
} \
total_blocks--; \
if (total_blocks < 0) \
{ \
printf("warning: block counter just went negative (this should not happen)\n"); \
return; \
} \
}
static void rpza_decode_stream(RpzaContext *s)
{
int width = s->avctx->width;
int stride = s->frame.linesize[0] / 2;
int row_inc = stride - 4;
int stream_ptr = 0;
int chunk_size;
unsigned char opcode;
int n_blocks;
unsigned short colorA = 0, colorB;
unsigned short color4[4];
unsigned char index, idx;
unsigned short ta, tb;
unsigned short *pixels = (unsigned short *)s->frame.data[0];
unsigned short *prev_pixels = (unsigned short *)s->prev_frame.data[0];
int row_ptr = 0;
int pixel_ptr = 0;
int block_ptr;
int pixel_x, pixel_y;
int total_blocks;
/* First byte is always 0xe1. Warn if it's different */
if (s->buf[stream_ptr] != 0xe1)
printf("First chunk byte is 0x%02x instead of 0x1e\n",
s->buf[stream_ptr]);
/* Get chunk size, ingnoring first byte */
chunk_size = BE_32(&s->buf[stream_ptr]) & 0x00FFFFFF;
stream_ptr += 4;
/* If length mismatch use size from MOV file and try to decode anyway */
if (chunk_size != s->size)
printf("MOV chunk size != encoded chunk size; using MOV chunk size\n");
chunk_size = s->size;
/* Number of 4x4 blocks in frame. */
total_blocks = (s->avctx->width * s->avctx->height) / (4 * 4);
/* Process chunk data */
while (stream_ptr < chunk_size) {
opcode = s->buf[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) | (s->buf[stream_ptr++]);
opcode = 0;
if ((s->buf[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--) {
block_ptr = row_ptr + pixel_ptr;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++){
pixels[block_ptr] = prev_pixels[block_ptr];
block_ptr++;
}
block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
/* Fill blocks with one color */
case 0xa0:
colorA = BE_16 (&s->buf[stream_ptr]);
stream_ptr += 2;
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++){
pixels[block_ptr] = colorA;
block_ptr++;
}
block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
/* Fill blocks with 4 colors */
case 0xc0:
colorA = BE_16 (&s->buf[stream_ptr]);
stream_ptr += 2;
case 0x20:
colorB = BE_16 (&s->buf[stream_ptr]);
stream_ptr += 2;
/* sort out the colors */
color4[0] = colorB;
color4[1] = 0;
color4[2] = 0;
color4[3] = colorA;
/* red components */
ta = (colorA >> 10) & 0x1F;
tb = (colorB >> 10) & 0x1F;
color4[1] |= ((11 * ta + 21 * tb) >> 5) << 10;
color4[2] |= ((21 * ta + 11 * tb) >> 5) << 10;
/* green components */
ta = (colorA >> 5) & 0x1F;
tb = (colorB >> 5) & 0x1F;
color4[1] |= ((11 * ta + 21 * tb) >> 5) << 5;
color4[2] |= ((21 * ta + 11 * tb) >> 5) << 5;
/* blue components */
ta = colorA & 0x1F;
tb = colorB & 0x1F;
color4[1] |= ((11 * ta + 21 * tb) >> 5);
color4[2] |= ((21 * ta + 11 * tb) >> 5);
while (n_blocks--) {
block_ptr = row_ptr + pixel_ptr;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
index = s->buf[stream_ptr++];
for (pixel_x = 0; pixel_x < 4; pixel_x++){
idx = (index >> (2 * (3 - pixel_x))) & 0x03;
pixels[block_ptr] = color4[idx];
block_ptr++;
}
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 (&s->buf[stream_ptr]);
stream_ptr += 2;
}
pixels[block_ptr] = colorA;
block_ptr++;
}
block_ptr += row_inc;
}
ADVANCE_BLOCK();
break;
/* Unknown opcode */
default:
printf("Unknown opcode %d in rpza chunk."
" Skip remaining %d bytes of chunk data.\n", opcode,
chunk_size - stream_ptr);
return;
} /* Opcode switch */
}
}
static int rpza_decode_init(AVCodecContext *avctx)
{
RpzaContext *s = (RpzaContext *)avctx->priv_data;
s->avctx = avctx;
avctx->pix_fmt = PIX_FMT_RGB555;
avctx->has_b_frames = 0;
dsputil_init(&s->dsp, avctx);
s->frame.data[0] = s->prev_frame.data[0] = NULL;
return 0;
}
static int rpza_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
RpzaContext *s = (RpzaContext *)avctx->priv_data;
s->buf = buf;
s->size = buf_size;
if (avctx->get_buffer(avctx, &s->frame)) {
printf (" RPZA Video: get_buffer() failed\n");
return -1;
}
rpza_decode_stream(s);
if (s->prev_frame.data[0])
avctx->release_buffer(avctx, &s->prev_frame);
/* shuffle frames */
s->prev_frame = s->frame;
*data_size = sizeof(AVFrame);
*(AVFrame*)data = s->frame;
/* always report that the buffer was completely consumed */
return buf_size;
}
static int rpza_decode_end(AVCodecContext *avctx)
{
RpzaContext *s = (RpzaContext *)avctx->priv_data;
if (s->prev_frame.data[0])
avctx->release_buffer(avctx, &s->prev_frame);
return 0;
}
AVCodec rpza_decoder = {
"rpza",
CODEC_TYPE_VIDEO,
CODEC_ID_RPZA,
sizeof(RpzaContext),
rpza_decode_init,
NULL,
rpza_decode_end,
rpza_decode_frame,
CODEC_CAP_DR1,
};
...@@ -15,7 +15,7 @@ PPOBJS= ...@@ -15,7 +15,7 @@ PPOBJS=
OBJS+=mpeg.o mpegts.o mpegtsenc.o ffm.o crc.o img.o raw.o rm.o \ OBJS+=mpeg.o mpegts.o mpegtsenc.o ffm.o crc.o img.o raw.o rm.o \
avienc.o avidec.o wav.o swf.o au.o gif.o mov.o mpjpeg.o dv.o \ avienc.o avidec.o wav.o swf.o au.o gif.o mov.o mpjpeg.o dv.o \
yuv4mpeg.o 4xm.o flvenc.o flvdec.o movenc.o psxstr.o idroq.o ipmovie.o \ yuv4mpeg.o 4xm.o flvenc.o flvdec.o movenc.o psxstr.o idroq.o ipmovie.o \
nut.o wc3movie.o mp3.o nut.o wc3movie.o mp3.o westwood.o segafilm.o
ifeq ($(CONFIG_RISKY),yes) ifeq ($(CONFIG_RISKY),yes)
OBJS+= asf.o OBJS+= asf.o
......
...@@ -56,6 +56,8 @@ void av_register_all(void) ...@@ -56,6 +56,8 @@ void av_register_all(void)
roq_init(); roq_init();
ipmovie_init(); ipmovie_init();
wc3_init(); wc3_init();
westwood_init();
film_init();
#if defined(AMR_NB) || defined(AMR_NB_FIXED) || defined(AMR_WB) #if defined(AMR_NB) || defined(AMR_NB_FIXED) || defined(AMR_WB)
amr_init(); amr_init();
......
...@@ -406,6 +406,12 @@ int nut_init(void); ...@@ -406,6 +406,12 @@ int nut_init(void);
/* wc3movie.c */ /* wc3movie.c */
int wc3_init(void); int wc3_init(void);
/* westwood.c */
int westwood_init(void);
/* segafilm.c */
int film_init(void);
#include "rtp.h" #include "rtp.h"
#include "rtsp.h" #include "rtsp.h"
......
...@@ -141,6 +141,15 @@ const CodecTag codec_bmp_tags[] = { ...@@ -141,6 +141,15 @@ const CodecTag codec_bmp_tags[] = {
{ CODEC_ID_VCR1, MKTAG('V', 'C', 'R', '1') }, { CODEC_ID_VCR1, MKTAG('V', 'C', 'R', '1') },
{ CODEC_ID_FFV1, MKTAG('F', 'F', 'V', '1') }, { CODEC_ID_FFV1, MKTAG('F', 'F', 'V', '1') },
{ CODEC_ID_XAN_WC4, MKTAG('X', 'x', 'a', 'n') }, { CODEC_ID_XAN_WC4, MKTAG('X', 'x', 'a', 'n') },
{ CODEC_ID_MSRLE, MKTAG('m', 'r', 'l', 'e') },
{ CODEC_ID_MSRLE, MKTAG(0x1, 0x0, 0x0, 0x0) },
{ CODEC_ID_MSVIDEO1, MKTAG('M', 'S', 'V', 'C') },
{ CODEC_ID_MSVIDEO1, MKTAG('m', 's', 'v', 'c') },
{ CODEC_ID_MSVIDEO1, MKTAG('C', 'R', 'A', 'M') },
{ CODEC_ID_MSVIDEO1, MKTAG('c', 'r', 'a', 'm') },
{ CODEC_ID_MSVIDEO1, MKTAG('W', 'H', 'A', 'M') },
{ CODEC_ID_MSVIDEO1, MKTAG('w', 'h', 'a', 'm') },
{ CODEC_ID_CINEPAK, MKTAG('c', 'v', 'i', 'd') },
{ 0, 0 }, { 0, 0 },
}; };
......
...@@ -98,6 +98,8 @@ static const CodecTag mov_video_tags[] = { ...@@ -98,6 +98,8 @@ static const CodecTag mov_video_tags[] = {
{ CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', 'p') }, /* DV PAL */ { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'c', 'p') }, /* DV PAL */
/* { CODEC_ID_DVVIDEO, MKTAG('A', 'V', 'd', 'v') }, *//* AVID dv */ /* { CODEC_ID_DVVIDEO, MKTAG('A', 'V', 'd', 'v') }, *//* AVID dv */
{ CODEC_ID_VP3, MKTAG('V', 'P', '3', '1') }, /* On2 VP3 */ { CODEC_ID_VP3, MKTAG('V', 'P', '3', '1') }, /* On2 VP3 */
{ CODEC_ID_RPZA, MKTAG('r', 'p', 'z', 'a') }, /* Apple Video (RPZA) */
{ CODEC_ID_CINEPAK, MKTAG('c', 'v', 'i', 'd') }, /* Cinepak */
{ CODEC_ID_NONE, 0 }, { CODEC_ID_NONE, 0 },
}; };
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment