Go to the documentation of this file.
47 #define HAP_MAX_CHUNKS 64
60 if (
ctx->tex_size > out_length)
63 ctx->enc.tex_data.out =
out;
64 ctx->enc.frame_data.in =
f->data[0];
65 ctx->enc.stride =
f->linesize[0];
81 bytestream2_put_le24(pbc, header_length ==
HAP_HDR_LONG ? 0 : section_length);
82 bytestream2_put_byte(pbc, section_type);
85 bytestream2_put_le32(pbc, section_length);
92 int i, final_size = 0;
94 for (
i = 0;
i <
ctx->chunk_count;
i++) {
96 uint8_t *chunk_src, *chunk_dst;
103 +
ctx->chunks[
i-1].compressed_size;
114 if (
ret != SNAPPY_OK) {
143 return (5 *
ctx->chunk_count) + 8;
151 if (
ctx->chunk_count > 1) {
165 if (
ctx->chunk_count == 1) {
168 ctx->chunks[0].compressor |
ctx->opt_tex_fmt);
178 for (
i = 0;
i <
ctx->chunk_count;
i++) {
179 bytestream2_put_byte(&pbc,
ctx->chunks[
i].compressor >> 4);
185 for (
i = 0;
i <
ctx->chunk_count;
i++) {
186 bytestream2_put_le32(&pbc,
ctx->chunks[
i].compressed_size);
196 int final_data_size,
ret;
197 int pktsize =
FFMAX(
ctx->tex_size,
ctx->max_snappy *
ctx->chunk_count) + header_length;
211 final_data_size =
ctx->tex_size;
220 if (final_data_size < 0)
221 return final_data_size;
235 int corrected_chunk_count;
252 switch (
ctx->opt_tex_fmt) {
254 ctx->enc.tex_ratio = 8;
257 ctx->enc.tex_funct =
ctx->dxtc.dxt1_block;
260 ctx->enc.tex_ratio = 16;
263 ctx->enc.tex_funct =
ctx->dxtc.dxt5_block;
266 ctx->enc.tex_ratio = 16;
269 ctx->enc.tex_funct =
ctx->dxtc.dxt5ys_block;
275 ctx->enc.raw_ratio = 16;
283 switch (
ctx->opt_compressor) {
286 corrected_chunk_count = 1;
288 ctx->max_snappy =
ctx->tex_size;
294 while ((
ctx->tex_size /
ctx->enc.tex_ratio) % corrected_chunk_count != 0) {
295 corrected_chunk_count--;
298 ctx->max_snappy = snappy_max_compressed_length(
ctx->tex_size / corrected_chunk_count);
308 if (corrected_chunk_count !=
ctx->opt_chunk_count) {
310 ctx->opt_chunk_count, corrected_chunk_count);
328 #define OFFSET(x) offsetof(HapContext, x)
329 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
AVPixelFormat
Pixel format.
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
This structure describes decoded (raw) audio or video data.
#define AV_LOG_VERBOSE
Detailed information.
static int hap_compress_frame(AVCodecContext *avctx, uint8_t *dst)
static const AVClass hapenc_class
int ff_texturedsp_compress_thread(AVCodecContext *avctx, void *arg, int slice, int thread_nb)
static av_cold int hap_init(AVCodecContext *avctx)
AVCodec p
The public AVCodec.
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
#define AVERROR_BUFFER_TOO_SMALL
Buffer too small.
static av_cold int hap_close(AVCodecContext *avctx)
#define FF_CODEC_ENCODE_CB(func)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void hap_write_section_header(PutByteContext *pbc, enum HapHeaderLength header_length, int section_length, enum HapSectionType section_type)
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
av_cold void ff_hap_free_context(HapContext *ctx)
const FFCodec ff_hap_encoder
void ff_texturedspenc_init(TextureDSPContext *c)
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
const char * av_default_item_name(void *ptr)
Return the context name.
@ HAP_ST_DECODE_INSTRUCTIONS
static const AVOption options[]
int ff_hap_set_chunk_count(HapContext *ctx, int count, int first_in_frame)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
enum HapCompressor compressor
static void hap_write_frame_header(HapContext *ctx, uint8_t *dst, int frame_length)
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
#define AV_LOG_INFO
Standard information.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
@ HAP_ST_COMPRESSOR_TABLE
#define i(width, name, range_min, range_max)
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
const char * name
Name of the codec implementation.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
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
static int hap_encode(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
main external API structure.
static int hap_decode_instructions_length(HapContext *ctx)
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
This structure stores compressed data.
uint32_t compressed_offset
static int hap_header_length(HapContext *ctx)
int width
picture width / height.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define MKTAG(a, b, c, d)
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...
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 ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and allocate data.
static int compress_texture(AVCodecContext *avctx, uint8_t *out, int out_length, const AVFrame *f)