annotate rpza.c @ 4025:76ca770d2f6b libavcodec

this code will not work with PIC as it needs 7 registers and gcc doesnt support that in PIC
author michael
date Sun, 15 Oct 2006 20:50:05 +0000
parents c8c591fe26f8
children 05e932ddaaa9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1491
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
1 /*
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
2 * Quicktime Video (RPZA) Video Decoder
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
3 * Copyright (C) 2003 the ffmpeg project
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
4 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
5 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
6 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
1491
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
1491
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
11 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
1491
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
15 * Lesser General Public License for more details.
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
16 *
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
3036
0b546eab515d Update licensing information: The FSF changed postal address.
diego
parents: 2967
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1491
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
20 *
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
21 */
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
22
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
23 /**
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
24 * @file rpza.c
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
25 * QT RPZA Video Decoder by Roberto Togni <rtogni@bresciaonline.it>
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
26 * For more information about the RPZA format, visit:
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
27 * http://www.pcisys.net/~melanson/codecs/
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
28 *
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
29 * The RPZA decoder outputs RGB555 colorspace data.
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
30 *
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
31 * Note that this decoder reads big endian RGB555 pixel values from the
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
32 * bytestream, arranges them in the host's endian order, and outputs
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
33 * them to the final rendered map in the same host endian order. This is
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
34 * intended behavior as the ffmpeg documentation states that RGB555 pixels
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
35 * shall be stored in native CPU endianness.
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
36 */
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
37
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
38 #include <stdio.h>
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
39 #include <stdlib.h>
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
40 #include <string.h>
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
41 #include <unistd.h>
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
42
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
43 #include "common.h"
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
44 #include "avcodec.h"
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
45 #include "dsputil.h"
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
46
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
47 typedef struct RpzaContext {
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
48
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
49 AVCodecContext *avctx;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
50 DSPContext dsp;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
51 AVFrame frame;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
52
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
53 unsigned char *buf;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
54 int size;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
55
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
56 } RpzaContext;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
57
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
58 #define ADVANCE_BLOCK() \
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
59 { \
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
60 pixel_ptr += 4; \
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
61 if (pixel_ptr >= width) \
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
62 { \
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
63 pixel_ptr = 0; \
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
64 row_ptr += stride * 4; \
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
65 } \
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
66 total_blocks--; \
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
67 if (total_blocks < 0) \
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
68 { \
1598
932d306bf1dc av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents: 1504
diff changeset
69 av_log(s->avctx, AV_LOG_ERROR, "warning: block counter just went negative (this should not happen)\n"); \
1491
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
70 return; \
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
71 } \
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
72 }
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
73
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
74 static void rpza_decode_stream(RpzaContext *s)
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
75 {
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
76 int width = s->avctx->width;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
77 int stride = s->frame.linesize[0] / 2;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
78 int row_inc = stride - 4;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
79 int stream_ptr = 0;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
80 int chunk_size;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
81 unsigned char opcode;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
82 int n_blocks;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
83 unsigned short colorA = 0, colorB;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
84 unsigned short color4[4];
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
85 unsigned char index, idx;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
86 unsigned short ta, tb;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
87 unsigned short *pixels = (unsigned short *)s->frame.data[0];
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
88
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
89 int row_ptr = 0;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
90 int pixel_ptr = 0;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
91 int block_ptr;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
92 int pixel_x, pixel_y;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
93 int total_blocks;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
94
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
95 /* First byte is always 0xe1. Warn if it's different */
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
96 if (s->buf[stream_ptr] != 0xe1)
2626
370f4b9ec7d8 typo fix by ("Todd.Kirby" doubleshot pacbell net)
michael
parents: 2453
diff changeset
97 av_log(s->avctx, AV_LOG_ERROR, "First chunk byte is 0x%02x instead of 0xe1\n",
1491
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
98 s->buf[stream_ptr]);
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
99
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
100 /* Get chunk size, ingnoring first byte */
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
101 chunk_size = BE_32(&s->buf[stream_ptr]) & 0x00FFFFFF;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
102 stream_ptr += 4;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
103
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
104 /* If length mismatch use size from MOV file and try to decode anyway */
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
105 if (chunk_size != s->size)
1598
932d306bf1dc av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents: 1504
diff changeset
106 av_log(s->avctx, AV_LOG_ERROR, "MOV chunk size != encoded chunk size; using MOV chunk size\n");
1491
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
107
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
108 chunk_size = s->size;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
109
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
110 /* Number of 4x4 blocks in frame. */
2033
6852ecebb82a rpza resolution fix, courtesy of Todd Kirby (doubleshot at pacbell.net)
melanson
parents: 1881
diff changeset
111 total_blocks = ((s->avctx->width + 3) / 4) * ((s->avctx->height + 3) / 4);
1491
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
112
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
113 /* Process chunk data */
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
114 while (stream_ptr < chunk_size) {
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
115 opcode = s->buf[stream_ptr++]; /* Get opcode */
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
116
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
117 n_blocks = (opcode & 0x1f) + 1; /* Extract block counter from opcode */
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
118
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
119 /* If opcode MSbit is 0, we need more data to decide what to do */
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
120 if ((opcode & 0x80) == 0) {
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
121 colorA = (opcode << 8) | (s->buf[stream_ptr++]);
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
122 opcode = 0;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
123 if ((s->buf[stream_ptr] & 0x80) != 0) {
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2626
diff changeset
124 /* Must behave as opcode 110xxxxx, using colorA computed
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2626
diff changeset
125 * above. Use fake opcode 0x20 to enter switch block at
1491
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
126 * the right place */
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
127 opcode = 0x20;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
128 n_blocks = 1;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
129 }
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
130 }
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
131
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
132 switch (opcode & 0xe0) {
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
133
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
134 /* Skip blocks */
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
135 case 0x80:
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
136 while (n_blocks--) {
1607
9ef0d51e809b Set buffer hints, use cr where available
rtognimp
parents: 1598
diff changeset
137 ADVANCE_BLOCK();
1491
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
138 }
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
139 break;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
140
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
141 /* Fill blocks with one color */
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
142 case 0xa0:
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
143 colorA = BE_16 (&s->buf[stream_ptr]);
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
144 stream_ptr += 2;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
145 while (n_blocks--) {
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
146 block_ptr = row_ptr + pixel_ptr;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
147 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
148 for (pixel_x = 0; pixel_x < 4; pixel_x++){
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
149 pixels[block_ptr] = colorA;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
150 block_ptr++;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
151 }
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
152 block_ptr += row_inc;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
153 }
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
154 ADVANCE_BLOCK();
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
155 }
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
156 break;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
157
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
158 /* Fill blocks with 4 colors */
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
159 case 0xc0:
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
160 colorA = BE_16 (&s->buf[stream_ptr]);
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
161 stream_ptr += 2;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
162 case 0x20:
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
163 colorB = BE_16 (&s->buf[stream_ptr]);
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
164 stream_ptr += 2;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
165
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
166 /* sort out the colors */
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
167 color4[0] = colorB;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
168 color4[1] = 0;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
169 color4[2] = 0;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
170 color4[3] = colorA;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
171
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
172 /* red components */
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
173 ta = (colorA >> 10) & 0x1F;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
174 tb = (colorB >> 10) & 0x1F;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
175 color4[1] |= ((11 * ta + 21 * tb) >> 5) << 10;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
176 color4[2] |= ((21 * ta + 11 * tb) >> 5) << 10;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
177
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
178 /* green components */
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
179 ta = (colorA >> 5) & 0x1F;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
180 tb = (colorB >> 5) & 0x1F;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
181 color4[1] |= ((11 * ta + 21 * tb) >> 5) << 5;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
182 color4[2] |= ((21 * ta + 11 * tb) >> 5) << 5;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
183
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
184 /* blue components */
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
185 ta = colorA & 0x1F;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
186 tb = colorB & 0x1F;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
187 color4[1] |= ((11 * ta + 21 * tb) >> 5);
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
188 color4[2] |= ((21 * ta + 11 * tb) >> 5);
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
189
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
190 while (n_blocks--) {
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
191 block_ptr = row_ptr + pixel_ptr;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
192 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
193 index = s->buf[stream_ptr++];
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
194 for (pixel_x = 0; pixel_x < 4; pixel_x++){
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
195 idx = (index >> (2 * (3 - pixel_x))) & 0x03;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
196 pixels[block_ptr] = color4[idx];
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
197 block_ptr++;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
198 }
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
199 block_ptr += row_inc;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
200 }
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
201 ADVANCE_BLOCK();
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
202 }
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
203 break;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
204
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
205 /* Fill block with 16 colors */
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
206 case 0x00:
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
207 block_ptr = row_ptr + pixel_ptr;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
208 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
209 for (pixel_x = 0; pixel_x < 4; pixel_x++){
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
210 /* We already have color of upper left pixel */
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
211 if ((pixel_y != 0) || (pixel_x !=0)) {
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
212 colorA = BE_16 (&s->buf[stream_ptr]);
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
213 stream_ptr += 2;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
214 }
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
215 pixels[block_ptr] = colorA;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
216 block_ptr++;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
217 }
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
218 block_ptr += row_inc;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
219 }
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
220 ADVANCE_BLOCK();
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
221 break;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
222
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
223 /* Unknown opcode */
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
224 default:
1598
932d306bf1dc av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents: 1504
diff changeset
225 av_log(s->avctx, AV_LOG_ERROR, "Unknown opcode %d in rpza chunk."
1491
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
226 " Skip remaining %d bytes of chunk data.\n", opcode,
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
227 chunk_size - stream_ptr);
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
228 return;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
229 } /* Opcode switch */
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
230 }
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
231 }
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
232
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
233 static int rpza_decode_init(AVCodecContext *avctx)
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
234 {
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
235 RpzaContext *s = (RpzaContext *)avctx->priv_data;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
236
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
237 s->avctx = avctx;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
238 avctx->pix_fmt = PIX_FMT_RGB555;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
239 avctx->has_b_frames = 0;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
240 dsputil_init(&s->dsp, avctx);
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
241
1630
586b5c08863c - Add reget_buffer() function to AVCodecContext
rtognimp
parents: 1607
diff changeset
242 s->frame.data[0] = NULL;
1491
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
243
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
244 return 0;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
245 }
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
246
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
247 static int rpza_decode_frame(AVCodecContext *avctx,
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
248 void *data, int *data_size,
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
249 uint8_t *buf, int buf_size)
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
250 {
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
251 RpzaContext *s = (RpzaContext *)avctx->priv_data;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
252
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
253 s->buf = buf;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
254 s->size = buf_size;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
255
1504
df7ab60d1ee0 This patch marks frames used in RPZA decoder as reference frames, from
tmmm
parents: 1491
diff changeset
256 s->frame.reference = 1;
1769
1514fd5d434b watch those hard tabs
melanson
parents: 1630
diff changeset
257 s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
1630
586b5c08863c - Add reget_buffer() function to AVCodecContext
rtognimp
parents: 1607
diff changeset
258 if (avctx->reget_buffer(avctx, &s->frame)) {
586b5c08863c - Add reget_buffer() function to AVCodecContext
rtognimp
parents: 1607
diff changeset
259 av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
1491
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
260 return -1;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
261 }
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
262
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
263 rpza_decode_stream(s);
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
264
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
265 *data_size = sizeof(AVFrame);
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
266 *(AVFrame*)data = s->frame;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
267
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
268 /* always report that the buffer was completely consumed */
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
269 return buf_size;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
270 }
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
271
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
272 static int rpza_decode_end(AVCodecContext *avctx)
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
273 {
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
274 RpzaContext *s = (RpzaContext *)avctx->priv_data;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
275
1630
586b5c08863c - Add reget_buffer() function to AVCodecContext
rtognimp
parents: 1607
diff changeset
276 if (s->frame.data[0])
586b5c08863c - Add reget_buffer() function to AVCodecContext
rtognimp
parents: 1607
diff changeset
277 avctx->release_buffer(avctx, &s->frame);
1491
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
278
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
279 return 0;
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
280 }
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
281
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
282 AVCodec rpza_decoder = {
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
283 "rpza",
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
284 CODEC_TYPE_VIDEO,
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
285 CODEC_ID_RPZA,
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
286 sizeof(RpzaContext),
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
287 rpza_decode_init,
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
288 NULL,
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
289 rpza_decode_end,
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
290 rpza_decode_frame,
1630
586b5c08863c - Add reget_buffer() function to AVCodecContext
rtognimp
parents: 1607
diff changeset
291 CODEC_CAP_DR1,
1491
222643544cf1 New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff changeset
292 };