Mercurial > libavcodec.hg
annotate vmdav.c @ 1893:779bdf5063ce libavcodec
1000000l (using uninitalized variable for initalizing bits per MV table)
author | michael |
---|---|
date | Tue, 16 Mar 2004 16:57:27 +0000 |
parents | 5456ab242388 |
children | d7505fbe66cb |
rev | line source |
---|---|
1717
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
1 /* |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
2 * Sierra VMD Audio & Video Decoders |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
3 * Copyright (C) 2004 the ffmpeg project |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
4 * |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
5 * This library is free software; you can redistribute it and/or |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
6 * modify it under the terms of the GNU Lesser General Public |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
7 * License as published by the Free Software Foundation; either |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
8 * version 2 of the License, or (at your option) any later version. |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
9 * |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
10 * This library is distributed in the hope that it will be useful, |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
13 * Lesser General Public License for more details. |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
14 * |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
15 * You should have received a copy of the GNU Lesser General Public |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
16 * License along with this library; if not, write to the Free Software |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
18 * |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
19 */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
20 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
21 /** |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
22 * @file vmdvideo.c |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
23 * Sierra VMD audio & video decoders |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
24 * by Vladimir "VAG" Gneushev (vagsoft at mail.ru) |
1882
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
25 * for more information on the Sierra VMD format, visit: |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
26 * http://www.pcisys.net/~melanson/codecs/ |
1717
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
27 * |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
28 * The video decoder outputs PAL8 colorspace data. The decoder expects |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
29 * a 0x330-byte VMD file header to be transmitted via extradata during |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
30 * codec initialization. Each encoded frame that is sent to this decoder |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
31 * is expected to be prepended with the appropriate 16-byte frame |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
32 * information record from the VMD file. |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
33 * |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
34 * The audio decoder, like the video decoder, expects each encoded data |
1882
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
35 * chunk to be prepended with the appropriate 16-byte frame information |
1717
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
36 * record from the VMD file. It does not require the 0x330-byte VMD file |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
37 * header, but it does need the audio setup parameters passed in through |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
38 * normal libavcodec API means. |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
39 */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
40 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
41 #include <stdio.h> |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
42 #include <stdlib.h> |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
43 #include <string.h> |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
44 #include <unistd.h> |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
45 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
46 #include "common.h" |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
47 #include "avcodec.h" |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
48 #include "dsputil.h" |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
49 |
1823
a660ef952580
(f)printf() is disallowed in libavcodec, compilation will fail now if its used, except that codecs which where added after the printf->av_log change which did ignore av_log() and used prinf are now silent and wont print anything, they should be changed to use av_log, i could do that, but its better if the orginal developer decides which AV_LOG level each message should get
michael
parents:
1717
diff
changeset
|
50 #define printf(...) {} //(f)printf() usage is forbidden in libavcodec, use av_log |
a660ef952580
(f)printf() is disallowed in libavcodec, compilation will fail now if its used, except that codecs which where added after the printf->av_log change which did ignore av_log() and used prinf are now silent and wont print anything, they should be changed to use av_log, i could do that, but its better if the orginal developer decides which AV_LOG level each message should get
michael
parents:
1717
diff
changeset
|
51 #define fprintf(...) {} |
a660ef952580
(f)printf() is disallowed in libavcodec, compilation will fail now if its used, except that codecs which where added after the printf->av_log change which did ignore av_log() and used prinf are now silent and wont print anything, they should be changed to use av_log, i could do that, but its better if the orginal developer decides which AV_LOG level each message should get
michael
parents:
1717
diff
changeset
|
52 |
1717
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
53 #define VMD_HEADER_SIZE 0x330 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
54 #define PALETTE_COUNT 256 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
55 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
56 /* |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
57 * Video Decoder |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
58 */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
59 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
60 typedef struct VmdVideoContext { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
61 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
62 AVCodecContext *avctx; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
63 DSPContext dsp; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
64 AVFrame frame; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
65 AVFrame prev_frame; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
66 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
67 unsigned char *buf; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
68 int size; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
69 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
70 unsigned char palette[PALETTE_COUNT * 4]; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
71 unsigned char *unpack_buffer; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
72 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
73 } VmdVideoContext; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
74 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
75 #define QUEUE_SIZE 0x1000 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
76 #define QUEUE_MASK 0x0FFF |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
77 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
78 static void lz_unpack(unsigned char *src, unsigned char *dest) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
79 { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
80 unsigned char *s; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
81 unsigned char *d; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
82 unsigned char queue[QUEUE_SIZE]; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
83 unsigned int qpos; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
84 unsigned int dataleft; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
85 unsigned int chainofs; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
86 unsigned int chainlen; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
87 unsigned int speclen; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
88 unsigned char tag; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
89 unsigned int i, j; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
90 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
91 s = src; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
92 d = dest; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
93 dataleft = LE_32(s); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
94 s += 4; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
95 memset(queue, QUEUE_SIZE, 0x20); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
96 if (LE_32(s) == 0x56781234) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
97 s += 4; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
98 qpos = 0x111; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
99 speclen = 0xF + 3; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
100 } else { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
101 qpos = 0xFEE; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
102 speclen = 100; /* no speclen */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
103 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
104 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
105 while (dataleft > 0) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
106 tag = *s++; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
107 if ((tag == 0xFF) && (dataleft > 8)) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
108 for (i = 0; i < 8; i++) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
109 queue[qpos++] = *d++ = *s++; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
110 qpos &= QUEUE_MASK; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
111 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
112 dataleft -= 8; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
113 } else { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
114 for (i = 0; i < 8; i++) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
115 if (dataleft == 0) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
116 break; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
117 if (tag & 0x01) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
118 queue[qpos++] = *d++ = *s++; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
119 qpos &= QUEUE_MASK; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
120 dataleft--; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
121 } else { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
122 chainofs = *s++; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
123 chainofs |= ((*s & 0xF0) << 4); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
124 chainlen = (*s++ & 0x0F) + 3; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
125 if (chainlen == speclen) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
126 chainlen = *s++ + 0xF + 3; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
127 for (j = 0; j < chainlen; j++) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
128 *d = queue[chainofs++ & QUEUE_MASK]; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
129 queue[qpos++] = *d++; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
130 qpos &= QUEUE_MASK; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
131 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
132 dataleft -= chainlen; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
133 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
134 tag >>= 1; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
135 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
136 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
137 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
138 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
139 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
140 static int rle_unpack(unsigned char *src, unsigned char *dest, int len) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
141 { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
142 unsigned char *ps; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
143 unsigned char *pd; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
144 int i, l; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
145 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
146 ps = src; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
147 pd = dest; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
148 if (len & 1) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
149 *pd++ = *ps++; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
150 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
151 len >>= 1; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
152 i = 0; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
153 do { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
154 l = *ps++; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
155 if (l & 0x80) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
156 l = (l & 0x7F) * 2; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
157 memcpy(pd, ps, l); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
158 ps += l; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
159 pd += l; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
160 } else { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
161 for (i = 0; i < l; i++) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
162 *pd++ = ps[0]; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
163 *pd++ = ps[1]; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
164 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
165 ps += 2; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
166 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
167 i += l; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
168 } while (i < len); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
169 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
170 return (ps - src); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
171 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
172 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
173 static void vmd_decode(VmdVideoContext *s) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
174 { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
175 int i; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
176 unsigned int *palette32; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
177 unsigned char r, g, b; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
178 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
179 /* point to the start of the encoded data */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
180 unsigned char *p = s->buf + 16; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
181 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
182 unsigned char *pb; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
183 unsigned char meth; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
184 unsigned char *dp; /* pointer to current frame */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
185 unsigned char *pp; /* pointer to previous frame */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
186 unsigned char len; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
187 int ofs; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
188 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
189 int frame_x, frame_y; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
190 int frame_width, frame_height; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
191 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
192 frame_x = LE_16(&s->buf[6]); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
193 frame_y = LE_16(&s->buf[8]); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
194 frame_width = LE_16(&s->buf[10]) - frame_x + 1; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
195 frame_height = LE_16(&s->buf[12]) - frame_y + 1; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
196 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
197 /* if only a certain region will be updated, copy the entire previous |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
198 * frame before the decode */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
199 if (frame_x || frame_y || (frame_width != s->avctx->width) || |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
200 (frame_height != s->avctx->height)) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
201 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
202 memcpy(s->frame.data[0], s->prev_frame.data[0], |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
203 s->avctx->height * s->frame.linesize[0]); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
204 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
205 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
206 /* check if there is a new palette */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
207 if (s->buf[15] & 0x02) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
208 p += 2; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
209 palette32 = (unsigned int *)s->palette; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
210 for (i = 0; i < PALETTE_COUNT; i++) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
211 r = *p++ * 4; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
212 g = *p++ * 4; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
213 b = *p++ * 4; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
214 palette32[i] = (r << 16) | (g << 8) | (b); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
215 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
216 s->size -= (256 * 3 + 2); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
217 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
218 if (s->size >= 0) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
219 /* originally UnpackFrame in VAG's code */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
220 pb = p; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
221 meth = *pb++; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
222 if (meth & 0x80) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
223 lz_unpack(pb, s->unpack_buffer); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
224 meth &= 0x7F; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
225 pb = s->unpack_buffer; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
226 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
227 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
228 dp = &s->frame.data[0][frame_y * s->frame.linesize[0] + frame_x]; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
229 pp = &s->prev_frame.data[0][frame_y * s->prev_frame.linesize[0] + frame_x]; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
230 switch (meth) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
231 case 1: |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
232 for (i = 0; i < frame_height; i++) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
233 ofs = 0; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
234 do { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
235 len = *pb++; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
236 if (len & 0x80) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
237 len = (len & 0x7F) + 1; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
238 memcpy(&dp[ofs], pb, len); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
239 pb += len; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
240 ofs += len; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
241 } else { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
242 /* interframe pixel copy */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
243 memcpy(&dp[ofs], &pp[ofs], len + 1); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
244 ofs += len + 1; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
245 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
246 } while (ofs < frame_width); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
247 if (ofs > frame_width) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
248 printf (" VMD video: offset > width (%d > %d)\n", |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
249 ofs, frame_width); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
250 break; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
251 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
252 dp += s->frame.linesize[0]; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
253 pp += s->prev_frame.linesize[0]; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
254 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
255 break; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
256 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
257 case 2: |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
258 for (i = 0; i < frame_height; i++) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
259 memcpy(dp, pb, frame_width); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
260 pb += frame_width; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
261 dp += s->frame.linesize[0]; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
262 pp += s->prev_frame.linesize[0]; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
263 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
264 break; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
265 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
266 case 3: |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
267 for (i = 0; i < frame_height; i++) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
268 ofs = 0; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
269 do { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
270 len = *pb++; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
271 if (len & 0x80) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
272 len = (len & 0x7F) + 1; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
273 if (*pb++ == 0xFF) |
1882
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
274 len = rle_unpack(pb, &dp[ofs], len); |
1717
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
275 else |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
276 memcpy(&dp[ofs], pb, len); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
277 pb += len; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
278 ofs += len; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
279 } else { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
280 /* interframe pixel copy */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
281 memcpy(&dp[ofs], &pp[ofs], len + 1); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
282 ofs += len + 1; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
283 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
284 } while (ofs < frame_width); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
285 if (ofs > frame_width) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
286 printf (" VMD video: offset > width (%d > %d)\n", |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
287 ofs, frame_width); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
288 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
289 dp += s->frame.linesize[0]; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
290 pp += s->prev_frame.linesize[0]; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
291 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
292 break; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
293 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
294 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
295 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
296 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
297 static int vmdvideo_decode_init(AVCodecContext *avctx) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
298 { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
299 VmdVideoContext *s = (VmdVideoContext *)avctx->priv_data; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
300 int i; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
301 unsigned int *palette32; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
302 int palette_index = 0; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
303 unsigned char r, g, b; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
304 unsigned char *vmd_header; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
305 unsigned char *raw_palette; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
306 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
307 s->avctx = avctx; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
308 avctx->pix_fmt = PIX_FMT_PAL8; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
309 avctx->has_b_frames = 0; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
310 dsputil_init(&s->dsp, avctx); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
311 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
312 /* make sure the VMD header made it */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
313 if (s->avctx->extradata_size != VMD_HEADER_SIZE) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
314 printf(" VMD video: expected extradata size of %d\n", |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
315 VMD_HEADER_SIZE); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
316 return -1; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
317 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
318 vmd_header = (unsigned char *)avctx->extradata; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
319 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
320 s->unpack_buffer = av_malloc(LE_32(&vmd_header[800])); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
321 if (!s->unpack_buffer) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
322 return -1; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
323 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
324 /* load up the initial palette */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
325 raw_palette = &vmd_header[28]; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
326 palette32 = (unsigned int *)s->palette; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
327 for (i = 0; i < PALETTE_COUNT; i++) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
328 r = raw_palette[palette_index++] * 4; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
329 g = raw_palette[palette_index++] * 4; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
330 b = raw_palette[palette_index++] * 4; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
331 palette32[i] = (r << 16) | (g << 8) | (b); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
332 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
333 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
334 s->frame.data[0] = s->prev_frame.data[0] = NULL; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
335 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
336 return 0; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
337 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
338 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
339 static int vmdvideo_decode_frame(AVCodecContext *avctx, |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
340 void *data, int *data_size, |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
341 uint8_t *buf, int buf_size) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
342 { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
343 VmdVideoContext *s = (VmdVideoContext *)avctx->priv_data; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
344 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
345 s->buf = buf; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
346 s->size = buf_size; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
347 |
1882
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
348 if (buf_size < 16) |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
349 return buf_size; |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
350 |
1717
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
351 s->frame.reference = 1; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
352 if (avctx->get_buffer(avctx, &s->frame)) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
353 printf (" VMD Video: get_buffer() failed\n"); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
354 return -1; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
355 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
356 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
357 vmd_decode(s); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
358 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
359 /* make the palette available on the way out */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
360 memcpy(s->frame.data[1], s->palette, PALETTE_COUNT * 4); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
361 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
362 if (s->prev_frame.data[0]) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
363 avctx->release_buffer(avctx, &s->prev_frame); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
364 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
365 /* shuffle frames */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
366 s->prev_frame = s->frame; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
367 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
368 *data_size = sizeof(AVFrame); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
369 *(AVFrame*)data = s->frame; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
370 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
371 /* report that the buffer was completely consumed */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
372 return buf_size; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
373 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
374 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
375 static int vmdvideo_decode_end(AVCodecContext *avctx) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
376 { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
377 VmdVideoContext *s = (VmdVideoContext *)avctx->priv_data; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
378 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
379 if (s->prev_frame.data[0]) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
380 avctx->release_buffer(avctx, &s->prev_frame); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
381 av_free(s->unpack_buffer); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
382 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
383 return 0; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
384 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
385 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
386 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
387 /* |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
388 * Audio Decoder |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
389 */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
390 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
391 typedef struct VmdAudioContext { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
392 int channels; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
393 int bits; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
394 int block_align; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
395 unsigned char steps8[16]; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
396 unsigned short steps16[16]; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
397 unsigned short steps128[256]; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
398 short predictors[2]; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
399 } VmdAudioContext; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
400 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
401 static int vmdaudio_decode_init(AVCodecContext *avctx) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
402 { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
403 VmdAudioContext *s = (VmdAudioContext *)avctx->priv_data; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
404 int i; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
405 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
406 s->channels = avctx->channels; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
407 s->bits = avctx->bits_per_sample; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
408 s->block_align = avctx->block_align; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
409 |
1882
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
410 printf (" %d channels, %d bits/sample, block align = %d, sample rate = %d\n", |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
411 s->channels, s->bits, s->block_align, avctx->sample_rate); |
1717
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
412 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
413 /* set up the steps8 and steps16 tables */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
414 for (i = 0; i < 8; i++) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
415 if (i < 4) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
416 s->steps8[i] = i; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
417 else |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
418 s->steps8[i] = s->steps8[i - 1] + i - 1; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
419 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
420 if (i == 0) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
421 s->steps16[i] = 0; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
422 else if (i == 1) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
423 s->steps16[i] = 4; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
424 else if (i == 2) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
425 s->steps16[i] = 16; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
426 else |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
427 s->steps16[i] = 1 << (i + 4); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
428 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
429 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
430 /* set up the step128 table */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
431 s->steps128[0] = 0; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
432 s->steps128[1] = 8; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
433 for (i = 0x02; i <= 0x20; i++) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
434 s->steps128[i] = (i - 1) << 4; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
435 for (i = 0x21; i <= 0x60; i++) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
436 s->steps128[i] = (i + 0x1F) << 3; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
437 for (i = 0x61; i <= 0x70; i++) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
438 s->steps128[i] = (i - 0x51) << 6; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
439 for (i = 0x71; i <= 0x78; i++) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
440 s->steps128[i] = (i - 0x69) << 8; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
441 for (i = 0x79; i <= 0x7D; i++) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
442 s->steps128[i] = (i - 0x75) << 10; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
443 s->steps128[0x7E] = 0x3000; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
444 s->steps128[0x7F] = 0x4000; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
445 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
446 /* set up the negative half of each table */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
447 for (i = 0; i < 8; i++) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
448 s->steps8[i + 8] = -s->steps8[i]; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
449 s->steps16[i + 8] = -s->steps16[i]; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
450 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
451 for (i = 0; i < 128; i++) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
452 s->steps128[i + 128] = -s->steps128[i]; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
453 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
454 return 0; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
455 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
456 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
457 static void vmdaudio_decode_audio(VmdAudioContext *s, unsigned char *data, |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
458 uint8_t *buf, int ratio) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
459 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
460 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
461 |
1882
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
462 static int vmdaudio_loadsound(VmdAudioContext *s, unsigned char *data, |
1717
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
463 uint8_t *buf, int silence) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
464 { |
1882
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
465 int bytes_decoded = 0; |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
466 int i; |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
467 |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
468 if (silence) |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
469 printf (" silent block!\n"); |
1717
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
470 if (s->channels == 2) { |
1882
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
471 |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
472 /* stereo handling */ |
1717
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
473 if ((s->block_align & 0x01) == 0) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
474 if (silence) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
475 memset(data, 0, s->block_align * 2); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
476 else |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
477 vmdaudio_decode_audio(s, data, buf, 1); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
478 } else { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
479 if (silence) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
480 memset(data, 0, s->block_align * 2); |
1882
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
481 else |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
482 vmdaudio_decode_audio(s, data, buf, 1); |
1717
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
483 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
484 } else { |
1882
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
485 |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
486 /* mono handling */ |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
487 if (silence) { |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
488 if (s->bits == 16) { |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
489 memset(data, 0, s->block_align * 2); |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
490 bytes_decoded = s->block_align * 2; |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
491 } else { |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
492 // memset(data, 0x00, s->block_align); |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
493 // bytes_decoded = s->block_align; |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
494 memset(data, 0x00, s->block_align * 2); |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
495 bytes_decoded = s->block_align * 2; |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
496 } |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
497 } else { |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
498 if (s->bits == 16) { |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
499 } else { |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
500 /* copy the data but convert it to signed */ |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
501 for (i = 0; i < s->block_align; i++) |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
502 data[i * 2 + 1] = buf[i] + 0x80; |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
503 bytes_decoded = s->block_align * 2; |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
504 } |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
505 } |
1717
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
506 } |
1882
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
507 |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
508 return bytes_decoded; |
1717
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
509 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
510 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
511 static int vmdaudio_decode_frame(AVCodecContext *avctx, |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
512 void *data, int *data_size, |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
513 uint8_t *buf, int buf_size) |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
514 { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
515 VmdAudioContext *s = (VmdAudioContext *)avctx->priv_data; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
516 unsigned int sound_flags; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
517 unsigned char *output_samples = (unsigned char *)data; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
518 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
519 /* point to the start of the encoded data */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
520 unsigned char *p = buf + 16; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
521 unsigned char *p_end = buf + buf_size; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
522 |
1882
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
523 printf (" processing audio frame with %d bytes\n", buf_size); |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
524 if (buf_size < 16) |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
525 return buf_size; |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
526 |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
527 *data_size = 0; |
1717
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
528 if (buf[6] == 1) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
529 /* the chunk contains audio */ |
1882
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
530 *data_size = vmdaudio_loadsound(s, output_samples, p, 0); |
1717
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
531 } else if (buf[6] == 2) { |
1882
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
532 printf (" hey! audio case #2\n"); |
1717
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
533 /* the chunk contains audio and silence mixed together */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
534 sound_flags = LE_32(p); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
535 p += 4; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
536 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
537 /* do something with extrabufs here? */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
538 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
539 while (p < p_end) { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
540 if (sound_flags & 0x01) |
1882
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
541 /* silence */ |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
542 *data_size += vmdaudio_loadsound(s, output_samples, p, 1); |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
543 else { |
1717
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
544 /* audio */ |
1882
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
545 *data_size += vmdaudio_loadsound(s, output_samples, p, 0); |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
546 p += s->block_align; |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
547 } |
1717
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
548 output_samples += (s->block_align * s->bits / 8); |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
549 sound_flags >>= 1; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
550 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
551 } else if (buf[6] == 3) { |
1882
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
552 printf (" hey! audio case #3\n"); |
1717
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
553 /* silent chunk */ |
1882
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
554 *data_size = vmdaudio_loadsound(s, output_samples, p, 1); |
1717
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
555 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
556 |
1882
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
557 printf (" final sample count = %d, byte count = %d\n", (*data_size) / 2, |
5456ab242388
minor VMD system update; still not perfect, but should not crash either
melanson
parents:
1823
diff
changeset
|
558 *data_size); |
1717
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
559 return buf_size; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
560 } |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
561 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
562 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
563 /* |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
564 * Public Data Structures |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
565 */ |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
566 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
567 AVCodec vmdvideo_decoder = { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
568 "vmdvideo", |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
569 CODEC_TYPE_VIDEO, |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
570 CODEC_ID_VMDVIDEO, |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
571 sizeof(VmdVideoContext), |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
572 vmdvideo_decode_init, |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
573 NULL, |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
574 vmdvideo_decode_end, |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
575 vmdvideo_decode_frame, |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
576 CODEC_CAP_DR1, |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
577 }; |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
578 |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
579 AVCodec vmdaudio_decoder = { |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
580 "vmdaudio", |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
581 CODEC_TYPE_AUDIO, |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
582 CODEC_ID_VMDAUDIO, |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
583 sizeof(VmdAudioContext), |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
584 vmdaudio_decode_init, |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
585 NULL, |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
586 NULL, |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
587 vmdaudio_decode_frame, |
6a7e68899d8a
first pass at Sierra VMD A/V decoders; video looks great, audio is not
melanson
parents:
diff
changeset
|
588 }; |