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

KTX 1.0 demuxer for ASTC textures. More...

#include "config_components.h"
#include <inttypes.h>
#include <limits.h>
#include "libavcodec/defs.h"
#include "avformat.h"
#include "avio.h"
#include "avio_internal.h"
#include "demux.h"
#include "internal.h"
#include "libavutil/display.h"
#include "libavutil/intreadwrite.h"

Go to the source code of this file.

Data Structures

struct  KTXDemuxerContext
 

Macros

#define ASTC_HEADER_SIZE   16
 

Functions

static int gl_enum_to_block (uint32_t e, int *bx, int *by)
 
static int ktx_probe (const AVProbeData *p)
 
static void ktx_orientation_flips (const char *value, int *hflip, int *vflip)
 
static int ktx_read_orientation (AVFormatContext *s, uint32_t kvdata, int *hflip, int *vflip)
 
static int ktx_read_header (AVFormatContext *s)
 
static int ktx_read_packet (AVFormatContext *s, AVPacket *pkt)
 

Variables

static const uint8_t astc_magic [4] = { 0x13, 0xAB, 0xA1, 0x5C }
 
static const uint8_t ktx_magic [12]
 
static const int astc_gl_linear [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 }
 
const FFInputFormat ff_ktx_demuxer
 

Detailed Description

KTX 1.0 demuxer for ASTC textures.

Parses the KTX 1.0 header, recovers the ASTC block size from the GL internal format enum, and synthesizes a 16-byte .astc-style extradata for the decoder. The raw ASTC bitstream is emitted as a single packet.

Definition in file ktxdec.c.

Macro Definition Documentation

◆ ASTC_HEADER_SIZE

#define ASTC_HEADER_SIZE   16

Definition at line 45 of file ktxdec.c.

Function Documentation

◆ gl_enum_to_block()

static int gl_enum_to_block ( uint32_t e,
int * bx,
int * by )
static

Definition at line 65 of file ktxdec.c.

Referenced by ktx_probe(), and ktx_read_header().

◆ ktx_probe()

static int ktx_probe ( const AVProbeData * p)
static

Definition at line 78 of file ktxdec.c.

◆ ktx_orientation_flips()

static void ktx_orientation_flips ( const char * value,
int * hflip,
int * vflip )
static

Definition at line 99 of file ktxdec.c.

Referenced by ktx_read_orientation().

◆ ktx_read_orientation()

static int ktx_read_orientation ( AVFormatContext * s,
uint32_t kvdata,
int * hflip,
int * vflip )
static

Definition at line 116 of file ktxdec.c.

Referenced by ktx_read_header().

◆ ktx_read_header()

static int ktx_read_header ( AVFormatContext * s)
static

Definition at line 171 of file ktxdec.c.

◆ ktx_read_packet()

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

Definition at line 301 of file ktxdec.c.

Variable Documentation

◆ astc_magic

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

Definition at line 46 of file ktxdec.c.

◆ ktx_magic

const uint8_t ktx_magic[12]
static
Initial value:
= {
0xAB, 'K', 'T', 'X', ' ', '1', '1', 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
}

Definition at line 47 of file ktxdec.c.

Referenced by ktx_probe(), and ktx_read_header().

◆ 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 52 of file ktxdec.c.

Referenced by gl_enum_to_block(), and 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 56 of file ktxdec.c.

Referenced by gl_enum_to_block(), and ktx_write_header().

◆ 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 57 of file ktxdec.c.

Referenced by gl_enum_to_block(), and ktx_write_header().

◆ ff_ktx_demuxer

const FFInputFormat ff_ktx_demuxer
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.flags = AVFMT_NOTIMESTAMPS,
.priv_data_size = sizeof(KTXDemuxerContext),
}
#define AVFMT_NOTIMESTAMPS
Format does not need / have any timestamps.
Definition avformat.h:500
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
static int read_probe(const AVProbeData *p)
Definition cdg.c:30
static int read_header(FFV1Context *f, RangeCoder *c)
Definition ffv1dec.c:578
static int ktx_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition ktxdec.c:301
static int ktx_read_header(AVFormatContext *s)
Definition ktxdec.c:171
static int ktx_probe(const AVProbeData *p)
Definition ktxdec.c:78
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:97

Definition at line 338 of file ktxdec.c.