Go to the documentation of this file.
35 #define DXV_HEADER_LENGTH 12
42 #define LOOKBACK_HT_ELEMS 0x40000
43 #define LOOKBACK_WORDS 0x20202
58 uint32_t
key, uint32_t
pos)
76 uint32_t
key, uint32_t
pos)
89 if ((wrapped_index > removed_hash && (candidate_hash <= removed_hash || candidate_hash > wrapped_index)) ||
90 (wrapped_index < removed_hash && (candidate_hash <= removed_hash && candidate_hash > wrapped_index))) {
91 *removed_entry = *
entry;
93 removed_entry =
entry;
94 removed_hash = wrapped_index;
99 removed_entry =
entry;
100 removed_hash = wrapped_index;
135 if (bytestream2_get_bytes_left_p(pbc) < 4) { \
136 return AVERROR_INVALIDDATA; \
138 value = pbc->buffer; \
139 bytestream2_put_le32(pbc, 0); \
142 if (idx >= 0x102 * x) { \
144 bytestream2_put_le16(pbc, (idx / x) - 0x102); \
145 } else if (idx >= 2 * x) { \
147 bytestream2_put_byte(pbc, (idx / x) - 2); \
148 } else if (idx == x) { \
153 AV_WL32(value, AV_RL32(value) | (op << (state * 2))); \
162 uint32_t
color, lut, idx, color_idx, lut_idx, prev_pos,
state = 16,
pos = 2,
op = 0;
167 bytestream2_put_le32(pbc,
AV_RL32(
ctx->tex_data));
168 bytestream2_put_le32(pbc,
AV_RL32(
ctx->tex_data + 4));
173 while (
pos + 2 <=
ctx->tex_size / 4) {
178 color_idx = prev_pos != -1 ?
pos - prev_pos : 0;
181 uint32_t old_color =
AV_RL32(
ctx->tex_data + old_pos * 4);
187 if (color_idx && lut ==
AV_RL32(
ctx->tex_data + (
pos - color_idx) * 4)) {
192 lut_idx = prev_pos != -1 ?
pos - prev_pos : 0;
196 uint32_t old_lut =
AV_RL32(
ctx->tex_data + old_pos * 4);
207 bytestream2_put_le32(pbc,
color);
212 bytestream2_put_le32(pbc, lut);
233 if (
ctx->enc.tex_funct) {
234 ctx->enc.tex_data.out =
ctx->tex_data;
235 ctx->enc.frame_data.in =
frame->data[0];
236 ctx->enc.stride =
frame->linesize[0];
247 bytestream2_put_le32(pbc,
ctx->tex_fmt);
248 bytestream2_put_byte(pbc, 4);
249 bytestream2_put_byte(pbc, 0);
250 bytestream2_put_byte(pbc, 0);
251 bytestream2_put_byte(pbc, 0);
255 ret =
ctx->compress_tex(avctx);
288 switch (
ctx->tex_fmt) {
292 ctx->enc.tex_ratio = 8;
298 ctx->enc.raw_ratio = 16;
305 if (!
ctx->tex_data) {
327 #define OFFSET(x) offsetof(DXVEncContext, x)
328 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
331 {
"dxt1",
"DXT1 (Normal Quality, No Alpha)", 0,
AV_OPT_TYPE_CONST, { .i64 =
DXV_FMT_DXT1 }, 0, 0,
FLAGS, .unit =
"format" },
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
static const AVClass dxvenc_class
const FFCodec ff_dxv_encoder
This structure describes decoded (raw) audio or video data.
static av_always_inline int bytestream2_tell_p(PutByteContext *p)
HTEntry lut_lookback_ht[LOOKBACK_HT_ELEMS]
void ff_texturedspenc_init(TextureDSPEncContext *c)
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.
TextureDSPThreadContext enc
#define DXV_HEADER_LENGTH
#define FF_CODEC_ENCODE_CB(func)
static int dxv_encode(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
#define LOOKBACK_HT_ELEMS
static const AVOption options[]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
HTEntry color_lookback_ht[LOOKBACK_HT_ELEMS]
#define AV_CEIL_RSHIFT(a, b)
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
static int dxv_compress_dxt1(AVCodecContext *avctx)
#define CODEC_LONG_NAME(str)
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
static uint32_t ht_lookup_and_upsert(HTEntry *ht, const AVCRC *hash_ctx, uint32_t key, uint32_t pos)
static av_cold int dxv_close(AVCodecContext *avctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
static av_cold int dxv_init(AVCodecContext *avctx)
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
int ff_texturedsp_exec_compress_threads(struct AVCodecContext *avctx, TextureDSPThreadContext *ctx)
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
#define i(width, name, range_min, range_max)
static av_always_inline void bytestream2_skip_p(PutByteContext *p, unsigned int size)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
const char * name
Name of the codec implementation.
static void ht_init(HTEntry *ht)
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
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
static void ht_delete(HTEntry *ht, const AVCRC *hash_ctx, uint32_t key, uint32_t pos)
main external API structure.
int(* dxt1_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
@ AV_OPT_TYPE_INT
Underlying C type is int.
int(* compress_tex)(AVCodecContext *avctx)
This structure stores compressed data.
int width
picture width / height.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
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_OPT_TYPE_CONST
Special option type for declaring named constants.
int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and allocate data.