51 int is_first_table = 1, had_offsets = 0, had_compressors = 0, had_sizes = 0;
62 switch (section_type) {
67 for (i = 0; i < section_size; i++) {
77 for (i = 0; i < section_size / 4; i++) {
87 for (i = 0; i < section_size / 4; i++) {
99 if (!had_sizes || !had_compressors)
105 size_t running_size = 0;
120 size_t running_offset = 0;
136 const char *compressorstr;
150 "Invalid texture format %#04x.\n", section_type & 0x0F);
154 switch (section_type & 0xF0) {
164 compressorstr =
"none";
166 compressorstr =
"snappy";
175 compressorstr =
"complex";
201 int64_t uncompressed_size;
205 if (uncompressed_size < 0) {
206 return uncompressed_size;
223 int chunk_nb,
int thread_nb)
235 int64_t uncompressed_size = ctx->
tex_size;
251 int slice,
int thread_nb,
int texture_num)
259 int start_slice, end_slice;
260 int base_blocks_per_slice = h_block / ctx->
slice_count;
266 start_slice = slice * base_blocks_per_slice;
268 start_slice +=
FFMIN(slice, remainder_blocks);
270 end_slice = start_slice + base_blocks_per_slice;
272 if (slice < remainder_blocks)
275 for (y = start_slice; y < end_slice; y++) {
277 int off = y * w_block;
278 for (x = 0; x < w_block; x++) {
279 if (texture_num == 0) {
293 int slice,
int thread_nb)
299 int slice,
int thread_nb)
312 int start_texture_section = 0;
313 int tex_rat[2] = {0, 0};
324 if ((section_type & 0x0F) != 0x0D) {
325 av_log(avctx,
AV_LOG_ERROR,
"Invalid section type in 2 textures mode %#04x.\n", section_type);
328 start_texture_section = 4;
407 const char *texture_name;
426 case MKTAG(
'H',
'a',
'p',
'1'):
427 texture_name =
"DXT1";
432 case MKTAG(
'H',
'a',
'p',
'5'):
433 texture_name =
"DXT5";
438 case MKTAG(
'H',
'a',
'p',
'Y'):
439 texture_name =
"DXT5-YCoCg-scaled";
444 case MKTAG(
'H',
'a',
'p',
'A'):
445 texture_name =
"RGTC1";
451 case MKTAG(
'H',
'a',
'p',
'M'):
452 texture_name =
"DXT5-YCoCg-scaled / RGTC1";
494 .codec_tags = (
const uint32_t []){
495 MKTAG(
'H',
'a',
'p',
'1'),
496 MKTAG(
'H',
'a',
'p',
'5'),
497 MKTAG(
'H',
'a',
'p',
'Y'),
498 MKTAG(
'H',
'a',
'p',
'A'),
499 MKTAG(
'H',
'a',
'p',
'M'),
#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.
int(* dxt5_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
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.
Texture block (4x4) module.
int(* rgtc1u_alpha_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
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)
int ff_hap_parse_section_header(GetByteContext *gbc, int *section_size, enum HapSectionType *section_type)
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)
static int hap_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
int(* dxt5ys_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint32_t compressed_offset
#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.
const char * name
Name of the codec implementation.
static int decompress_texture_thread_internal(AVCodecContext *avctx, void *arg, int slice, int thread_nb, int texture_num)
#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...
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call have so the codec calls ff_thread_report set FF_CODEC_CAP_ALLOCATE_PROGRESS in AVCodec caps_internal and use ff_thread_get_buffer() to allocate frames.The frames must then be freed with ff_thread_release_buffer().Otherwise decode directly into the user-supplied frames.Call ff_thread_report_progress() after some part of the current picture has decoded.A good place to put this is where draw_horiz_band() is called-add this if it isn't called anywhere
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)
int(* update_thread_context)(struct AVCodecContext *dst, const struct AVCodecContext *src)
Copy necessary context variables from a previous thread context to the current one.
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call ff_thread_finish_setup() afterwards.If some code can't be moved
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
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(* 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(* tex_fun)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
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.
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').
int(* dxt1_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
static int decompress_texture2_thread(AVCodecContext *avctx, void *arg, int slice, int thread_nb)
static int decompress_chunks_thread(AVCodecContext *avctx, void *arg, int chunk_nb, int thread_nb)
static int hap_parse_frame_header(AVCodecContext *avctx)
int(* tex_fun2)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
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.
#define AVERROR_DECODER_NOT_FOUND
Decoder not found.
int key_frame
1 -> keyframe, 0-> not
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
#define FF_CODEC_TAGS_END
AVCodec.codec_tags termination value.
int(* rgtc1u_gray_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
enum HapCompressor compressor
#define MKTAG(a, b, c, d)
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.