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
31 #define TXD_DXT1 0x31545844
32 #define TXD_DXT3 0x33545844
33
40 unsigned int y, v;
42 uint32_t *pal;
43 int i, j;
44 int ret;
45
47
49 version = bytestream2_get_le32(&gb);
51 d3d_format = bytestream2_get_le32(&gb);
52 w = bytestream2_get_le16(&gb);
53 h = bytestream2_get_le16(&gb);
54 depth = bytestream2_get_byte(&gb);
56 flags = bytestream2_get_byte(&gb);
57
58 if (version < 8 || version > 9) {
61 }
62
63 if (depth == 8) {
65 } else if (depth == 16 || depth == 32) {
67 } else {
70 }
71
73 return ret;
74
77
79 return ret;
80
82
85
86 if (depth == 8) {
87 pal = (uint32_t *) p->
data[1];
88 for (y = 0; y < 256; y++) {
89 v = bytestream2_get_be32(&gb);
90 pal[y] = (v >> 8) + (v << 24);
91 }
98 }
99 } else if (depth == 16) {
101 switch (d3d_format) {
102 case 0:
103 if (!(flags & 1))
108 for (j = 0; j < avctx->
height; j += 4) {
109 for (i = 0; i < avctx->
width; i += 4) {
113 }
114 }
115 break;
119 for (j = 0; j < avctx->
height; j += 4) {
120 for (i = 0; i < avctx->
width; i += 4) {
124 }
125 }
126 break;
127 default:
129 }
130 } else if (depth == 32) {
131 switch (d3d_format) {
132 case 0x15:
133 case 0x16:
136 for (y=0; y<
h; y++) {
139 }
140 break;
141 default:
143 }
144 }
145
146 *got_frame = 1;
147
149
153 }
154
162 };
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
int coded_width
Bitstream width / height, may be different from width/height e.g.
int(* dxt1_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
Texture block (4x4) module.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
8 bits with AV_PIX_FMT_RGB32 palette
static int txd_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
const char * name
Name of the codec implementation.
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
av_cold void ff_texturedsp_init(TextureDSPContext *c)
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int(* dxt3_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
static int unsupported(AVCodecContext *avctx)
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
#define AV_CEIL_RSHIFT(a, b)