50 int slice,
int thread_nb)
58 int start_slice, end_slice;
59 int base_blocks_per_slice = h_block / ctx->
slice_count;
65 start_slice = slice * base_blocks_per_slice;
68 start_slice +=
FFMIN(slice, remainder_blocks);
70 end_slice = start_slice + base_blocks_per_slice;
72 if (slice < remainder_blocks)
75 for (y = start_slice; y < end_slice; y++) {
77 int off = y * w_block;
78 for (x = 0; x < w_block; x++) {
93 #define CHECKPOINT(x) \
96 value = bytestream2_get_le32(gbc); \
107 idx = (bytestream2_get_byte(gbc) + 2) * x; \
109 av_log(avctx, AV_LOG_ERROR, "idx %d > %d\n", idx, pos); \
110 return AVERROR_INVALIDDATA; \
114 idx = (bytestream2_get_le16(gbc) + 0x102) * x; \
116 av_log(avctx, AV_LOG_ERROR, "idx %d > %d\n", idx, pos); \
117 return AVERROR_INVALIDDATA; \
128 int idx = 0,
state = 0;
136 while (pos + 2 <= ctx->
tex_size / 4) {
154 prev = bytestream2_get_le32(gbc);
163 prev = bytestream2_get_le32(gbc);
177 int idx, prev,
state = 0;
189 while (pos + 2 <= ctx->
tex_size / 4) {
203 value = bytestream2_get_le32(gbc);
213 check = bytestream2_get_byte(gbc) + 1;
216 probe = bytestream2_get_le16(gbc);
218 }
while (probe == 0xFFFF);
220 while (check && pos + 4 <= ctx->
tex_size / 4) {
245 run = bytestream2_get_byte(gbc);
248 probe = bytestream2_get_le16(gbc);
250 }
while (probe == 0xFFFF);
264 idx = 8 + bytestream2_get_le16(gbc);
265 if (idx > pos || (
unsigned int)(pos - idx) + 2 > ctx->
tex_size / 4)
277 prev = bytestream2_get_le32(gbc);
281 prev = bytestream2_get_le32(gbc);
294 if (idx > pos || (
unsigned int)(pos - idx) + 2 > ctx->
tex_size / 4)
306 if (op && (idx > pos || (
unsigned int)(pos - idx) + 2 > ctx->
tex_size / 4))
311 prev = bytestream2_get_le32(gbc);
320 prev = bytestream2_get_le32(gbc);
354 const char *msgcomp, *msgtext;
356 int version_major, version_minor = 0;
357 int size = 0, old_type = 0;
362 tag = bytestream2_get_le32(gbc);
364 case MKBETAG(
'D',
'X',
'T',
'1'):
372 case MKBETAG(
'D',
'X',
'T',
'5'):
380 case MKBETAG(
'Y',
'C',
'G',
'6'):
381 case MKBETAG(
'Y',
'G',
'1',
'0'):
386 size = tag & 0x00FFFFFF;
387 old_type = tag >> 24;
388 version_major = (old_type & 0x0F) - 1;
390 if (old_type & 0x80) {
398 if (old_type & 0x40) {
403 }
else if (old_type & 0x20 || version_major == 1) {
418 version_major = bytestream2_get_byte(gbc) - 1;
419 version_minor = bytestream2_get_byte(gbc);
422 if (bytestream2_get_byte(gbc)) {
429 size = bytestream2_get_le32(gbc);
432 "%s compression with %s texture (version %d.%d)\n",
433 msgcomp, msgtext, version_major, version_minor);
437 "Incomplete or invalid file (header %d, left %u).\n",
448 ret = decompress_tex(avctx);
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#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)
Texture block (4x4) module.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static int dxv_decompress_dxt1(AVCodecContext *avctx)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
static int dxv_decompress_dxt5(AVCodecContext *avctx)
Multithreading support functions.
static int probe(AVProbeData *p)
int ff_lzf_uncompress(GetByteContext *gb, uint8_t **buf, int64_t *size)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int decompress_texture_thread(AVCodecContext *avctx, void *arg, int slice, int thread_nb)
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)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
static int dxv_close(AVCodecContext *avctx)
const char * name
Name of the codec implementation.
int(* dxt5_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
static int dxv_decompress_lzf(AVCodecContext *avctx)
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 width
picture width / height.
GLsizei GLboolean const GLfloat * value
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
main external API structure.
static int dxv_init(AVCodecContext *avctx)
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.
int(* tex_funct)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
static int dxv_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
common internal api header.
#define MKBETAG(a, b, c, d)
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 key_frame
1 -> keyframe, 0-> not
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int dxv_decompress_raw(AVCodecContext *avctx)
#define check(x, y, S, v)