Mercurial > libavcodec.hg
annotate cinepak.c @ 1891:f403b3e286b3 libavcodec
use pan_scan to remove some weight, proper pan_scan offset reading
author | iive |
---|---|
date | Tue, 16 Mar 2004 15:38:40 +0000 |
parents | 39ad6cd5d4a6 |
children | b13a25ac9f0c |
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 * Cinepak 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 * |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
5 * This library is free software; you can redistribute it and/or |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
6 * 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
|
7 * License as published by the Free Software Foundation; either |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
8 * version 2 of the License, or (at your option) any later version. |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
9 * |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
10 * This library is distributed in the hope that it will be useful, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
11 * 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
|
12 * 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
|
13 * Lesser General Public License for more details. |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
14 * |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
15 * You should have received a copy of the GNU Lesser General Public |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
16 * License along with this library; if not, write to the Free Software |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
18 * |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
19 */ |
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 * @file cinepak.c |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
23 * Cinepak video decoder |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
24 * by Ewald Snel <ewald@rambo.its.tudelft.nl> |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
25 * For more information on the Cinepak algorithm, visit: |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
26 * http://www.csse.monash.edu.au/~timf/ |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
27 */ |
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 #include <stdio.h> |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
30 #include <stdlib.h> |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
31 #include <string.h> |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
32 #include <unistd.h> |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
33 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
34 #include "common.h" |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
35 #include "avcodec.h" |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
36 #include "dsputil.h" |
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 #define PALETTE_COUNT 256 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
39 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
40 typedef struct { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
41 uint8_t y0, y1, y2, y3; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
42 uint8_t u, v; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
43 } cvid_codebook_t; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
44 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
45 #define MAX_STRIPS 32 |
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 { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
48 uint16_t id; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
49 uint16_t x1, y1; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
50 uint16_t x2, y2; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
51 cvid_codebook_t v4_codebook[256]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
52 cvid_codebook_t v1_codebook[256]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
53 } cvid_strip_t; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
54 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
55 typedef struct CinepakContext { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
56 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
57 AVCodecContext *avctx; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
58 DSPContext dsp; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
59 AVFrame frame; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
60 AVFrame prev_frame; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
61 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
62 unsigned char *data; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
63 int size; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
64 |
1572
860e44e2c20c
support Cinepak files with funky (not divisible by 4) resolutions
melanson
parents:
1491
diff
changeset
|
65 int width, height; |
860e44e2c20c
support Cinepak files with funky (not divisible by 4) resolutions
melanson
parents:
1491
diff
changeset
|
66 |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
67 unsigned char palette[PALETTE_COUNT * 4]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
68 int palette_video; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
69 cvid_strip_t strips[MAX_STRIPS]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
70 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
71 } CinepakContext; |
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 static void cinepak_decode_codebook (cvid_codebook_t *codebook, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
74 int chunk_id, int size, uint8_t *data) |
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 uint8_t *eod = (data + size); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
77 uint32_t flag, mask; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
78 int i, n; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
79 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
80 /* check if this chunk contains 4- or 6-element vectors */ |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
81 n = (chunk_id & 0x0400) ? 4 : 6; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
82 flag = 0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
83 mask = 0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
84 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
85 for (i=0; i < 256; i++) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
86 if ((chunk_id & 0x0100) && !(mask >>= 1)) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
87 if ((data + 4) > eod) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
88 break; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
89 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
90 flag = BE_32 (data); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
91 data += 4; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
92 mask = 0x80000000; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
93 } |
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 if (!(chunk_id & 0x0100) || (flag & mask)) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
96 if ((data + n) > eod) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
97 break; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
98 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
99 if (n == 6) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
100 codebook[i].y0 = *data++; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
101 codebook[i].y1 = *data++; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
102 codebook[i].y2 = *data++; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
103 codebook[i].y3 = *data++; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
104 codebook[i].u = 128 + *data++; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
105 codebook[i].v = 128 + *data++; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
106 } else { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
107 /* this codebook type indicates either greyscale or |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
108 * palettized video; if palettized, U & V components will |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
109 * not be used so it is safe to set them to 128 for the |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
110 * benefit of greyscale rendering in YUV420P */ |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
111 codebook[i].y0 = *data++; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
112 codebook[i].y1 = *data++; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
113 codebook[i].y2 = *data++; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
114 codebook[i].y3 = *data++; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
115 codebook[i].u = 128; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
116 codebook[i].v = 128; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
117 } |
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 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
120 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
121 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
122 static int cinepak_decode_vectors (CinepakContext *s, cvid_strip_t *strip, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
123 int chunk_id, int size, uint8_t *data) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
124 { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
125 uint8_t *eod = (data + size); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
126 uint32_t flag, mask; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
127 cvid_codebook_t *codebook; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
128 unsigned int i, j, x, y; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
129 uint32_t iy[4]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
130 uint32_t iu[2]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
131 uint32_t iv[2]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
132 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
133 flag = 0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
134 mask = 0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
135 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
136 for (y=strip->y1; y < strip->y2; y+=4) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
137 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
138 iy[0] = strip->x1 + (y * s->frame.linesize[0]); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
139 iy[1] = iy[0] + s->frame.linesize[0]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
140 iy[2] = iy[1] + s->frame.linesize[0]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
141 iy[3] = iy[2] + s->frame.linesize[0]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
142 iu[0] = (strip->x1/2) + ((y/2) * s->frame.linesize[1]); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
143 iu[1] = iu[0] + s->frame.linesize[1]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
144 iv[0] = (strip->x1/2) + ((y/2) * s->frame.linesize[2]); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
145 iv[1] = iv[0] + s->frame.linesize[2]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
146 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
147 for (x=strip->x1; x < strip->x2; x+=4) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
148 if ((chunk_id & 0x0100) && !(mask >>= 1)) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
149 if ((data + 4) > eod) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
150 return -1; |
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 flag = BE_32 (data); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
153 data += 4; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
154 mask = 0x80000000; |
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 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
157 if (!(chunk_id & 0x0100) || (flag & mask)) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
158 if (!(chunk_id & 0x0200) && !(mask >>= 1)) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
159 if ((data + 4) > eod) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
160 return -1; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
161 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
162 flag = BE_32 (data); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
163 data += 4; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
164 mask = 0x80000000; |
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 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
167 if ((chunk_id & 0x0200) || (~flag & mask)) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
168 if (data >= eod) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
169 return -1; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
170 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
171 codebook = &strip->v1_codebook[*data++]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
172 s->frame.data[0][iy[0] + 0] = codebook->y0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
173 s->frame.data[0][iy[0] + 1] = codebook->y0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
174 s->frame.data[0][iy[1] + 0] = codebook->y0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
175 s->frame.data[0][iy[1] + 1] = codebook->y0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
176 if (!s->palette_video) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
177 s->frame.data[1][iu[0]] = codebook->u; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
178 s->frame.data[2][iv[0]] = codebook->v; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
179 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
180 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
181 s->frame.data[0][iy[0] + 2] = codebook->y0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
182 s->frame.data[0][iy[0] + 3] = codebook->y0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
183 s->frame.data[0][iy[1] + 2] = codebook->y0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
184 s->frame.data[0][iy[1] + 3] = codebook->y0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
185 if (!s->palette_video) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
186 s->frame.data[1][iu[0] + 1] = codebook->u; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
187 s->frame.data[2][iv[0] + 1] = codebook->v; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
188 } |
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 s->frame.data[0][iy[2] + 0] = codebook->y0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
191 s->frame.data[0][iy[2] + 1] = codebook->y0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
192 s->frame.data[0][iy[3] + 0] = codebook->y0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
193 s->frame.data[0][iy[3] + 1] = codebook->y0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
194 if (!s->palette_video) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
195 s->frame.data[1][iu[1]] = codebook->u; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
196 s->frame.data[2][iv[1]] = codebook->v; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
197 } |
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 s->frame.data[0][iy[2] + 2] = codebook->y0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
200 s->frame.data[0][iy[2] + 3] = codebook->y0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
201 s->frame.data[0][iy[3] + 2] = codebook->y0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
202 s->frame.data[0][iy[3] + 3] = codebook->y0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
203 if (!s->palette_video) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
204 s->frame.data[1][iu[1] + 1] = codebook->u; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
205 s->frame.data[2][iv[1] + 1] = codebook->v; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
206 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
207 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
208 } else if (flag & mask) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
209 if ((data + 4) > eod) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
210 return -1; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
211 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
212 codebook = &strip->v4_codebook[*data++]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
213 s->frame.data[0][iy[0] + 0] = codebook->y0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
214 s->frame.data[0][iy[0] + 1] = codebook->y1; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
215 s->frame.data[0][iy[1] + 0] = codebook->y2; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
216 s->frame.data[0][iy[1] + 1] = codebook->y3; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
217 if (!s->palette_video) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
218 s->frame.data[1][iu[0]] = codebook->u; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
219 s->frame.data[2][iv[0]] = codebook->v; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
220 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
221 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
222 codebook = &strip->v4_codebook[*data++]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
223 s->frame.data[0][iy[0] + 2] = codebook->y0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
224 s->frame.data[0][iy[0] + 3] = codebook->y1; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
225 s->frame.data[0][iy[1] + 2] = codebook->y2; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
226 s->frame.data[0][iy[1] + 3] = codebook->y3; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
227 if (!s->palette_video) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
228 s->frame.data[1][iu[0] + 1] = codebook->u; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
229 s->frame.data[2][iv[0] + 1] = codebook->v; |
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 codebook = &strip->v4_codebook[*data++]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
233 s->frame.data[0][iy[2] + 0] = codebook->y0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
234 s->frame.data[0][iy[2] + 1] = codebook->y1; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
235 s->frame.data[0][iy[3] + 0] = codebook->y2; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
236 s->frame.data[0][iy[3] + 1] = codebook->y3; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
237 if (!s->palette_video) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
238 s->frame.data[1][iu[1]] = codebook->u; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
239 s->frame.data[2][iv[1]] = codebook->v; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
240 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
241 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
242 codebook = &strip->v4_codebook[*data++]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
243 s->frame.data[0][iy[2] + 2] = codebook->y0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
244 s->frame.data[0][iy[2] + 3] = codebook->y1; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
245 s->frame.data[0][iy[3] + 2] = codebook->y2; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
246 s->frame.data[0][iy[3] + 3] = codebook->y3; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
247 if (!s->palette_video) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
248 s->frame.data[1][iu[1] + 1] = codebook->u; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
249 s->frame.data[2][iv[1] + 1] = codebook->v; |
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 |
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 } else { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
254 /* copy from the previous frame */ |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
255 for (i = 0; i < 4; i++) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
256 for (j = 0; j < 4; j++) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
257 s->frame.data[0][iy[i] + j] = |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
258 s->prev_frame.data[0][iy[i] + j]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
259 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
260 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
261 for (i = 0; i < 2; i++) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
262 for (j = 0; j < 2; j++) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
263 s->frame.data[1][iu[i] + j] = |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
264 s->prev_frame.data[1][iu[i] + j]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
265 s->frame.data[2][iv[i] + j] = |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
266 s->prev_frame.data[2][iv[i] + j]; |
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 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
269 } |
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 iy[0] += 4; iy[1] += 4; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
272 iy[2] += 4; iy[3] += 4; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
273 iu[0] += 2; iu[1] += 2; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
274 iv[0] += 2; iv[1] += 2; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
275 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
276 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
277 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
278 return 0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
279 } |
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 static int cinepak_decode_strip (CinepakContext *s, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
282 cvid_strip_t *strip, uint8_t *data, int size) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
283 { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
284 uint8_t *eod = (data + size); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
285 int chunk_id, chunk_size; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
286 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
287 /* coordinate sanity checks */ |
1572
860e44e2c20c
support Cinepak files with funky (not divisible by 4) resolutions
melanson
parents:
1491
diff
changeset
|
288 if (strip->x1 >= s->width || strip->x2 > s->width || |
860e44e2c20c
support Cinepak files with funky (not divisible by 4) resolutions
melanson
parents:
1491
diff
changeset
|
289 strip->y1 >= s->height || strip->y2 > s->height || |
860e44e2c20c
support Cinepak files with funky (not divisible by 4) resolutions
melanson
parents:
1491
diff
changeset
|
290 strip->x1 >= strip->x2 || strip->y1 >= strip->y2) |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
291 return -1; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
292 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
293 while ((data + 4) <= eod) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
294 chunk_id = BE_16 (&data[0]); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
295 chunk_size = BE_16 (&data[2]) - 4; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
296 data += 4; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
297 chunk_size = ((data + chunk_size) > eod) ? (eod - data) : chunk_size; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
298 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
299 switch (chunk_id) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
300 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
301 case 0x2000: |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
302 case 0x2100: |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
303 case 0x2400: |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
304 case 0x2500: |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
305 cinepak_decode_codebook (strip->v4_codebook, chunk_id, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
306 chunk_size, data); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
307 break; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
308 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
309 case 0x2200: |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
310 case 0x2300: |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
311 case 0x2600: |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
312 case 0x2700: |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
313 cinepak_decode_codebook (strip->v1_codebook, chunk_id, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
314 chunk_size, data); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
315 break; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
316 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
317 case 0x3000: |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
318 case 0x3100: |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
319 case 0x3200: |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
320 return cinepak_decode_vectors (s, strip, chunk_id, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
321 chunk_size, data); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
322 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
323 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
324 data += chunk_size; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
325 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
326 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
327 return -1; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
328 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
329 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
330 static int cinepak_decode (CinepakContext *s) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
331 { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
332 uint8_t *eod = (s->data + s->size); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
333 int i, result, strip_size, frame_flags, num_strips; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
334 int y0 = 0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
335 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
336 if (s->size < 10) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
337 return -1; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
338 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
339 frame_flags = s->data[0]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
340 num_strips = BE_16 (&s->data[8]); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
341 s->data += 10; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
342 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
343 if (num_strips > MAX_STRIPS) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
344 num_strips = MAX_STRIPS; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
345 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
346 for (i=0; i < num_strips; i++) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
347 if ((s->data + 12) > eod) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
348 return -1; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
349 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
350 s->strips[i].id = BE_16 (s->data); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
351 s->strips[i].y1 = y0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
352 s->strips[i].x1 = 0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
353 s->strips[i].y2 = y0 + BE_16 (&s->data[8]); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
354 s->strips[i].x2 = s->avctx->width; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
355 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
356 strip_size = BE_16 (&s->data[2]) - 12; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
357 s->data += 12; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
358 strip_size = ((s->data + strip_size) > eod) ? (eod - s->data) : strip_size; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
359 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
360 if ((i > 0) && !(frame_flags & 0x01)) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
361 memcpy (s->strips[i].v4_codebook, s->strips[i-1].v4_codebook, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
362 sizeof(s->strips[i].v4_codebook)); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
363 memcpy (s->strips[i].v1_codebook, s->strips[i-1].v1_codebook, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
364 sizeof(s->strips[i].v1_codebook)); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
365 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
366 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
367 result = cinepak_decode_strip (s, &s->strips[i], s->data, strip_size); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
368 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
369 if (result != 0) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
370 return result; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
371 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
372 s->data += strip_size; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
373 y0 = s->strips[i].y2; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
374 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
375 return 0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
376 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
377 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
378 static int cinepak_decode_init(AVCodecContext *avctx) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
379 { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
380 CinepakContext *s = (CinepakContext *)avctx->priv_data; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
381 /* |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
382 int i; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
383 unsigned char r, g, b; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
384 unsigned char *raw_palette; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
385 unsigned int *palette32; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
386 */ |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
387 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
388 s->avctx = avctx; |
1572
860e44e2c20c
support Cinepak files with funky (not divisible by 4) resolutions
melanson
parents:
1491
diff
changeset
|
389 s->width = (avctx->width + 3) & ~3; |
860e44e2c20c
support Cinepak files with funky (not divisible by 4) resolutions
melanson
parents:
1491
diff
changeset
|
390 s->height = (avctx->height + 3) & ~3; |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
391 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
392 // check for paletted data |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
393 s->palette_video = 0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
394 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
395 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
396 avctx->pix_fmt = PIX_FMT_YUV420P; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
397 avctx->has_b_frames = 0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
398 dsputil_init(&s->dsp, avctx); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
399 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
400 s->frame.data[0] = s->prev_frame.data[0] = NULL; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
401 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
402 return 0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
403 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
404 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
405 static int cinepak_decode_frame(AVCodecContext *avctx, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
406 void *data, int *data_size, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
407 uint8_t *buf, int buf_size) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
408 { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
409 CinepakContext *s = (CinepakContext *)avctx->priv_data; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
410 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
411 s->data = buf; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
412 s->size = buf_size; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
413 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
414 if (avctx->get_buffer(avctx, &s->frame)) { |
1598
932d306bf1dc
av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)
michael
parents:
1572
diff
changeset
|
415 av_log(avctx, AV_LOG_ERROR, " Cinepak: get_buffer() failed\n"); |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
416 return -1; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
417 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
418 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
419 cinepak_decode(s); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
420 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
421 if (s->prev_frame.data[0]) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
422 avctx->release_buffer(avctx, &s->prev_frame); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
423 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
424 /* shuffle frames */ |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
425 s->prev_frame = s->frame; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
426 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
427 *data_size = sizeof(AVFrame); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
428 *(AVFrame*)data = s->frame; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
429 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
430 /* report that the buffer was completely consumed */ |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
431 return buf_size; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
432 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
433 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
434 static int cinepak_decode_end(AVCodecContext *avctx) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
435 { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
436 CinepakContext *s = (CinepakContext *)avctx->priv_data; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
437 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
438 if (s->prev_frame.data[0]) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
439 avctx->release_buffer(avctx, &s->prev_frame); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
440 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
441 return 0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
442 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
443 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
444 AVCodec cinepak_decoder = { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
445 "cinepak", |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
446 CODEC_TYPE_VIDEO, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
447 CODEC_ID_CINEPAK, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
448 sizeof(CinepakContext), |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
449 cinepak_decode_init, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
450 NULL, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
451 cinepak_decode_end, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
452 cinepak_decode_frame, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
453 CODEC_CAP_DR1, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
454 }; |