Libav
Macros | Functions | Variables
huffyuvenc.c File Reference

huffyuv encoder More...

#include "libavutil/opt.h"
#include "avcodec.h"
#include "huffyuv.h"
#include "huffman.h"
#include "huffyuvencdsp.h"
#include "internal.h"
#include "put_bits.h"

Go to the source code of this file.

Macros

#define LOAD4
 
#define LOAD2
 
#define STAT2
 
#define WRITE2
 
#define LOAD_GBRA
 
#define STAT_BGRA
 
#define WRITE_GBRA
 
#define OFFSET(x)   offsetof(HYuvContext, x)
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 
#define HUFF_CLASS(variant)
 
#define FF_HUFFYUV_COMMON_OPTS
 

Functions

static int sub_left_prediction (HYuvContext *s, uint8_t *dst, uint8_t *src, int w, int left)
 
static void sub_left_prediction_bgr32 (HYuvContext *s, uint8_t *dst, uint8_t *src, int w, int *red, int *green, int *blue, int *alpha)
 
static void sub_left_prediction_rgb24 (HYuvContext *s, uint8_t *dst, uint8_t *src, int w, int *red, int *green, int *blue)
 
static int store_table (HYuvContext *s, const uint8_t *len, uint8_t *buf)
 
static av_cold int encode_init (AVCodecContext *avctx)
 
static int encode_422_bitstream (HYuvContext *s, int offset, int count)
 
static int encode_gray_bitstream (HYuvContext *s, int count)
 
static int encode_bgra_bitstream (HYuvContext *s, int count, int planes)
 
static int encode_frame (AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
 
static av_cold int encode_end (AVCodecContext *avctx)
 
 HUFF_CLASS (huffyuv)
 

Variables

static const AVOption huffyuv_options []
 
AVCodec ff_huffyuv_encoder
 

Detailed Description

huffyuv encoder

Definition in file huffyuvenc.c.

Macro Definition Documentation

◆ LOAD4

#define LOAD4
Value:
int y0 = y[2 * i];\
int y1 = y[2 * i + 1];\
int u0 = u[i];\
int v0 = v[i];
#define u(width,...)

Referenced by encode_422_bitstream().

◆ LOAD2

#define LOAD2
Value:
int y0 = s->temp[0][2 * i];\
int y1 = s->temp[0][2 * i + 1];

Referenced by encode_gray_bitstream().

◆ STAT2

#define STAT2
Value:
s->stats[0][y0]++;\
s->stats[0][y1]++;

Referenced by encode_gray_bitstream().

◆ WRITE2

#define WRITE2
Value:
put_bits(&s->pb, s->len[0][y0], s->bits[0][y0]);\
put_bits(&s->pb, s->len[0][y1], s->bits[0][y1]);
static void put_bits(PutBitContext *s, int n, unsigned int value)
Write up to 31 bits into a bitstream.
Definition: put_bits.h:134

Referenced by encode_gray_bitstream().

◆ LOAD_GBRA

#define LOAD_GBRA
Value:
int g = s->temp[0][planes == 3 ? 3 * i + 1 : 4 * i + G]; \
int b = s->temp[0][planes == 3 ? 3 * i + 2 : 4 * i + B] - g & 0xFF; \
int r = s->temp[0][planes == 3 ? 3 * i + 0 : 4 * i + R] - g & 0xFF; \
int a = s->temp[0][planes * i + A];
#define G
Definition: huffyuv.h:50
#define R
Definition: huffyuv.h:51
Definition: vf_drawbox.c:37
#define b
Definition: input.c:52
#define B
Definition: huffyuv.h:49
#define r
Definition: input.c:51
g
Definition: yuv2rgb.c:546

Referenced by encode_bgra_bitstream().

◆ STAT_BGRA

#define STAT_BGRA
Value:
s->stats[0][b]++; \
s->stats[1][g]++; \
s->stats[2][r]++; \
if (planes == 4) \
s->stats[2][a]++;
#define b
Definition: input.c:52
#define r
Definition: input.c:51
g
Definition: yuv2rgb.c:546

Referenced by encode_bgra_bitstream().

◆ WRITE_GBRA

#define WRITE_GBRA
Value:
put_bits(&s->pb, s->len[1][g], s->bits[1][g]); \
put_bits(&s->pb, s->len[0][b], s->bits[0][b]); \
put_bits(&s->pb, s->len[2][r], s->bits[2][r]); \
if (planes == 4) \
put_bits(&s->pb, s->len[2][a], s->bits[2][a]);
#define b
Definition: input.c:52
#define r
Definition: input.c:51
g
Definition: yuv2rgb.c:546
static void put_bits(PutBitContext *s, int n, unsigned int value)
Write up to 31 bits into a bitstream.
Definition: put_bits.h:134

Referenced by encode_bgra_bitstream().

◆ OFFSET

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

Definition at line 703 of file huffyuvenc.c.

◆ VE

Definition at line 704 of file huffyuvenc.c.

◆ HUFF_CLASS

#define HUFF_CLASS (   variant)
Value:
static const AVClass variant ## _class = { \
.class_name = # variant, \
.item_name = av_default_item_name, \
.option = variant ## _options, \
.version = LIBAVUTIL_VERSION_INT, \
}
LIBAVUTIL_VERSION_INT
Definition: eval.c:55
av_default_item_name
Definition: dnxhdenc.c:55
Describe the class of an AVClass context structure.
Definition: log.h:34
Definition: hls.c:70

Definition at line 706 of file huffyuvenc.c.

◆ FF_HUFFYUV_COMMON_OPTS

#define FF_HUFFYUV_COMMON_OPTS
Value:
{ "pred", "Prediction method", OFFSET(predictor), AV_OPT_TYPE_INT, { .i64 = LEFT }, LEFT, MEDIAN, VE, "pred" }, \
{ "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LEFT }, INT_MIN, INT_MAX, VE, "pred" }, \
{ "plane", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PLANE }, INT_MIN, INT_MAX, VE, "pred" }, \
{ "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MEDIAN }, INT_MIN, INT_MAX, VE, "pred" }
static void predictor(uint8_t *src, int size)
Definition: exr.c:220
Definition: huffyuv.h:57
NULL
Definition: eval.c:55
Definition: huffyuv.h:58
#define OFFSET(x)
Definition: huffyuvenc.c:703
#define VE
Definition: huffyuvenc.c:704
#define LEFT
Definition: cdgraphics.c:163

Definition at line 714 of file huffyuvenc.c.

Function Documentation

◆ sub_left_prediction()

static int sub_left_prediction ( HYuvContext s,
uint8_t dst,
uint8_t src,
int  w,
int  left 
)
inlinestatic

Definition at line 38 of file huffyuvenc.c.

Referenced by encode_frame().

◆ sub_left_prediction_bgr32()

static void sub_left_prediction_bgr32 ( HYuvContext s,
uint8_t dst,
uint8_t src,
int  w,
int *  red,
int *  green,
int *  blue,
int *  alpha 
)
inlinestatic

Definition at line 60 of file huffyuvenc.c.

Referenced by encode_frame().

◆ sub_left_prediction_rgb24()

static void sub_left_prediction_rgb24 ( HYuvContext s,
uint8_t dst,
uint8_t src,
int  w,
int *  red,
int *  green,
int *  blue 
)
inlinestatic

Definition at line 95 of file huffyuvenc.c.

Referenced by encode_frame().

◆ store_table()

static int store_table ( HYuvContext s,
const uint8_t len,
uint8_t buf 
)
static

Definition at line 123 of file huffyuvenc.c.

Referenced by encode_frame(), and encode_init().

◆ encode_init()

static av_cold int encode_init ( AVCodecContext avctx)
static

Definition at line 147 of file huffyuvenc.c.

◆ encode_422_bitstream()

static int encode_422_bitstream ( HYuvContext s,
int  offset,
int  count 
)
static

Definition at line 305 of file huffyuvenc.c.

Referenced by encode_frame().

◆ encode_gray_bitstream()

static int encode_gray_bitstream ( HYuvContext s,
int  count 
)
static

Definition at line 360 of file huffyuvenc.c.

Referenced by encode_frame().

◆ encode_bgra_bitstream()

static int encode_bgra_bitstream ( HYuvContext s,
int  count,
int  planes 
)
inlinestatic

Definition at line 405 of file huffyuvenc.c.

Referenced by encode_frame().

◆ encode_frame()

static int encode_frame ( AVCodecContext avctx,
AVPacket pkt,
const AVFrame pict,
int *  got_packet 
)
static

Definition at line 456 of file huffyuvenc.c.

◆ encode_end()

static av_cold int encode_end ( AVCodecContext avctx)
static

Definition at line 691 of file huffyuvenc.c.

◆ HUFF_CLASS()

HUFF_CLASS ( huffyuv  )

Variable Documentation

◆ huffyuv_options

const AVOption huffyuv_options[]
static
Initial value:
= {
{ NULL},
}
NULL
Definition: eval.c:55
#define FF_HUFFYUV_COMMON_OPTS
Definition: huffyuvenc.c:714

Definition at line 720 of file huffyuvenc.c.

◆ ff_huffyuv_encoder

AVCodec ff_huffyuv_encoder
Initial value:
= {
.name = "huffyuv",
.long_name = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"),
.priv_data_size = sizeof(HYuvContext),
.priv_class = &huffyuv_class,
.encode2 = encode_frame,
.close = encode_end,
.pix_fmts = (const enum AVPixelFormat[]){
},
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
}
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: internal.h:48
static av_cold int encode_init(AVCodecContext *avctx)
Definition: huffyuvenc.c:147
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:61
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: internal.h:40
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
Definition: huffyuvenc.c:456
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:148
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:63
static av_cold int encode_end(AVCodecContext *avctx)
Definition: huffyuvenc.c:691
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:242
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:257
static av_cold int init(AVCodecParserContext *s)
Definition: h264_parser.c:582
AVPixelFormat
Pixel format.
Definition: pixfmt.h:57

Definition at line 727 of file huffyuvenc.c.