Go to the documentation of this file.
35 #define DXV_HEADER_LENGTH 12
40 #define DXV_ALIGN(x) FFALIGN(x, 16)
47 #define LOOKBACK_HT_ELEMS 0x20202
48 #define LOOKBACK_WORDS 0x20202
76 if (bytestream2_get_bytes_left_p(pbc) < 4) { \
77 return AVERROR_INVALIDDATA; \
79 value = pbc->buffer; \
80 bytestream2_put_le32(pbc, 0); \
83 if (idx >= 0x102 * x) { \
85 bytestream2_put_le16(pbc, (idx / x) - 0x102); \
86 } else if (idx >= 2 * x) { \
88 bytestream2_put_byte(pbc, (idx / x) - 2); \
89 } else if (idx == x) { \
94 AV_WL32(value, AV_RL32(value) | (op << (state * 2))); \
103 uint32_t idx, combo_idx, prev_pos, old_pos,
state = 16,
pos = 0,
op = 0;
111 bytestream2_put_le32(pbc,
AV_RL32(
ctx->tex_data));
114 bytestream2_put_le32(pbc,
AV_RL32(
ctx->tex_data + 4));
118 while (
pos + 2 <=
ctx->tex_size / 4) {
175 if (
ctx->enc.tex_funct) {
176 uint8_t *safe_data[4] = {
frame->data[0], 0, 0, 0};
177 int safe_linesize[4] = {
frame->linesize[0], 0, 0, 0};
200 for (
int y = 0; y < avctx->
height; y++) {
201 memset(safe_data[0] + y * safe_linesize[0] +
frame->linesize[0], 0, safe_linesize[0] -
frame->linesize[0]);
206 memset(safe_data[0] + y * safe_linesize[0], 0, safe_linesize[0]);
211 ctx->enc.tex_data.out =
ctx->tex_data;
212 ctx->enc.frame_data.in = safe_data[0];
213 ctx->enc.stride = safe_linesize[0];
218 if (safe_data[0] !=
frame->data[0])
227 bytestream2_put_le32(pbc,
ctx->tex_fmt);
228 bytestream2_put_byte(pbc, 4);
229 bytestream2_put_byte(pbc, 0);
230 bytestream2_put_byte(pbc, 0);
231 bytestream2_put_byte(pbc, 0);
235 ret =
ctx->compress_tex(avctx);
260 switch (
ctx->tex_fmt) {
264 ctx->enc.tex_ratio = 8;
270 ctx->enc.raw_ratio = 16;
277 if (!
ctx->tex_data) {
307 #define OFFSET(x) offsetof(DXVEncContext, x)
308 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
311 {
"dxt1",
"DXT1 (Normal Quality, No Alpha)", 0,
AV_OPT_TYPE_CONST, { .i64 =
DXV_FMT_DXT1 }, 0, 0,
FLAGS, .unit =
"format" },
FFHashtableContext * lut_ht
#define CODEC_PIXFMTS(...)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
int ff_hashtable_delete(struct FFHashtableContext *ctx, const void *key)
Delete a value from a hash table given a key.
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)
av_cold void ff_hashtable_freep(FFHashtableContext **ctx)
Free a hash table.
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)
#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 av_cold int dxv_close(AVCodecContext *avctx)
int av_image_alloc(uint8_t *pointers[4], int linesizes[4], int w, int h, enum AVPixelFormat pix_fmt, int align)
Allocate an image with size w and h and pixel format pix_fmt, and fill pointers and linesizes accordi...
#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)
int ff_texturedsp_exec_compress_threads(struct AVCodecContext *avctx, TextureDSPThreadContext *ctx)
void ff_hashtable_clear(struct FFHashtableContext *ctx)
Delete all values from a hash table.
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
int ff_hashtable_set(struct FFHashtableContext *ctx, const void *key, const void *val)
Store a value in a hash table given a key.
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.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
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
main external API structure.
int(* dxt1_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
static void av_image_copy2(uint8_t *const dst_data[4], const int dst_linesizes[4], uint8_t *const src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Wrapper around av_image_copy() to workaround the limitation that the conversion from uint8_t * const ...
@ AV_OPT_TYPE_INT
Underlying C type is int.
FFHashtableContext * combo_ht
int(* compress_tex)(AVCodecContext *avctx)
This structure stores compressed data.
FFHashtableContext * color_ht
int width
picture width / height.
int ff_hashtable_get(const struct FFHashtableContext *ctx, const void *key, void *val)
Look up a value from a hash table given a key.
#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.
av_cold int ff_hashtable_alloc(FFHashtableContext **ctx, size_t key_size, size_t val_size, size_t max_entries)
Create a fixed-sized Robin Hood hash table.