Go to the documentation of this file.
40 #define DDPF_FOURCC (1 << 2)
41 #define DDPF_PALETTE (1 << 5)
42 #define DDPF_NORMALMAP (1U << 31)
118 int alpha_exponent, ycocg_classic, ycocg_scaled, normal_map,
array;
122 gimp_tag = bytestream2_get_le32(gbc);
123 alpha_exponent = gimp_tag ==
MKTAG(
'A',
'E',
'X',
'P');
124 ycocg_classic = gimp_tag ==
MKTAG(
'Y',
'C',
'G',
'1');
125 ycocg_scaled = gimp_tag ==
MKTAG(
'Y',
'C',
'G',
'2');
129 size = bytestream2_get_le32(gbc);
134 flags = bytestream2_get_le32(gbc);
138 fourcc = bytestream2_get_le32(gbc);
140 if (
ctx->compressed &&
ctx->paletted) {
142 "Disabling invalid palette flag for compressed dds.\n");
146 bpp =
ctx->bpp = bytestream2_get_le32(gbc);
147 r = bytestream2_get_le32(gbc);
148 g = bytestream2_get_le32(gbc);
149 b = bytestream2_get_le32(gbc);
150 a = bytestream2_get_le32(gbc);
166 if (
ctx->compressed) {
167 ctx->dec.raw_ratio = 16;
169 case MKTAG(
'D',
'X',
'T',
'1'):
170 ctx->dec.tex_ratio = 8;
171 ctx->dec.tex_funct =
ctx->texdsp.dxt1a_block;
173 case MKTAG(
'D',
'X',
'T',
'2'):
174 ctx->dec.tex_ratio = 16;
175 ctx->dec.tex_funct =
ctx->texdsp.dxt2_block;
177 case MKTAG(
'D',
'X',
'T',
'3'):
178 ctx->dec.tex_ratio = 16;
179 ctx->dec.tex_funct =
ctx->texdsp.dxt3_block;
181 case MKTAG(
'D',
'X',
'T',
'4'):
182 ctx->dec.tex_ratio = 16;
183 ctx->dec.tex_funct =
ctx->texdsp.dxt4_block;
185 case MKTAG(
'D',
'X',
'T',
'5'):
186 ctx->dec.tex_ratio = 16;
188 ctx->dec.tex_funct =
ctx->texdsp.dxt5ys_block;
189 else if (ycocg_classic)
190 ctx->dec.tex_funct =
ctx->texdsp.dxt5y_block;
192 ctx->dec.tex_funct =
ctx->texdsp.dxt5_block;
194 case MKTAG(
'R',
'X',
'G',
'B'):
195 ctx->dec.tex_ratio = 16;
196 ctx->dec.tex_funct =
ctx->texdsp.dxt5_block;
202 case MKTAG(
'A',
'T',
'I',
'1'):
203 case MKTAG(
'B',
'C',
'4',
'U'):
204 ctx->dec.tex_ratio = 8;
205 ctx->dec.tex_funct =
ctx->texdsp.rgtc1u_block;
207 case MKTAG(
'B',
'C',
'4',
'S'):
208 ctx->dec.tex_ratio = 8;
209 ctx->dec.tex_funct =
ctx->texdsp.rgtc1s_block;
211 case MKTAG(
'A',
'T',
'I',
'2'):
213 ctx->dec.tex_ratio = 16;
214 ctx->dec.tex_funct =
ctx->texdsp.dxn3dc_block;
216 case MKTAG(
'B',
'C',
'5',
'U'):
217 ctx->dec.tex_ratio = 16;
218 ctx->dec.tex_funct =
ctx->texdsp.rgtc2u_block;
220 case MKTAG(
'B',
'C',
'5',
'S'):
221 ctx->dec.tex_ratio = 16;
222 ctx->dec.tex_funct =
ctx->texdsp.rgtc2s_block;
224 case MKTAG(
'U',
'Y',
'V',
'Y'):
228 case MKTAG(
'Y',
'U',
'Y',
'2'):
232 case MKTAG(
'P',
'8',
' ',
' '):
238 case MKTAG(
'G',
'1',
' ',
' '):
242 case MKTAG(
'D',
'X',
'1',
'0'):
244 dxgi = bytestream2_get_le32(gbc);
247 array = bytestream2_get_le32(gbc);
252 "Found array of size %d (ignored).\n",
array);
255 ctx->compressed = (dxgi >= 70) && (dxgi <= 84);
297 ctx->dec.tex_ratio = 8;
298 ctx->dec.tex_funct =
ctx->texdsp.dxt1a_block;
304 ctx->dec.tex_ratio = 16;
305 ctx->dec.tex_funct =
ctx->texdsp.dxt3_block;
311 ctx->dec.tex_ratio = 16;
312 ctx->dec.tex_funct =
ctx->texdsp.dxt5_block;
316 ctx->dec.tex_ratio = 8;
317 ctx->dec.tex_funct =
ctx->texdsp.rgtc1u_block;
320 ctx->dec.tex_ratio = 8;
321 ctx->dec.tex_funct =
ctx->texdsp.rgtc1s_block;
325 ctx->dec.tex_ratio = 16;
326 ctx->dec.tex_funct =
ctx->texdsp.rgtc2u_block;
329 ctx->dec.tex_ratio = 16;
330 ctx->dec.tex_funct =
ctx->texdsp.rgtc2s_block;
334 "Unsupported DXGI format %d.\n", dxgi);
342 }
else if (
ctx->paletted) {
351 if (bpp == 4 &&
r == 0 &&
g == 0 &&
b == 0 &&
a == 0)
354 else if (bpp == 8 &&
r == 0xff &&
g == 0 &&
b == 0 &&
a == 0)
356 else if (bpp == 8 &&
r == 0 &&
g == 0 &&
b == 0 &&
a == 0xff)
359 else if (bpp == 16 &&
r == 0xff &&
g == 0 &&
b == 0 &&
a == 0xff00)
361 else if (bpp == 16 &&
r == 0xff00 &&
g == 0 &&
b == 0 &&
a == 0xff) {
365 else if (bpp == 16 &&
r == 0xffff &&
g == 0 &&
b == 0 &&
a == 0)
367 else if (bpp == 16 &&
r == 0x7c00 &&
g == 0x3e0 &&
b == 0x1f &&
a == 0)
369 else if (bpp == 16 &&
r == 0x7c00 &&
g == 0x3e0 &&
b == 0x1f &&
a == 0x8000)
371 else if (bpp == 16 &&
r == 0xf800 &&
g == 0x7e0 &&
b == 0x1f &&
a == 0)
374 else if (bpp == 24 &&
r == 0xff0000 &&
g == 0xff00 &&
b == 0xff &&
a == 0)
377 else if (bpp == 32 &&
r == 0xff0000 &&
g == 0xff00 &&
b == 0xff &&
a == 0)
379 else if (bpp == 32 &&
r == 0xff &&
g == 0xff00 &&
b == 0xff0000 &&
a == 0)
381 else if (bpp == 32 &&
r == 0xff0000 &&
g == 0xff00 &&
b == 0xff &&
a == 0xff000000)
383 else if (bpp == 32 &&
r == 0xff &&
g == 0xff00 &&
b == 0xff0000 &&
a == 0xff000000)
388 "[bpp %d r 0x%x g 0x%x b 0x%x a 0x%x].\n", bpp,
r,
g,
b,
a);
398 else if (ycocg_classic && !
ctx->compressed)
403 case MKTAG(
'A',
'2',
'X',
'Y'):
406 case MKTAG(
'x',
'G',
'B',
'R'):
409 case MKTAG(
'x',
'R',
'B',
'G'):
412 case MKTAG(
'R',
'B',
'x',
'G'):
415 case MKTAG(
'R',
'G',
'x',
'B'):
418 case MKTAG(
'R',
'x',
'B',
'G'):
421 case MKTAG(
'x',
'G',
'x',
'R'):
424 case MKTAG(
'A',
'2',
'D',
'5'):
446 switch (
ctx->postproc) {
460 src[0] =
r *
a / 255;
461 src[1] =
g *
a / 255;
462 src[2] =
b *
a / 255;
474 x_off =
ctx->dec.tex_ratio == 8 ? 0 : 3;
481 int d = (255 * 255 - x * x - y * y) / 2;
499 int cg =
src[1] - 128;
500 int co =
src[2] - 128;
585 if (bytestream2_get_le32(gbc) !=
MKTAG(
'D',
'D',
'S',
' ') ||
586 bytestream2_get_le32(gbc) != 124) {
593 height = bytestream2_get_le32(gbc);
594 width = bytestream2_get_le32(gbc);
608 mipmap = bytestream2_get_le32(gbc);
622 if (
ctx->compressed) {
630 "Compressed Buffer is too small (%d < %d).\n",
646 for (
i = 0;
i < 16;
i++) {
654 #if FF_API_PALETTE_HAS_CHANGED
668 uint8_t
val = bytestream2_get_byte(gbc);
670 dst[x + 1] =
val >> 4;
681 for (
i = 0;
i < 256;
i++)
689 #if FF_API_PALETTE_HAS_CHANGED
#define FF_ENABLE_DEPRECATION_WARNINGS
#define AV_LOG_WARNING
Something somehow does not look correct.
@ DXGI_FORMAT_B8G8R8A8_TYPELESS
@ DXGI_FORMAT_BC2_UNORM_SRGB
static int dds_decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
attribute_deprecated int palette_has_changed
Tell user application that palette has changed from previous frame.
@ AV_PIX_FMT_YA8
8 bits gray, 8 bits alpha
enum AVColorSpace colorspace
YUV colorspace type.
@ DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
@ DXGI_FORMAT_B8G8R8X8_UNORM
@ DXGI_FORMAT_B5G6R5_UNORM
@ DXGI_FORMAT_B8G8R8A8_UNORM
This structure describes decoded (raw) audio or video data.
@ DXGI_FORMAT_BC4_TYPELESS
#define AV_LOG_VERBOSE
Detailed information.
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
@ DXGI_FORMAT_R16G16B16A16_TYPELESS
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
@ DXGI_FORMAT_B8G8R8X8_UNORM_SRGB
int ff_texturedsp_decompress_thread(AVCodecContext *avctx, void *arg, int slice, int thread_nb)
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.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
@ DXGI_FORMAT_BC1_TYPELESS
AVCodec p
The public AVCodec.
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
static double val(void *priv, double ch)
static void run_postproc(AVCodecContext *avctx, AVFrame *frame)
@ DXGI_FORMAT_B8G8R8X8_TYPELESS
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
#define FF_CODEC_DECODE_CB(func)
@ DXGI_FORMAT_R16G16B16A16_SNORM
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
av_cold void ff_texturedsp_init(TextureDSPContext *c)
#define CODEC_LONG_NAME(str)
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
@ AV_PIX_FMT_RGB565LE
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
@ DXGI_FORMAT_R16G16B16A16_UNORM
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
@ AV_PIX_FMT_MONOBLACK
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb.
@ AV_PICTURE_TYPE_I
Intra.
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
static __device__ float sqrtf(float a)
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
const FFCodec ff_dds_decoder
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
enum AVPictureType pict_type
Picture type of the frame.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
@ DXGI_FORMAT_BC3_UNORM_SRGB
@ DXGI_FORMAT_R8G8B8A8_SNORM
@ DXGI_FORMAT_R8G8B8A8_TYPELESS
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
static void do_swizzle(AVFrame *frame, int x, int y)
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
@ DXGI_FORMAT_R8G8B8A8_UINT
enum DDSPostProc postproc
int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane)
Compute the size of an image line with format pix_fmt and width width for the plane plane.
@ DXGI_FORMAT_R16G16B16A16_FLOAT
#define AV_PIX_FMT_BGRA64
@ AV_PIX_FMT_RGB555LE
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined
@ DXGI_FORMAT_BC2_TYPELESS
#define i(width, name, range_min, range_max)
@ DXGI_FORMAT_R16G16B16A16_SINT
static int parse_pixel_format(AVCodecContext *avctx)
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
@ DXGI_FORMAT_BC1_UNORM_SRGB
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
static int array[MAX_W *MAX_W]
@ DXGI_FORMAT_BC5_TYPELESS
#define FFSWAP(type, a, b)
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
main external API structure.
TextureDSPThreadContext dec
@ DXGI_FORMAT_R16G16B16A16_UINT
#define FF_DISABLE_DEPRECATION_WARNINGS
int coded_width
Bitstream width / height, may be different from width/height e.g.
@ AV_PIX_FMT_GRAY16LE
Y , 16bpp, little-endian.
@ DXGI_FORMAT_BC3_TYPELESS
This structure stores compressed data.
int width
picture width / height.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define flags(name, subs,...)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
@ DXGI_FORMAT_R8G8B8A8_UNORM
#define MKTAG(a, b, c, d)
@ DXGI_FORMAT_B8G8R8A8_UNORM_SRGB
int(* execute2)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count)
The codec may call this to execute several independent things.
@ DXGI_FORMAT_R8G8B8A8_SINT
#define av_fourcc2str(fourcc)