FFmpeg
Data Structures | Macros | Functions | Variables
dxvenc.c File Reference
#include <stdint.h>
#include "libavutil/crc.h"
#include "libavutil/imgutils.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "bytestream.h"
#include "codec_internal.h"
#include "dxv.h"
#include "encode.h"
#include "texturedsp.h"

Go to the source code of this file.

Data Structures

struct  HTEntry
 
struct  DXVEncContext
 

Macros

#define DXV_HEADER_LENGTH   12
 
#define LOOKBACK_HT_ELEMS   0x40000
 
#define LOOKBACK_WORDS   0x20202
 
#define PUSH_OP(x)
 
#define OFFSET(x)   offsetof(DXVEncContext, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

Functions

static void ht_init (HTEntry *ht)
 
static uint32_t ht_lookup_and_upsert (HTEntry *ht, const AVCRC *hash_ctx, uint32_t key, uint32_t pos)
 
static void ht_delete (HTEntry *ht, const AVCRC *hash_ctx, uint32_t key, uint32_t pos)
 
static int dxv_compress_dxt1 (AVCodecContext *avctx)
 
static int dxv_encode (AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
 
static av_cold int dxv_init (AVCodecContext *avctx)
 
static av_cold int dxv_close (AVCodecContext *avctx)
 

Variables

static const AVOption options []
 
static const AVClass dxvenc_class
 
const FFCodec ff_dxv_encoder
 

Macro Definition Documentation

◆ DXV_HEADER_LENGTH

#define DXV_HEADER_LENGTH   12

Definition at line 35 of file dxvenc.c.

◆ LOOKBACK_HT_ELEMS

#define LOOKBACK_HT_ELEMS   0x40000

Definition at line 42 of file dxvenc.c.

◆ LOOKBACK_WORDS

#define LOOKBACK_WORDS   0x20202

Definition at line 43 of file dxvenc.c.

◆ PUSH_OP

#define PUSH_OP (   x)
Value:
do { \
if (state == 16) { \
if (bytestream2_get_bytes_left_p(pbc) < 4) { \
} \
value = pbc->buffer; \
bytestream2_put_le32(pbc, 0); \
state = 0; \
} \
if (idx >= 0x102 * x) { \
op = 3; \
bytestream2_put_le16(pbc, (idx / x) - 0x102); \
} else if (idx >= 2 * x) { \
op = 2; \
bytestream2_put_byte(pbc, (idx / x) - 2); \
} else if (idx == x) { \
op = 1; \
} else { \
op = 0; \
} \
AV_WL32(value, AV_RL32(value) | (op << (state * 2))); \
state++; \
} while (0)

Definition at line 132 of file dxvenc.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(DXVEncContext, x)

Definition at line 327 of file dxvenc.c.

◆ FLAGS

Definition at line 328 of file dxvenc.c.

Function Documentation

◆ ht_init()

static void ht_init ( HTEntry ht)
static

Definition at line 50 of file dxvenc.c.

Referenced by dxv_compress_dxt1().

◆ ht_lookup_and_upsert()

static uint32_t ht_lookup_and_upsert ( HTEntry ht,
const AVCRC hash_ctx,
uint32_t  key,
uint32_t  pos 
)
static

Definition at line 57 of file dxvenc.c.

Referenced by dxv_compress_dxt1().

◆ ht_delete()

static void ht_delete ( HTEntry ht,
const AVCRC hash_ctx,
uint32_t  key,
uint32_t  pos 
)
static

Definition at line 75 of file dxvenc.c.

Referenced by dxv_compress_dxt1().

◆ dxv_compress_dxt1()

static int dxv_compress_dxt1 ( AVCodecContext avctx)
static

Definition at line 157 of file dxvenc.c.

Referenced by dxv_init().

◆ dxv_encode()

static int dxv_encode ( AVCodecContext avctx,
AVPacket pkt,
const AVFrame frame,
int *  got_packet 
)
static

Definition at line 219 of file dxvenc.c.

◆ dxv_init()

static av_cold int dxv_init ( AVCodecContext avctx)
static

Definition at line 266 of file dxvenc.c.

◆ dxv_close()

static av_cold int dxv_close ( AVCodecContext avctx)
static

Definition at line 318 of file dxvenc.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "format", NULL, OFFSET(tex_fmt), AV_OPT_TYPE_INT, { .i64 = DXV_FMT_DXT1 }, DXV_FMT_DXT1, DXV_FMT_DXT1, FLAGS, .unit = "format" },
{ "dxt1", "DXT1 (Normal Quality, No Alpha)", 0, AV_OPT_TYPE_CONST, { .i64 = DXV_FMT_DXT1 }, 0, 0, FLAGS, .unit = "format" },
{ NULL },
}

Definition at line 329 of file dxvenc.c.

◆ dxvenc_class

const AVClass dxvenc_class
static
Initial value:
= {
.class_name = "DXV encoder",
.option = options,
}

Definition at line 335 of file dxvenc.c.

◆ ff_dxv_encoder

const FFCodec ff_dxv_encoder
Initial value:
= {
.p.name = "dxv",
CODEC_LONG_NAME("Resolume DXV"),
.p.type = AVMEDIA_TYPE_VIDEO,
.p.id = AV_CODEC_ID_DXV,
.init = dxv_init,
.close = dxv_close,
.priv_data_size = sizeof(DXVEncContext),
.p.capabilities = AV_CODEC_CAP_DR1 |
.p.priv_class = &dxvenc_class,
.p.pix_fmts = (const enum AVPixelFormat[]) {
},
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}

Definition at line 341 of file dxvenc.c.

AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
DXV_FMT_DXT1
@ DXV_FMT_DXT1
Definition: dxv.h:28
DXVEncContext
Definition: dxvenc.c:108
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:43
dxvenc_class
static const AVClass dxvenc_class
Definition: dxvenc.c:335
OFFSET
#define OFFSET(x)
Definition: dxvenc.c:327
FF_CODEC_ENCODE_CB
#define FF_CODEC_ENCODE_CB(func)
Definition: codec_internal.h:320
dxv_encode
static int dxv_encode(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: dxvenc.c:219
options
static const AVOption options[]
Definition: dxvenc.c:329
bytestream2_get_bytes_left_p
static av_always_inline int bytestream2_get_bytes_left_p(PutByteContext *p)
Definition: bytestream.h:163
op
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.
Definition: anm.c:76
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:296
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:100
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:110
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
dxv_close
static av_cold int dxv_close(AVCodecContext *avctx)
Definition: dxvenc.c:318
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
dxv_init
static av_cold int dxv_init(AVCodecContext *avctx)
Definition: dxvenc.c:266
AV_CODEC_ID_DXV
@ AV_CODEC_ID_DXV
Definition: codec_id.h:245
AV_CODEC_CAP_SLICE_THREADS
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: codec.h:114
value
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
Definition: writing_filters.txt:86
state
static struct @465 state
FLAGS
#define FLAGS
Definition: dxvenc.c:328
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299