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

Hap encoder. More...

#include <stdint.h>
#include "snappy-c.h"
#include "libavutil/frame.h"
#include "libavutil/imgutils.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "bytestream.h"
#include "codec_internal.h"
#include "encode.h"
#include "hap.h"
#include "texturedsp.h"

Go to the source code of this file.

Macros

#define HAP_MAX_CHUNKS   64
 
#define OFFSET(x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

Enumerations

enum  HapHeaderLength { HAP_HDR_SHORT = 4 , HAP_HDR_LONG = 8 }
 

Functions

static int compress_texture (AVCodecContext *avctx, uint8_t *out, int out_length, const AVFrame *f)
 
static void hap_write_section_header (PutByteContext *pbc, enum HapHeaderLength header_length, int section_length, enum HapSectionType section_type)
 
static int hap_compress_frame (AVCodecContext *avctx, uint8_t *dst)
 
static int hap_decode_instructions_length (HapContext *ctx)
 
static int hap_header_length (HapContext *ctx)
 
static void hap_write_frame_header (HapContext *ctx, uint8_t *dst, int frame_length)
 
static int hap_encode (AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
 
static av_cold int hap_init (AVCodecContext *avctx)
 
static av_cold int hap_close (AVCodecContext *avctx)
 

Variables

static const AVOption options []
 
static const AVClass hapenc_class
 
const FFCodec ff_hap_encoder
 

Detailed Description

Hap encoder.

Fourcc: Hap1, Hap5, HapY

https://github.com/Vidvox/hap/blob/master/documentation/HapVideoDRAFT.md

Definition in file hapenc.c.

Macro Definition Documentation

◆ HAP_MAX_CHUNKS

#define HAP_MAX_CHUNKS   64

Definition at line 47 of file hapenc.c.

Referenced by hap_init().

◆ OFFSET

#define OFFSET ( x)
Value:
offsetof(HapContext, x)

Definition at line 331 of file hapenc.c.

◆ FLAGS

Definition at line 332 of file hapenc.c.

Enumeration Type Documentation

◆ HapHeaderLength

Enumerator
HAP_HDR_SHORT 
HAP_HDR_LONG 

Definition at line 49 of file hapenc.c.

Function Documentation

◆ compress_texture()

static int compress_texture ( AVCodecContext * avctx,
uint8_t * out,
int out_length,
const AVFrame * f )
static

Definition at line 56 of file hapenc.c.

Referenced by hap_encode().

◆ hap_write_section_header()

static void hap_write_section_header ( PutByteContext * pbc,
enum HapHeaderLength header_length,
int section_length,
enum HapSectionType section_type )
static

Definition at line 74 of file hapenc.c.

Referenced by hap_write_frame_header().

◆ hap_compress_frame()

static int hap_compress_frame ( AVCodecContext * avctx,
uint8_t * dst )
static

Definition at line 91 of file hapenc.c.

Referenced by hap_encode().

◆ hap_decode_instructions_length()

static int hap_decode_instructions_length ( HapContext * ctx)
static

Definition at line 139 of file hapenc.c.

Referenced by hap_header_length(), and hap_write_frame_header().

◆ hap_header_length()

static int hap_header_length ( HapContext * ctx)
static

Definition at line 148 of file hapenc.c.

Referenced by hap_encode().

◆ hap_write_frame_header()

static void hap_write_frame_header ( HapContext * ctx,
uint8_t * dst,
int frame_length )
static

Definition at line 161 of file hapenc.c.

Referenced by hap_encode().

◆ hap_encode()

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

Definition at line 193 of file hapenc.c.

◆ hap_init()

static av_cold int hap_init ( AVCodecContext * avctx)
static

Definition at line 234 of file hapenc.c.

◆ hap_close()

static av_cold int hap_close ( AVCodecContext * avctx)
static

Definition at line 322 of file hapenc.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "format", NULL, OFFSET(opt_tex_fmt), AV_OPT_TYPE_INT, { .i64 = HAP_FMT_RGBDXT1 }, HAP_FMT_RGBDXT1, HAP_FMT_YCOCGDXT5, FLAGS, .unit = "format" },
{ "hap", "Hap 1 (DXT1 textures)", 0, AV_OPT_TYPE_CONST, { .i64 = HAP_FMT_RGBDXT1 }, 0, 0, FLAGS, .unit = "format" },
{ "hap_alpha", "Hap Alpha (DXT5 textures)", 0, AV_OPT_TYPE_CONST, { .i64 = HAP_FMT_RGBADXT5 }, 0, 0, FLAGS, .unit = "format" },
{ "hap_q", "Hap Q (DXT5-YCoCg textures)", 0, AV_OPT_TYPE_CONST, { .i64 = HAP_FMT_YCOCGDXT5 }, 0, 0, FLAGS, .unit = "format" },
{ "chunks", "chunk count", OFFSET(opt_chunk_count), AV_OPT_TYPE_INT, {.i64 = 1 }, 1, HAP_MAX_CHUNKS, FLAGS, },
{ "compressor", "second-stage compressor", OFFSET(opt_compressor), AV_OPT_TYPE_INT, { .i64 = HAP_COMP_SNAPPY }, HAP_COMP_NONE, HAP_COMP_SNAPPY, FLAGS, .unit = "compressor" },
{ "none", "None", 0, AV_OPT_TYPE_CONST, { .i64 = HAP_COMP_NONE }, 0, 0, FLAGS, .unit = "compressor" },
{ "snappy", "Snappy", 0, AV_OPT_TYPE_CONST, { .i64 = HAP_COMP_SNAPPY }, 0, 0, FLAGS, .unit = "compressor" },
{ NULL },
}
#define FLAGS
Definition cmdutils.c:598
#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
@ HAP_FMT_RGBDXT1
Definition hap.h:33
@ HAP_FMT_YCOCGDXT5
Definition hap.h:35
@ HAP_FMT_RGBADXT5
Definition hap.h:34
@ HAP_COMP_NONE
Definition hap.h:40
@ HAP_COMP_SNAPPY
Definition hap.h:41
#define HAP_MAX_CHUNKS
Definition hapenc.c:47

Definition at line 333 of file hapenc.c.

◆ hapenc_class

const AVClass hapenc_class
static
Initial value:
= {
.class_name = "Hap encoder",
.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 345 of file hapenc.c.

◆ ff_hap_encoder

const FFCodec ff_hap_encoder
Initial value:
= {
.p.name = "hap",
CODEC_LONG_NAME("Vidvox Hap"),
.p.type = AVMEDIA_TYPE_VIDEO,
.p.id = AV_CODEC_ID_HAP,
.priv_data_size = sizeof(HapContext),
.p.priv_class = &hapenc_class,
.init = hap_init,
.close = hap_close,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}
#define CODEC_PIXFMTS(...)
#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...
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
Definition codec.h:147
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition codec.h:49
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition codec.h:102
@ AV_CODEC_ID_HAP
Definition codec_id.h:238
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
static av_cold int hap_init(AVCodecContext *avctx)
Definition hapdec.c:339
static av_cold int hap_close(AVCodecContext *avctx)
Definition hapdec.c:409
static int hap_encode(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition hapenc.c:193
static const AVClass hapenc_class
Definition hapenc.c:345
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition pixfmt.h:100

Definition at line 352 of file hapenc.c.