Mercurial > libavcodec.hg
annotate cinepak.c @ 11515:34080d73a504 libavcodec
fix minor typo
author | kostya |
---|---|
date | Sun, 21 Mar 2010 10:26:09 +0000 |
parents | 5da84f0d0a55 |
children | 8a4984c5cacc |
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 * |
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 /** |
8718
e9d9d946f213
Use full internal pathname in doxygen @file directives.
diego
parents:
8581
diff
changeset
|
23 * @file libavcodec/cinepak.c |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
24 * Cinepak video decoder |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
25 * 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
|
26 * 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
|
27 * http://www.csse.monash.edu.au/~timf/ |
4262
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
28 * For more information on the quirky data inside Sega FILM/CPK files, visit: |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
29 * http://wiki.multimedia.cx/index.php?title=Sega_FILM |
1491
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 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
32 #include <stdio.h> |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
33 #include <stdlib.h> |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
34 #include <string.h> |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
35 |
8573
2acf0ae7b041
Fix build: Add intreadwrite.h and bswap.h #includes where necessary.
diego
parents:
8318
diff
changeset
|
36 #include "libavutil/intreadwrite.h" |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
37 #include "avcodec.h" |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
38 |
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; |
8318
bc36a075bf35
The POSIX namespace shall be held sacrosanct. To that end,
melanson
parents:
7823
diff
changeset
|
43 } cvid_codebook; |
1491
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; |
8318
bc36a075bf35
The POSIX namespace shall be held sacrosanct. To that end,
melanson
parents:
7823
diff
changeset
|
51 cvid_codebook v4_codebook[256]; |
bc36a075bf35
The POSIX namespace shall be held sacrosanct. To that end,
melanson
parents:
7823
diff
changeset
|
52 cvid_codebook v1_codebook[256]; |
bc36a075bf35
The POSIX namespace shall be held sacrosanct. To that end,
melanson
parents:
7823
diff
changeset
|
53 } cvid_strip; |
1491
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 AVFrame frame; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
59 |
6230 | 60 const unsigned char *data; |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
61 int size; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
62 |
1572
860e44e2c20c
support Cinepak files with funky (not divisible by 4) resolutions
melanson
parents:
1491
diff
changeset
|
63 int width, height; |
860e44e2c20c
support Cinepak files with funky (not divisible by 4) resolutions
melanson
parents:
1491
diff
changeset
|
64 |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
65 int palette_video; |
8318
bc36a075bf35
The POSIX namespace shall be held sacrosanct. To that end,
melanson
parents:
7823
diff
changeset
|
66 cvid_strip strips[MAX_STRIPS]; |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
67 |
4262
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
68 int sega_film_skip_bytes; |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
69 |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
70 } CinepakContext; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
71 |
8318
bc36a075bf35
The POSIX namespace shall be held sacrosanct. To that end,
melanson
parents:
7823
diff
changeset
|
72 static void cinepak_decode_codebook (cvid_codebook *codebook, |
6230 | 73 int chunk_id, int size, const uint8_t *data) |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
74 { |
6230 | 75 const uint8_t *eod = (data + size); |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
76 uint32_t flag, mask; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
77 int i, n; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
78 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
79 /* check if this chunk contains 4- or 6-element vectors */ |
8580
144ddb6a597c
Cinepak strip and chunk sizes are 24-bit, not 16-bit as it was thought earlier.
kostya
parents:
8573
diff
changeset
|
80 n = (chunk_id & 0x04) ? 4 : 6; |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
81 flag = 0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
82 mask = 0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
83 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
84 for (i=0; i < 256; i++) { |
8580
144ddb6a597c
Cinepak strip and chunk sizes are 24-bit, not 16-bit as it was thought earlier.
kostya
parents:
8573
diff
changeset
|
85 if ((chunk_id & 0x01) && !(mask >>= 1)) { |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
86 if ((data + 4) > eod) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
87 break; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
88 |
4364 | 89 flag = AV_RB32 (data); |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
90 data += 4; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
91 mask = 0x80000000; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
92 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
93 |
8580
144ddb6a597c
Cinepak strip and chunk sizes are 24-bit, not 16-bit as it was thought earlier.
kostya
parents:
8573
diff
changeset
|
94 if (!(chunk_id & 0x01) || (flag & mask)) { |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
95 if ((data + n) > eod) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
96 break; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
97 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
98 if (n == 6) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
99 codebook[i].y0 = *data++; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
100 codebook[i].y1 = *data++; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
101 codebook[i].y2 = *data++; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
102 codebook[i].y3 = *data++; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
103 codebook[i].u = 128 + *data++; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
104 codebook[i].v = 128 + *data++; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
105 } else { |
2967 | 106 /* this codebook type indicates either greyscale or |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
107 * 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
|
108 * 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
|
109 * benefit of greyscale rendering in YUV420P */ |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
110 codebook[i].y0 = *data++; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
111 codebook[i].y1 = *data++; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
112 codebook[i].y2 = *data++; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
113 codebook[i].y3 = *data++; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
114 codebook[i].u = 128; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
115 codebook[i].v = 128; |
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 } |
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 |
8318
bc36a075bf35
The POSIX namespace shall be held sacrosanct. To that end,
melanson
parents:
7823
diff
changeset
|
121 static int cinepak_decode_vectors (CinepakContext *s, cvid_strip *strip, |
6230 | 122 int chunk_id, int size, const uint8_t *data) |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
123 { |
6230 | 124 const uint8_t *eod = (data + size); |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
125 uint32_t flag, mask; |
8318
bc36a075bf35
The POSIX namespace shall be held sacrosanct. To that end,
melanson
parents:
7823
diff
changeset
|
126 cvid_codebook *codebook; |
2009
b13a25ac9f0c
buffer hints, use reget_buffer, removed copy from previous frame
rtognimp
parents:
1881
diff
changeset
|
127 unsigned int x, y; |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
128 uint32_t iy[4]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
129 uint32_t iu[2]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
130 uint32_t iv[2]; |
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 flag = 0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
133 mask = 0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
134 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
135 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
|
136 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
137 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
|
138 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
|
139 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
|
140 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
|
141 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
|
142 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
|
143 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
|
144 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
|
145 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
146 for (x=strip->x1; x < strip->x2; x+=4) { |
8580
144ddb6a597c
Cinepak strip and chunk sizes are 24-bit, not 16-bit as it was thought earlier.
kostya
parents:
8573
diff
changeset
|
147 if ((chunk_id & 0x01) && !(mask >>= 1)) { |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
148 if ((data + 4) > eod) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
149 return -1; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
150 |
4364 | 151 flag = AV_RB32 (data); |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
152 data += 4; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
153 mask = 0x80000000; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
154 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
155 |
8580
144ddb6a597c
Cinepak strip and chunk sizes are 24-bit, not 16-bit as it was thought earlier.
kostya
parents:
8573
diff
changeset
|
156 if (!(chunk_id & 0x01) || (flag & mask)) { |
144ddb6a597c
Cinepak strip and chunk sizes are 24-bit, not 16-bit as it was thought earlier.
kostya
parents:
8573
diff
changeset
|
157 if (!(chunk_id & 0x02) && !(mask >>= 1)) { |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
158 if ((data + 4) > eod) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
159 return -1; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
160 |
4364 | 161 flag = AV_RB32 (data); |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
162 data += 4; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
163 mask = 0x80000000; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
164 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
165 |
8580
144ddb6a597c
Cinepak strip and chunk sizes are 24-bit, not 16-bit as it was thought earlier.
kostya
parents:
8573
diff
changeset
|
166 if ((chunk_id & 0x02) || (~flag & mask)) { |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
167 if (data >= eod) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
168 return -1; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
169 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
170 codebook = &strip->v1_codebook[*data++]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
171 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
|
172 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
|
173 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
|
174 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
|
175 if (!s->palette_video) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
176 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
|
177 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
|
178 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
179 |
2089 | 180 s->frame.data[0][iy[0] + 2] = codebook->y1; |
181 s->frame.data[0][iy[0] + 3] = codebook->y1; | |
182 s->frame.data[0][iy[1] + 2] = codebook->y1; | |
183 s->frame.data[0][iy[1] + 3] = codebook->y1; | |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
184 if (!s->palette_video) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
185 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
|
186 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
|
187 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
188 |
2089 | 189 s->frame.data[0][iy[2] + 0] = codebook->y2; |
190 s->frame.data[0][iy[2] + 1] = codebook->y2; | |
191 s->frame.data[0][iy[3] + 0] = codebook->y2; | |
192 s->frame.data[0][iy[3] + 1] = codebook->y2; | |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
193 if (!s->palette_video) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
194 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
|
195 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
|
196 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
197 |
2089 | 198 s->frame.data[0][iy[2] + 2] = codebook->y3; |
199 s->frame.data[0][iy[2] + 3] = codebook->y3; | |
200 s->frame.data[0][iy[3] + 2] = codebook->y3; | |
201 s->frame.data[0][iy[3] + 3] = codebook->y3; | |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
202 if (!s->palette_video) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
203 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
|
204 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
|
205 } |
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 } else if (flag & mask) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
208 if ((data + 4) > eod) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
209 return -1; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
210 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
211 codebook = &strip->v4_codebook[*data++]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
212 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
|
213 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
|
214 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
|
215 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
|
216 if (!s->palette_video) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
217 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
|
218 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
|
219 } |
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 codebook = &strip->v4_codebook[*data++]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
222 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
|
223 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
|
224 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
|
225 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
|
226 if (!s->palette_video) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
227 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
|
228 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
|
229 } |
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 codebook = &strip->v4_codebook[*data++]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
232 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
|
233 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
|
234 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
|
235 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
|
236 if (!s->palette_video) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
237 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
|
238 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
|
239 } |
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 codebook = &strip->v4_codebook[*data++]; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
242 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
|
243 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
|
244 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
|
245 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
|
246 if (!s->palette_video) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
247 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
|
248 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
|
249 } |
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 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
254 iy[0] += 4; iy[1] += 4; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
255 iy[2] += 4; iy[3] += 4; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
256 iu[0] += 2; iu[1] += 2; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
257 iv[0] += 2; iv[1] += 2; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
258 } |
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 return 0; |
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 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
264 static int cinepak_decode_strip (CinepakContext *s, |
8318
bc36a075bf35
The POSIX namespace shall be held sacrosanct. To that end,
melanson
parents:
7823
diff
changeset
|
265 cvid_strip *strip, const uint8_t *data, int size) |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
266 { |
6230 | 267 const uint8_t *eod = (data + size); |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
268 int chunk_id, chunk_size; |
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 /* coordinate sanity checks */ |
1572
860e44e2c20c
support Cinepak files with funky (not divisible by 4) resolutions
melanson
parents:
1491
diff
changeset
|
271 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
|
272 strip->y1 >= s->height || strip->y2 > s->height || |
860e44e2c20c
support Cinepak files with funky (not divisible by 4) resolutions
melanson
parents:
1491
diff
changeset
|
273 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
|
274 return -1; |
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 while ((data + 4) <= eod) { |
8580
144ddb6a597c
Cinepak strip and chunk sizes are 24-bit, not 16-bit as it was thought earlier.
kostya
parents:
8573
diff
changeset
|
277 chunk_id = data[0]; |
144ddb6a597c
Cinepak strip and chunk sizes are 24-bit, not 16-bit as it was thought earlier.
kostya
parents:
8573
diff
changeset
|
278 chunk_size = AV_RB24 (&data[1]) - 4; |
2787
af90d5dc83f0
fix infinite loop (suggested change by rjayne at convera dot com)
michael
parents:
2106
diff
changeset
|
279 if(chunk_size < 0) |
af90d5dc83f0
fix infinite loop (suggested change by rjayne at convera dot com)
michael
parents:
2106
diff
changeset
|
280 return -1; |
af90d5dc83f0
fix infinite loop (suggested change by rjayne at convera dot com)
michael
parents:
2106
diff
changeset
|
281 |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
282 data += 4; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
283 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
|
284 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
285 switch (chunk_id) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
286 |
8580
144ddb6a597c
Cinepak strip and chunk sizes are 24-bit, not 16-bit as it was thought earlier.
kostya
parents:
8573
diff
changeset
|
287 case 0x20: |
144ddb6a597c
Cinepak strip and chunk sizes are 24-bit, not 16-bit as it was thought earlier.
kostya
parents:
8573
diff
changeset
|
288 case 0x21: |
144ddb6a597c
Cinepak strip and chunk sizes are 24-bit, not 16-bit as it was thought earlier.
kostya
parents:
8573
diff
changeset
|
289 case 0x24: |
144ddb6a597c
Cinepak strip and chunk sizes are 24-bit, not 16-bit as it was thought earlier.
kostya
parents:
8573
diff
changeset
|
290 case 0x25: |
2967 | 291 cinepak_decode_codebook (strip->v4_codebook, chunk_id, |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
292 chunk_size, data); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
293 break; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
294 |
8580
144ddb6a597c
Cinepak strip and chunk sizes are 24-bit, not 16-bit as it was thought earlier.
kostya
parents:
8573
diff
changeset
|
295 case 0x22: |
144ddb6a597c
Cinepak strip and chunk sizes are 24-bit, not 16-bit as it was thought earlier.
kostya
parents:
8573
diff
changeset
|
296 case 0x23: |
144ddb6a597c
Cinepak strip and chunk sizes are 24-bit, not 16-bit as it was thought earlier.
kostya
parents:
8573
diff
changeset
|
297 case 0x26: |
144ddb6a597c
Cinepak strip and chunk sizes are 24-bit, not 16-bit as it was thought earlier.
kostya
parents:
8573
diff
changeset
|
298 case 0x27: |
2967 | 299 cinepak_decode_codebook (strip->v1_codebook, chunk_id, |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
300 chunk_size, data); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
301 break; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
302 |
8580
144ddb6a597c
Cinepak strip and chunk sizes are 24-bit, not 16-bit as it was thought earlier.
kostya
parents:
8573
diff
changeset
|
303 case 0x30: |
144ddb6a597c
Cinepak strip and chunk sizes are 24-bit, not 16-bit as it was thought earlier.
kostya
parents:
8573
diff
changeset
|
304 case 0x31: |
144ddb6a597c
Cinepak strip and chunk sizes are 24-bit, not 16-bit as it was thought earlier.
kostya
parents:
8573
diff
changeset
|
305 case 0x32: |
2967 | 306 return cinepak_decode_vectors (s, strip, chunk_id, |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
307 chunk_size, data); |
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 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
310 data += chunk_size; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
311 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
312 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
313 return -1; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
314 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
315 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
316 static int cinepak_decode (CinepakContext *s) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
317 { |
6230 | 318 const uint8_t *eod = (s->data + s->size); |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
319 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
|
320 int y0 = 0; |
2836
7bfea1374957
automatically detect Cinepak data from Sega FILM/CPK files
melanson
parents:
2787
diff
changeset
|
321 int encoded_buf_size; |
1491
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 if (s->size < 10) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
324 return -1; |
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 frame_flags = s->data[0]; |
4364 | 327 num_strips = AV_RB16 (&s->data[8]); |
328 encoded_buf_size = ((s->data[1] << 16) | AV_RB16 (&s->data[2])); | |
4262
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
329 |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
330 /* if this is the first frame, check for deviant Sega FILM data */ |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
331 if (s->sega_film_skip_bytes == -1) { |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
332 if (encoded_buf_size != s->size) { |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
333 /* If the encoded frame size differs from the frame size as indicated |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
334 * by the container file, this data likely comes from a Sega FILM/CPK file. |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
335 * If the frame header is followed by the bytes FE 00 00 06 00 00 then |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
336 * this is probably one of the two known files that have 6 extra bytes |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
337 * after the frame header. Else, assume 2 extra bytes. */ |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
338 if ((s->data[10] == 0xFE) && |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
339 (s->data[11] == 0x00) && |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
340 (s->data[12] == 0x00) && |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
341 (s->data[13] == 0x06) && |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
342 (s->data[14] == 0x00) && |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
343 (s->data[15] == 0x00)) |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
344 s->sega_film_skip_bytes = 6; |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
345 else |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
346 s->sega_film_skip_bytes = 2; |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
347 } else |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
348 s->sega_film_skip_bytes = 0; |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
349 } |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
350 |
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
351 s->data += 10 + s->sega_film_skip_bytes; |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
352 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
353 if (num_strips > MAX_STRIPS) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
354 num_strips = MAX_STRIPS; |
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 for (i=0; i < num_strips; i++) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
357 if ((s->data + 12) > eod) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
358 return -1; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
359 |
8581 | 360 s->strips[i].id = s->data[0]; |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
361 s->strips[i].y1 = y0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
362 s->strips[i].x1 = 0; |
4364 | 363 s->strips[i].y2 = y0 + AV_RB16 (&s->data[8]); |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
364 s->strips[i].x2 = s->avctx->width; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
365 |
8580
144ddb6a597c
Cinepak strip and chunk sizes are 24-bit, not 16-bit as it was thought earlier.
kostya
parents:
8573
diff
changeset
|
366 strip_size = AV_RB24 (&s->data[1]) - 12; |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
367 s->data += 12; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
368 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
|
369 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
370 if ((i > 0) && !(frame_flags & 0x01)) { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
371 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
|
372 sizeof(s->strips[i].v4_codebook)); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
373 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
|
374 sizeof(s->strips[i].v1_codebook)); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
375 } |
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 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
|
378 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
379 if (result != 0) |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
380 return result; |
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 s->data += strip_size; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
383 y0 = s->strips[i].y2; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
384 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
385 return 0; |
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 |
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
6484
diff
changeset
|
388 static av_cold int cinepak_decode_init(AVCodecContext *avctx) |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
389 { |
4827 | 390 CinepakContext *s = avctx->priv_data; |
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 s->avctx = avctx; |
1572
860e44e2c20c
support Cinepak files with funky (not divisible by 4) resolutions
melanson
parents:
1491
diff
changeset
|
393 s->width = (avctx->width + 3) & ~3; |
860e44e2c20c
support Cinepak files with funky (not divisible by 4) resolutions
melanson
parents:
1491
diff
changeset
|
394 s->height = (avctx->height + 3) & ~3; |
4262
cdcfabd40101
Another hack to allow the Cinepak decoder to detect both types of deviant Cinepak
melanson
parents:
3947
diff
changeset
|
395 s->sega_film_skip_bytes = -1; /* uninitialized state */ |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
396 |
2105 | 397 // check for paletted data |
7823
4525dcd81357
Bump Major version, this commit is almost just renaming bits_per_sample to
michael
parents:
7040
diff
changeset
|
398 if ((avctx->palctrl == NULL) || (avctx->bits_per_coded_sample == 40)) { |
2105 | 399 s->palette_video = 0; |
400 avctx->pix_fmt = PIX_FMT_YUV420P; | |
401 } else { | |
402 s->palette_video = 1; | |
403 avctx->pix_fmt = PIX_FMT_PAL8; | |
404 } | |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
405 |
2009
b13a25ac9f0c
buffer hints, use reget_buffer, removed copy from previous frame
rtognimp
parents:
1881
diff
changeset
|
406 s->frame.data[0] = NULL; |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
407 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
408 return 0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
409 } |
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 static int cinepak_decode_frame(AVCodecContext *avctx, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
412 void *data, int *data_size, |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
413 AVPacket *avpkt) |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
414 { |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
415 const uint8_t *buf = avpkt->data; |
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
416 int buf_size = avpkt->size; |
4827 | 417 CinepakContext *s = avctx->priv_data; |
1491
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 s->data = buf; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
420 s->size = buf_size; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
421 |
2009
b13a25ac9f0c
buffer hints, use reget_buffer, removed copy from previous frame
rtognimp
parents:
1881
diff
changeset
|
422 s->frame.reference = 1; |
b13a25ac9f0c
buffer hints, use reget_buffer, removed copy from previous frame
rtognimp
parents:
1881
diff
changeset
|
423 s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | |
b13a25ac9f0c
buffer hints, use reget_buffer, removed copy from previous frame
rtognimp
parents:
1881
diff
changeset
|
424 FF_BUFFER_HINTS_REUSABLE; |
b13a25ac9f0c
buffer hints, use reget_buffer, removed copy from previous frame
rtognimp
parents:
1881
diff
changeset
|
425 if (avctx->reget_buffer(avctx, &s->frame)) { |
b13a25ac9f0c
buffer hints, use reget_buffer, removed copy from previous frame
rtognimp
parents:
1881
diff
changeset
|
426 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
|
427 return -1; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
428 } |
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 cinepak_decode(s); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
431 |
2105 | 432 if (s->palette_video) { |
433 memcpy (s->frame.data[1], avctx->palctrl->palette, AVPALETTE_SIZE); | |
434 if (avctx->palctrl->palette_changed) { | |
435 s->frame.palette_has_changed = 1; | |
436 avctx->palctrl->palette_changed = 0; | |
437 } else | |
438 s->frame.palette_has_changed = 0; | |
439 } | |
440 | |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
441 *data_size = sizeof(AVFrame); |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
442 *(AVFrame*)data = s->frame; |
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 /* report that the buffer was completely consumed */ |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
445 return buf_size; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
446 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
447 |
6517
48759bfbd073
Apply 'cold' attribute to init/uninit functions in libavcodec
zuxy
parents:
6484
diff
changeset
|
448 static av_cold int cinepak_decode_end(AVCodecContext *avctx) |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
449 { |
4827 | 450 CinepakContext *s = avctx->priv_data; |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
451 |
2009
b13a25ac9f0c
buffer hints, use reget_buffer, removed copy from previous frame
rtognimp
parents:
1881
diff
changeset
|
452 if (s->frame.data[0]) |
b13a25ac9f0c
buffer hints, use reget_buffer, removed copy from previous frame
rtognimp
parents:
1881
diff
changeset
|
453 avctx->release_buffer(avctx, &s->frame); |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
454 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
455 return 0; |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
456 } |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
457 |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
458 AVCodec cinepak_decoder = { |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
459 "cinepak", |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
460 CODEC_TYPE_VIDEO, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
461 CODEC_ID_CINEPAK, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
462 sizeof(CinepakContext), |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
463 cinepak_decode_init, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
464 NULL, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
465 cinepak_decode_end, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
466 cinepak_decode_frame, |
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
467 CODEC_CAP_DR1, |
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6710
diff
changeset
|
468 .long_name = NULL_IF_CONFIG_SMALL("Cinepak"), |
1491
222643544cf1
New demuxers: Sega FILM/CPK, Westwood VQA & AUD; new decoders: MS RLE &
tmmm
parents:
diff
changeset
|
469 }; |