FFmpeg
Loading...
Searching...
No Matches
libastcenc.c File Reference

ASTC encoder using ARM's astc-encoder library (astcenc C API). More...

#include <astcenc/astcenc.h>
#include <limits.h>
#include "avcodec.h"
#include "codec_internal.h"
#include "encode.h"
#include "profiles.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/pixdesc.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"

Go to the source code of this file.

Data Structures

struct  LibAstcEncContext
 

Macros

#define ASTC_MAGIC   0x5CA1AB13
 
#define ASTC_HEADER_SIZE   16
 
#define ASTC_BLOCK_BYTES   16
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 
#define OFFSET(x)
 

Functions

static av_cold int libastcenc_init (AVCodecContext *avctx)
 
static int libastcenc_encode (AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
 
static av_cold int libastcenc_close (AVCodecContext *avctx)
 

Variables

static const AVOption options []
 
static const AVClass libastcenc_class
 
const FFCodec ff_libastcenc_encoder
 

Detailed Description

ASTC encoder using ARM's astc-encoder library (astcenc C API).

Output is the raw ASTC bitstream (16 bytes per block). The container (.astc / .ktx) is added by the corresponding FFmpeg muxer.

Definition in file libastcenc.c.

Macro Definition Documentation

◆ ASTC_MAGIC

#define ASTC_MAGIC   0x5CA1AB13

Definition at line 45 of file libastcenc.c.

◆ ASTC_HEADER_SIZE

#define ASTC_HEADER_SIZE   16

Definition at line 46 of file libastcenc.c.

◆ ASTC_BLOCK_BYTES

#define ASTC_BLOCK_BYTES   16

Definition at line 47 of file libastcenc.c.

◆ VE

Definition at line 366 of file libastcenc.c.

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 367 of file libastcenc.c.

Function Documentation

◆ libastcenc_init()

static av_cold int libastcenc_init ( AVCodecContext * avctx)
static

Definition at line 67 of file libastcenc.c.

◆ libastcenc_encode()

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

Definition at line 230 of file libastcenc.c.

◆ libastcenc_close()

static av_cold int libastcenc_close ( AVCodecContext * avctx)
static

Definition at line 356 of file libastcenc.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "block_size", "ASTC block size WxH[xD] (e.g. 4x4, 8x8, 6x6x6)", OFFSET(block_size_str),
AV_OPT_TYPE_STRING, { .str = "8x8" }, 0, 0, VE },
{ "quality", "Compression quality 0..100 (0=fastest, 100=exhaustive)",
OFFSET(quality), AV_OPT_TYPE_FLOAT, { .dbl = 60.0 }, 0.0, 100.0, VE },
{ "profile", "Color profile (overrides AVCodecContext.profile)",
OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 3, VE, .unit = "profile" },
{ "ldr", "Linear LDR", 0, AV_OPT_TYPE_CONST, { .i64 = ASTCENC_PRF_LDR }, 0, 0, VE, .unit = "profile" },
{ "ldr-srgb", "sRGB LDR", 0, AV_OPT_TYPE_CONST, { .i64 = ASTCENC_PRF_LDR_SRGB }, 0, 0, VE, .unit = "profile" },
{ "hdr-ldr-a", "HDR RGB, LDR alpha", 0, AV_OPT_TYPE_CONST, { .i64 = ASTCENC_PRF_HDR_RGB_LDR_A }, 0, 0, VE, .unit = "profile" },
{ "hdr", "HDR", 0, AV_OPT_TYPE_CONST, { .i64 = ASTCENC_PRF_HDR }, 0, 0, VE, .unit = "profile" },
{ "perceptual", "Use perceptual (PSNR-weighted) error metric", OFFSET(perceptual),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
{ "alpha_weight", "Enable alpha weighting", OFFSET(alpha_weight),
AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, VE },
{ NULL },
}
#define VE
Definition amfenc_av1.c:30
static IPT perceptual(const CmsCtx *ctx, IPT ipt)
Definition cms.c:520
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition opt.h:270
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275
int profile
Definition mxfenc.c:2299
static const uint8_t quality[]
Definition vmixdec.c:58

Definition at line 369 of file libastcenc.c.

◆ libastcenc_class

const AVClass libastcenc_class
static
Initial value:
= {
.class_name = "libastcenc",
.item_name = av_default_item_name,
.option = options,
}
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85

Definition at line 387 of file libastcenc.c.

◆ ff_libastcenc_encoder

const FFCodec ff_libastcenc_encoder
Initial value:
= {
.p.name = "libastcenc",
CODEC_LONG_NAME("ASTC (Adaptive Scalable Texture Compression) image using astc-encoder"),
.p.type = AVMEDIA_TYPE_VIDEO,
.p.capabilities = AV_CODEC_CAP_DR1,
.p.priv_class = &libastcenc_class,
.p.wrapper_name = "libastcenc",
.priv_data_size = sizeof(LibAstcEncContext),
.close = libastcenc_close,
}
#define CODEC_PIXFMTS(...)
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
#define FF_CODEC_ENCODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition codec.h:49
@ AV_CODEC_ID_ASTC
Definition codec_id.h:327
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
static av_cold int libastcenc_init(AVCodecContext *avctx)
Definition libastcenc.c:67
static av_cold int libastcenc_close(AVCodecContext *avctx)
Definition libastcenc.c:356
static const AVClass libastcenc_class
Definition libastcenc.c:387
static int libastcenc_encode(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition libastcenc.c:230
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:97
#define AV_PIX_FMT_RGBAF32
Definition pixfmt.h:633
#define AV_PIX_FMT_RGBAF16
Definition pixfmt.h:630
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition pixfmt.h:75
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition pixfmt.h:100
#define AV_PIX_FMT_GBRAPF32
Definition pixfmt.h:585
const AVProfile ff_astc_profiles[]
Definition profiles.c:223

Definition at line 394 of file libastcenc.c.