Go to the documentation of this file.
34 #define DXV_HEADER_LENGTH 12
41 #define LOOKBACK_HT_ELEMS 0x40000
42 #define LOOKBACK_WORDS 0x20202
57 uint32_t
key, uint32_t
pos)
75 uint32_t
key, uint32_t
pos)
88 if ((wrapped_index > removed_hash && (candidate_hash <= removed_hash || candidate_hash > wrapped_index)) ||
89 (wrapped_index < removed_hash && (candidate_hash <= removed_hash && candidate_hash > wrapped_index))) {
90 *removed_entry = *
entry;
92 removed_entry =
entry;
93 removed_hash = wrapped_index;
98 removed_entry =
entry;
99 removed_hash = wrapped_index;
134 if (bytestream2_get_bytes_left_p(pbc) < 4) { \
135 return AVERROR_INVALIDDATA; \
137 value = pbc->buffer; \
138 bytestream2_put_le32(pbc, 0); \
141 if (idx >= 0x102 * x) { \
143 bytestream2_put_le16(pbc, (idx / x) - 0x102); \
144 } else if (idx >= 2 * x) { \
146 bytestream2_put_byte(pbc, (idx / x) - 2); \
147 } else if (idx == x) { \
152 AV_WL32(value, AV_RL32(value) | (op << (state * 2))); \
161 uint32_t
color, lut, idx, color_idx, lut_idx, prev_pos,
state = 16,
pos = 2,
op = 0;
166 bytestream2_put_le32(pbc,
AV_RL32(
ctx->tex_data));
167 bytestream2_put_le32(pbc,
AV_RL32(
ctx->tex_data + 4));
172 while (
pos + 2 <=
ctx->tex_size / 4) {
177 color_idx = prev_pos != -1 ?
pos - prev_pos : 0;
180 uint32_t old_color =
AV_RL32(
ctx->tex_data + old_pos * 4);
186 if (color_idx && lut ==
AV_RL32(
ctx->tex_data + (
pos - color_idx) * 4)) {
191 lut_idx = prev_pos != -1 ?
pos - prev_pos : 0;
195 uint32_t old_lut =
AV_RL32(
ctx->tex_data + old_pos * 4);
206 bytestream2_put_le32(pbc,
color);
211 bytestream2_put_le32(pbc, lut);
232 if (
ctx->enc.tex_funct) {
233 ctx->enc.tex_data.out =
ctx->tex_data;
246 bytestream2_put_le32(pbc,
ctx->tex_fmt);
247 bytestream2_put_byte(pbc, 4);
248 bytestream2_put_byte(pbc, 0);
249 bytestream2_put_byte(pbc, 0);
250 bytestream2_put_byte(pbc, 0);
254 ret =
ctx->compress_tex(avctx);
287 switch (
ctx->tex_fmt) {
291 ctx->enc.tex_ratio = 8;
297 ctx->enc.raw_ratio = 16;
304 if (!
ctx->tex_data) {
326 #define OFFSET(x) offsetof(DXVEncContext, x)
327 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
330 {
"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)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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...
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.
int(* compress_tex)(AVCodecContext *avctx)
This structure stores compressed data.
int width
picture width / height.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
#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...
int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and allocate data.