3 * Copyright (C) 2015 Vittorio Giovara <vittorio.giovara@gmail.com>
4 * Copyright (C) 2015 Tom Butterworth <bangnoise@gmail.com>
6 * This file is part of Libav.
8 * Libav is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * Libav is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with Libav; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
28 #include "libavutil/opt.h"
30 #include "bytestream.h"
31 #include "texturedsp.h"
33 enum HapTextureFormat
{
34 HAP_FMT_RGBDXT1
= 0x0B,
35 HAP_FMT_RGBADXT5
= 0x0E,
36 HAP_FMT_YCOCGDXT5
= 0x0F,
41 HAP_COMP_SNAPPY
= 0xB0,
42 HAP_COMP_COMPLEX
= 0xC0,
46 HAP_ST_DECODE_INSTRUCTIONS
= 0x01,
47 HAP_ST_COMPRESSOR_TABLE
= 0x02,
48 HAP_ST_SIZE_TABLE
= 0x03,
49 HAP_ST_OFFSET_TABLE
= 0x04,
52 typedef struct HapChunk
{
53 enum HapCompressor compressor
;
54 int compressed_offset
;
55 size_t compressed_size
;
56 int uncompressed_offset
;
57 size_t uncompressed_size
;
60 typedef struct HapContext
{
63 TextureDSPContext dxtc
;
66 enum HapTextureFormat opt_tex_fmt
; /* Texture type (encoder only) */
67 int opt_chunk_count
; /* User-requested chunk count (encoder only) */
71 int *chunk_results
; /* Results from threaded operations */
73 int tex_rat
; /* Compression ratio */
74 const uint8_t *tex_data
; /* Compressed texture */
75 uint8_t *tex_buf
; /* Buffer for compressed texture */
76 size_t tex_size
; /* Size of the compressed texture */
78 size_t max_snappy
; /* Maximum compressed size for snappy buffer */
80 int slice_count
; /* Number of slices for threaded operations */
82 /* Pointer to the selected compress or decompress function */
83 int (*tex_fun
)(uint8_t *dst
, ptrdiff_t stride
, const uint8_t *block
);
87 * Set the number of chunks in the frame. Returns 0 on success or an error if:
88 * - first_in_frame is 0 and the number of chunks has changed
89 * - any other error occurs
91 int ff_hap_set_chunk_count(HapContext
*ctx
, int count
, int first_in_frame
);
94 * Free resources associated with the context
96 av_cold
void ff_hap_free_context(HapContext
*ctx
);
98 #endif /* AVCODEC_HAP_H */