54 *section_size = bytestream2_get_le24(gbc);
55 *section_type = bytestream2_get_byte(gbc);
57 if (*section_size == 0) {
61 *section_size = bytestream2_get_le32(gbc);
75 int is_first_table = 1, had_offsets = 0, had_compressors = 0, had_sizes = 0;
86 switch (section_type) {
91 for (i = 0; i < section_size; i++) {
101 for (i = 0; i < section_size / 4; i++) {
111 for (i = 0; i < section_size / 4; i++) {
120 size -= section_size;
123 if (!had_sizes || !had_compressors)
129 size_t running_size = 0;
142 size_t running_offset = 0;
158 const char *compressorstr;
169 "Invalid texture format %#04x.\n", section_type & 0x0F);
173 switch (section_type & 0xF0) {
183 compressorstr =
"none";
185 compressorstr =
"snappy";
194 compressorstr =
"complex";
220 int64_t uncompressed_size;
224 if (uncompressed_size < 0) {
225 return uncompressed_size;
242 int chunk_nb,
int thread_nb)
254 int64_t uncompressed_size = ctx->
tex_size;
270 int slice,
int thread_nb)
278 int start_slice, end_slice;
279 int base_blocks_per_slice = h_block / ctx->
slice_count;
285 start_slice = slice * base_blocks_per_slice;
287 start_slice +=
FFMIN(slice, remainder_blocks);
289 end_slice = start_slice + base_blocks_per_slice;
291 if (slice < remainder_blocks)
294 for (y = start_slice; y < end_slice; y++) {
296 int off = y * w_block;
297 for (x = 0; x < w_block; x++) {
373 const char *texture_name;
389 case MKTAG(
'H',
'a',
'p',
'1'):
390 texture_name =
"DXT1";
395 case MKTAG(
'H',
'a',
'p',
'5'):
396 texture_name =
"DXT5";
401 case MKTAG(
'H',
'a',
'p',
'Y'):
402 texture_name =
"DXT5-YCoCg-scaled";
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
const struct AVCodec * codec
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
static int hap_can_use_tex_in_place(HapContext *ctx)
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(* tex_fun)(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 av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
int64_t ff_snappy_peek_uncompressed_length(GetByteContext *gb)
Get the uncompressed length of an input buffer compressed using the Snappy algorithm.
#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
static int hap_parse_decode_instructions(HapContext *ctx, int size)
Multithreading support functions.
int ff_hap_set_chunk_count(HapContext *ctx, int count, int first_in_frame)
static av_cold int hap_init(AVCodecContext *avctx)
void ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
static int hap_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#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)
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.
int ff_snappy_uncompress(GetByteContext *gb, uint8_t *buf, int64_t *size)
Decompress an input buffer using Snappy algorithm.
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
static av_cold int hap_close(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.
static int parse_section_header(GetByteContext *gbc, int *section_size, enum HapSectionType *section_type)
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.
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
av_cold void ff_hap_free_context(HapContext *ctx)
main external API structure.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
static int decompress_chunks_thread(AVCodecContext *avctx, void *arg, int chunk_nb, int thread_nb)
static int hap_parse_frame_header(AVCodecContext *avctx)
static int decompress_texture_thread(AVCodecContext *avctx, void *arg, int slice, int thread_nb)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
int av_reallocp(void *ptr, size_t size)
Allocate or reallocate a block of memory.
int(* update_thread_context)(AVCodecContext *dst, const AVCodecContext *src)
Copy necessary context variables from a previous thread context to the current one.
#define AVERROR_DECODER_NOT_FOUND
Decoder not found.
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
enum HapCompressor compressor
#define MKTAG(a, b, c, d)
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.