53 *section_size = bytestream2_get_le24(gbc);
54 *section_type = bytestream2_get_byte(gbc);
56 if (*section_size == 0) {
60 *section_size = bytestream2_get_le32(gbc);
74 int is_first_table = 1, had_offsets = 0, had_compressors = 0, had_sizes = 0;
85 switch (section_type) {
90 for (i = 0; i < section_size; i++) {
100 for (i = 0; i < section_size / 4; i++) {
110 for (i = 0; i < section_size / 4; i++) {
119 size -= section_size;
122 if (!had_sizes || !had_compressors)
128 size_t running_size = 0;
141 size_t running_offset = 0;
157 const char *compressorstr;
168 "Invalid texture format %#04x.\n", section_type & 0x0F);
172 switch (section_type & 0xF0) {
182 compressorstr =
"none";
184 compressorstr =
"snappy";
193 compressorstr =
"complex";
219 int64_t uncompressed_size;
223 if (uncompressed_size < 0) {
224 return uncompressed_size;
241 int chunk_nb,
int thread_nb)
253 int64_t uncompressed_size = ctx->
tex_size;
269 int slice,
int thread_nb)
277 int start_slice, end_slice;
278 int base_blocks_per_slice = h_block / ctx->
slice_count;
284 start_slice = slice * base_blocks_per_slice;
286 start_slice +=
FFMIN(slice, remainder_blocks);
288 end_slice = start_slice + base_blocks_per_slice;
290 if (slice < remainder_blocks)
293 for (y = start_slice; y < end_slice; y++) {
295 int off = y * w_block;
296 for (x = 0; x < w_block; x++) {
372 const char *texture_name;
388 case MKTAG(
'H',
'a',
'p',
'1'):
389 texture_name =
"DXT1";
394 case MKTAG(
'H',
'a',
'p',
'5'):
395 texture_name =
"DXT5";
400 case MKTAG(
'H',
'a',
'p',
'Y'):
401 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.
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.
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(* 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.