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

KTX 1.0 muxer for ASTC textures. More...

#include "avformat.h"
#include "avio.h"
#include "mux.h"
#include "libavcodec/defs.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"

Go to the source code of this file.

Data Structures

struct  KTXMuxerContext
 

Macros

#define ASTC_HEADER_SIZE   16
 
#define OFFSET(x)
 
#define VE   AV_OPT_FLAG_ENCODING_PARAM
 

Functions

static int ktx_orientation_from_side_data (AVFormatContext *s, AVStream *st, int *hflip, int *vflip)
 
static int ktx_write_header (AVFormatContext *s)
 
static int ktx_write_packet (AVFormatContext *s, AVPacket *pkt)
 

Variables

static const uint8_t astc_magic [4] = { 0x13, 0xAB, 0xA1, 0x5C }
 
static const int astc_gl_linear [14]
 
static const int astc_gl_srgb [14]
 
static const int astc_bx [14] = { 4, 5, 5, 6, 6, 8, 8, 8, 10, 10, 10, 10, 12, 12 }
 
static const int astc_by [14] = { 4, 4, 5, 5, 6, 5, 6, 8, 5, 6, 8, 10, 10, 12 }
 
static const char ktx_orientation_key [] = "KTXorientation"
 
static const AVOption ktx_options []
 
static const AVClass ktx_muxer_class
 
const FFOutputFormat ff_ktx_muxer
 

Detailed Description

KTX 1.0 muxer for ASTC textures.

Writes the KTX 1.0 header (64 bytes) followed by a uint32 image size and the raw ASTC bitstream. The block size is recovered from the encoder's .astc-style extradata; the sRGB vs linear GL enum is chosen by the "srgb" muxer option.

Definition in file ktxenc.c.

Macro Definition Documentation

◆ ASTC_HEADER_SIZE

#define ASTC_HEADER_SIZE   16

Definition at line 39 of file ktxenc.c.

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 262 of file ktxenc.c.

◆ VE

#define VE   AV_OPT_FLAG_ENCODING_PARAM

Definition at line 263 of file ktxenc.c.

Function Documentation

◆ ktx_orientation_from_side_data()

static int ktx_orientation_from_side_data ( AVFormatContext * s,
AVStream * st,
int * hflip,
int * vflip )
static

Definition at line 70 of file ktxenc.c.

Referenced by ktx_write_header().

◆ ktx_write_header()

static int ktx_write_header ( AVFormatContext * s)
static

Definition at line 103 of file ktxenc.c.

◆ ktx_write_packet()

static int ktx_write_packet ( AVFormatContext * s,
AVPacket * pkt )
static

Definition at line 244 of file ktxenc.c.

Variable Documentation

◆ astc_magic

const uint8_t astc_magic[4] = { 0x13, 0xAB, 0xA1, 0x5C }
static

Definition at line 40 of file ktxenc.c.

◆ astc_gl_linear

const int astc_gl_linear[14]
static
Initial value:
= {
0x93B0, 0x93B1, 0x93B2, 0x93B3, 0x93B4, 0x93B5, 0x93B6, 0x93B7,
0x93B8, 0x93B9, 0x93BA, 0x93BB, 0x93BC, 0x93BD
}

Definition at line 44 of file ktxenc.c.

◆ astc_gl_srgb

const int astc_gl_srgb[14]
static
Initial value:
= {
0x93D0, 0x93D1, 0x93D2, 0x93D3, 0x93D4, 0x93D5, 0x93D6, 0x93D7,
0x93D8, 0x93D9, 0x93DA, 0x93DB, 0x93DC, 0x93DD
}

Definition at line 48 of file ktxenc.c.

Referenced by ktx_write_header().

◆ astc_bx

const int astc_bx[14] = { 4, 5, 5, 6, 6, 8, 8, 8, 10, 10, 10, 10, 12, 12 }
static

Definition at line 53 of file ktxenc.c.

◆ astc_by

const int astc_by[14] = { 4, 4, 5, 5, 6, 5, 6, 8, 5, 6, 8, 10, 10, 12 }
static

Definition at line 54 of file ktxenc.c.

◆ ktx_orientation_key

const char ktx_orientation_key[] = "KTXorientation"
static

Definition at line 62 of file ktxenc.c.

Referenced by ktx_write_header().

◆ ktx_options

const AVOption ktx_options[]
static
Initial value:
= {
{ "srgb", "GL internal format color space", OFFSET(srgb),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE, .unit = "srgb" },
{ "auto", "Follow the encoder profile", 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, 0, 0, VE, .unit = "srgb" },
{ "linear", "Write the linear ASTC format", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, VE, .unit = "srgb" },
{ "srgb", "Write the sRGB ASTC format", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, VE, .unit = "srgb" },
{ NULL },
}
#define VE
Definition amfenc_av1.c:30
#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

Definition at line 264 of file ktxenc.c.

◆ ktx_muxer_class

const AVClass ktx_muxer_class
static
Initial value:
= {
.class_name = "ktx_muxer",
.item_name = av_default_item_name,
.option = ktx_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
static const AVOption ktx_options[]
Definition ktxenc.c:264

Definition at line 273 of file ktxenc.c.

◆ ff_ktx_muxer

const FFOutputFormat ff_ktx_muxer
Initial value:
= {
.p.name = "ktx",
.p.long_name = NULL_IF_CONFIG_SMALL("KTX 1.0 (Khronos Texture) for ASTC"),
.p.mime_type = "image/ktx",
.p.extensions = "ktx",
.p.audio_codec = AV_CODEC_ID_NONE,
.p.video_codec = AV_CODEC_ID_ASTC,
.p.subtitle_codec = AV_CODEC_ID_NONE,
.flags_internal = FF_OFMT_FLAG_MAX_ONE_OF_EACH |
.priv_data_size = sizeof(KTXMuxerContext),
.p.priv_class = &ktx_muxer_class,
.write_header = ktx_write_header,
.write_packet = ktx_write_packet,
.p.flags = AVFMT_NOTIMESTAMPS,
}
#define AVFMT_NOTIMESTAMPS
Format does not need / have any timestamps.
Definition avformat.h:500
@ AV_CODEC_ID_NONE
Definition codec_id.h:48
@ AV_CODEC_ID_ASTC
Definition codec_id.h:327
static const AVClass ktx_muxer_class
Definition ktxenc.c:273
static int ktx_write_header(AVFormatContext *s)
Definition ktxenc.c:103
static int ktx_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition ktxenc.c:244
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:97
#define FF_OFMT_FLAG_MAX_ONE_OF_EACH
If this flag is set, it indicates that for each codec type whose corresponding default codec (i....
Definition mux.h:50
#define FF_OFMT_FLAG_ONLY_DEFAULT_CODECS
If this flag is set, then the only permitted audio/video/subtitle codec ids are AVOutputFormat....
Definition mux.h:59

Definition at line 280 of file ktxenc.c.