40 #define DDPF_FOURCC (1 << 2)
41 #define DDPF_PALETTE (1 << 5)
42 #define DDPF_NORMALMAP (1 << 31)
124 int alpha_exponent, ycocg_classic, ycocg_scaled, normal_map,
array;
128 gimp_tag = bytestream2_get_le32(gbc);
129 alpha_exponent = gimp_tag ==
MKTAG(
'A',
'E',
'X',
'P');
130 ycocg_classic = gimp_tag ==
MKTAG(
'Y',
'C',
'G',
'1');
131 ycocg_scaled = gimp_tag ==
MKTAG(
'Y',
'C',
'G',
'2');
135 size = bytestream2_get_le32(gbc);
140 flags = bytestream2_get_le32(gbc);
144 fourcc = bytestream2_get_le32(gbc);
148 "Disabling invalid palette flag for compressed dds.\n");
152 bpp = ctx->
bpp = bytestream2_get_le32(gbc);
153 r = bytestream2_get_le32(gbc);
154 g = bytestream2_get_le32(gbc);
155 b = bytestream2_get_le32(gbc);
156 a = bytestream2_get_le32(gbc);
166 "r 0x%x g 0x%x b 0x%x a 0x%x\n", buf, bpp, r, g, b, a);
177 case MKTAG(
'D',
'X',
'T',
'1'):
181 case MKTAG(
'D',
'X',
'T',
'2'):
185 case MKTAG(
'D',
'X',
'T',
'3'):
189 case MKTAG(
'D',
'X',
'T',
'4'):
193 case MKTAG(
'D',
'X',
'T',
'5'):
197 else if (ycocg_classic)
202 case MKTAG(
'R',
'X',
'G',
'B'):
210 case MKTAG(
'A',
'T',
'I',
'1'):
211 case MKTAG(
'B',
'C',
'4',
'U'):
215 case MKTAG(
'B',
'C',
'4',
'S'):
219 case MKTAG(
'A',
'T',
'I',
'2'):
224 case MKTAG(
'B',
'C',
'5',
'U'):
228 case MKTAG(
'B',
'C',
'5',
'S'):
232 case MKTAG(
'U',
'Y',
'V',
'Y'):
236 case MKTAG(
'Y',
'U',
'Y',
'2'):
240 case MKTAG(
'P',
'8',
' ',
' '):
246 case MKTAG(
'G',
'1',
' ',
' '):
250 case MKTAG(
'D',
'X',
'1',
'0'):
252 dxgi = bytestream2_get_le32(gbc);
255 array = bytestream2_get_le32(gbc);
260 "Found array of size %d (ignored).\n", array);
263 ctx->
compressed = (dxgi >= 70) && (dxgi <= 84);
342 "Unsupported DXGI format %d.\n", dxgi);
359 if (bpp == 4 && r == 0 && g == 0 && b == 0 && a == 0)
362 else if (bpp == 8 && r == 0xff && g == 0 && b == 0 && a == 0)
364 else if (bpp == 8 && r == 0 && g == 0 && b == 0 && a == 0xff)
367 else if (bpp == 16 && r == 0xff && g == 0 && b == 0 && a == 0xff00)
369 else if (bpp == 16 && r == 0xff00 && g == 0 && b == 0 && a == 0xff) {
373 else if (bpp == 16 && r == 0xffff && g == 0 && b == 0 && a == 0)
375 else if (bpp == 16 && r == 0x7c00 && g == 0x3e0 && b == 0x1f && a == 0)
377 else if (bpp == 16 && r == 0x7c00 && g == 0x3e0 && b == 0x1f && a == 0x8000)
379 else if (bpp == 16 && r == 0xf800 && g == 0x7e0 && b == 0x1f && a == 0)
382 else if (bpp == 24 && r == 0xff0000 && g == 0xff00 && b == 0xff && a == 0)
385 else if (bpp == 32 && r == 0xff0000 && g == 0xff00 && b == 0xff && a == 0)
387 else if (bpp == 32 && r == 0xff && g == 0xff00 && b == 0xff0000 && a == 0)
389 else if (bpp == 32 && r == 0xff0000 && g == 0xff00 && b == 0xff && a == 0xff000000)
391 else if (bpp == 32 && r == 0xff && g == 0xff00 && b == 0xff0000 && a == 0xff000000)
396 "[bpp %d r 0x%x g 0x%x b 0x%x a 0x%x].\n", bpp, r, g, b, a);
411 case MKTAG(
'A',
'2',
'X',
'Y'):
414 case MKTAG(
'x',
'G',
'B',
'R'):
417 case MKTAG(
'x',
'R',
'B',
'G'):
420 case MKTAG(
'R',
'B',
'x',
'G'):
423 case MKTAG(
'R',
'G',
'x',
'B'):
426 case MKTAG(
'R',
'x',
'B',
'G'):
429 case MKTAG(
'x',
'G',
'x',
'R'):
432 case MKTAG(
'A',
'2',
'D',
'5'):
441 int slice,
int thread_nb)
449 int start_slice, end_slice;
450 int base_blocks_per_slice = h_block / ctx->
slice_count;
456 start_slice = slice * base_blocks_per_slice;
458 start_slice +=
FFMIN(slice, remainder_blocks);
460 end_slice = start_slice + base_blocks_per_slice;
462 if (slice < remainder_blocks)
465 for (y = start_slice; y < end_slice; y++) {
467 int off = y * w_block;
468 for (x = 0; x < w_block; x++) {
505 src[0] = r * a / 255;
506 src[1] = g * a / 255;
507 src[2] = b * a / 255;
526 int d = (255 * 255 - x * x - y * y) / 2;
544 int cg = src[1] - 128;
545 int co = src[2] - 128;
548 src[0] = av_clip_uint8(y + co - cg);
549 src[1] = av_clip_uint8(y + cg);
550 src[2] = av_clip_uint8(y - co - cg);
630 if (bytestream2_get_le32(gbc) !=
MKTAG(
'D',
'D',
'S',
' ') ||
631 bytestream2_get_le32(gbc) != 124) {
638 avctx->
height = bytestream2_get_le32(gbc);
639 avctx->
width = bytestream2_get_le32(gbc);
653 mipmap = bytestream2_get_le32(gbc);
675 "Compressed Buffer is too small (%d < %d).\n",
689 for (i = 0; i < 16; i++) {
691 (frame->
data[1][2+i*4]<<0)+
692 (frame->
data[1][1+i*4]<<8)+
693 (frame->
data[1][0+i*4]<<16)+
694 (frame->
data[1][3+i*4]<<24)
705 for (y = 0; y < frame->
height; y++) {
706 for (x = 0; x < frame->
width; x += 2) {
709 dst[x + 1] = val >> 4;
720 for (i = 0; i < 256; i++)
722 (frame->
data[1][2+i*4]<<0)+
723 (frame->
data[1][1+i*4]<<8)+
724 (frame->
data[1][0+i*4]<<16)+
725 (frame->
data[1][3+i*4]<<24)
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
const char const char void * val
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...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
int(* tex_funct)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
ptrdiff_t const GLvoid * data
8 bits gray, 8 bits alpha
int coded_width
Bitstream width / height, may be different from width/height e.g.
#define AV_LOG_WARNING
Something somehow does not look correct.
Texture block (4x4) module.
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined ...
#define AV_PIX_FMT_BGRA64
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)
size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag)
Put a string representing the codec tag codec_tag in buf.
enum DDSPostProc postproc
static int parse_pixel_format(AVCodecContext *avctx)
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB)
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
8 bits with AV_PIX_FMT_RGB32 palette
Multithreading support functions.
int(* dxt5y_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
#define AV_LOG_VERBOSE
Detailed information.
int(* dxt1a_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int(* dxt4_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
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. ...
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
const char * name
Name of the codec implementation.
int(* dxt5_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
av_cold void ff_texturedsp_init(TextureDSPContext *c)
enum AVPictureType pict_type
Picture type of the frame.
int(* rgtc1s_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
int width
picture width / height.
packed RGB 8:8:8, 24bpp, BGRBGR...
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
int(* dxn3dc_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
static void do_swizzle(AVFrame *frame, int x, int y)
Replacements for frequently missing libm functions.
enum AVColorSpace colorspace
YUV colorspace type.
int palette_has_changed
Tell user application that palette has changed from previous frame.
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
int(* rgtc2u_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
int(* dxt3_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb...
common internal api header.
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.
int(* rgtc2s_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
Y , 16bpp, little-endian.
int key_frame
1 -> keyframe, 0-> not
static int decompress_texture_thread(AVCodecContext *avctx, void *arg, int slice, int thread_nb)
static int array[MAX_W *MAX_W]
#define FFSWAP(type, a, b)
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.
#define MKTAG(a, b, c, d)
static void run_postproc(AVCodecContext *avctx, AVFrame *frame)
This structure stores compressed data.
int(* dxt5ys_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
int(* dxt2_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
int(* rgtc1u_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
static int dds_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)