1 /*
2 * Renderware TeXture Dictionary (.txd) image decoder
3 * Copyright (c) 2007 Ivo van Poorten
4 *
5 * See also: http://wiki.multimedia.cx/index.php?title=TXD
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
30
38 uint32_t *pal;
40
42 version = bytestream2_get_le32(&gb);
44 d3d_format = bytestream2_get_le32(&gb);
45 w = bytestream2_get_le16(&gb);
46 h = bytestream2_get_le16(&gb);
47 depth = bytestream2_get_byte(&gb);
49 flags = bytestream2_get_byte(&gb);
50
51 if (version < 8 || version > 9) {
53 version);
55 }
56
57 if (depth == 8) {
59 } else if (depth == 16 || depth == 32) {
61 } else {
64 }
65
68
71
73
76
77 if (depth == 8) {
78 pal = (uint32_t *) p->
data[1];
79 for (y = 0; y < 256; y++) {
80 v = bytestream2_get_be32(&gb);
81 pal[
y] = (v >> 8) + (v << 24);
82 }
86 for (y=0; y<h; y++) {
88 ptr += stride;
89 }
90 } else if (depth == 16) {
92 switch (d3d_format) {
93 case 0:
94 if (!(flags & 1))
100 break;
105 break;
106 default:
108 }
109 } else if (depth == 32) {
110 switch (d3d_format) {
111 case 0x15:
112 case 0x16:
115 for (y=0; y<h; y++) {
117 ptr += stride;
118 }
119 break;
120 default:
122 }
123 }
124
125 *got_frame = 1;
126
128
132 }
133
141 };