FFmpeg
Macros | Functions | Variables
huffyuvenc.c File Reference

huffyuv encoder More...

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

Go to the source code of this file.

Macros

#define STATS_OUT_SIZE   21*MAX_N*3 + 4
 
#define LOAD4
 
#define LOADEND   int y0 = s->temp[0][width-1];
 
#define LOADEND_14   int y0 = s->temp16[0][width-1] & mask;
 
#define LOADEND_16   int y0 = s->temp16[0][width-1];
 
#define STATEND   s->stats[plane][y0]++;
 
#define STATEND_16   s->stats[plane][y0>>2]++;
 
#define WRITEEND   put_bits(&s->pb, s->len[plane][y0], s->bits[plane][y0]);
 
#define WRITEEND_16
 
#define LOAD2
 
#define LOAD2_14
 
#define LOAD2_16
 
#define STAT2
 
#define STAT2_16
 
#define WRITE2
 
#define WRITE2_16
 
#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 COMMON_OPTIONS
 

Functions

static void diff_bytes (HYuvContext *s, uint8_t *dst, const uint8_t *src0, const uint8_t *src1, int w)
 
static int sub_left_prediction (HYuvContext *s, uint8_t *dst, const uint8_t *src, int w, int left)
 
static void sub_left_prediction_bgr32 (HYuvContext *s, uint8_t *dst, const 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 void sub_median_prediction (HYuvContext *s, uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w, int *left, int *left_top)
 
static int store_table (HYuvContext *s, const uint8_t *len, uint8_t *buf)
 
static int store_huffman_tables (HYuvContext *s, 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_plane_bitstream (HYuvContext *s, int width, int plane)
 
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)
 

Variables

static const AVOption normal_options []
 
static const AVOption ff_options []
 
static const AVClass normal_class
 
static const AVClass ff_class
 
AVCodec ff_huffyuv_encoder
 

Detailed Description

huffyuv encoder

Definition in file huffyuvenc.c.

Macro Definition Documentation

#define STATS_OUT_SIZE   21*MAX_N*3 + 4

Referenced by encode_frame(), and encode_init().

#define LOAD4
Value:
int y0 = y[2 * i];\
int y1 = y[2 * i + 1];\
int u0 = u[i];\
int v0 = v[i];
GLfloat v0
Definition: opengl_enc.c:106
#define u(width, name, range_min, range_max)
Definition: cbs_h2645.c:252
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
int

Referenced by encode_422_bitstream().

#define LOADEND   int y0 = s->temp[0][width-1];

Referenced by encode_plane_bitstream().

#define LOADEND_14   int y0 = s->temp16[0][width-1] & mask;

Referenced by encode_plane_bitstream().

#define LOADEND_16   int y0 = s->temp16[0][width-1];

Referenced by encode_plane_bitstream().

#define STATEND   s->stats[plane][y0]++;

Referenced by encode_plane_bitstream().

#define STATEND_16   s->stats[plane][y0>>2]++;

Referenced by encode_plane_bitstream().

#define WRITEEND   put_bits(&s->pb, s->len[plane][y0], s->bits[plane][y0]);

Referenced by encode_plane_bitstream().

#define WRITEEND_16
Value:
put_bits(&s->pb, s->len[plane][y0>>2], s->bits[plane][y0>>2]);\
put_bits(&s->pb, 2, y0&3);
int plane
Definition: avisynth_c.h:384
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:208
#define s(width, name)
Definition: cbs_vp9.c:257

Referenced by encode_plane_bitstream().

#define LOAD2
Value:
int y0 = s->temp[0][2 * i];\
int y1 = s->temp[0][2 * i + 1];
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
#define s(width, name)
Definition: cbs_vp9.c:257
int

Referenced by encode_gray_bitstream(), and encode_plane_bitstream().

#define LOAD2_14
Value:
int y0 = s->temp16[0][2 * i] & mask;\
int y1 = s->temp16[0][2 * i + 1] & mask;
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
static const uint16_t mask[17]
Definition: lzw.c:38
#define s(width, name)
Definition: cbs_vp9.c:257
int

Referenced by encode_plane_bitstream().

#define LOAD2_16
Value:
int y0 = s->temp16[0][2 * i];\
int y1 = s->temp16[0][2 * i + 1];
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
#define s(width, name)
Definition: cbs_vp9.c:257
int

Referenced by encode_plane_bitstream().

#define STAT2
Value:
s->stats[plane][y0]++;\
s->stats[plane][y1]++;
int plane
Definition: avisynth_c.h:384
#define s(width, name)
Definition: cbs_vp9.c:257

Referenced by encode_gray_bitstream(), and encode_plane_bitstream().

#define STAT2_16
Value:
s->stats[plane][y0>>2]++;\
s->stats[plane][y1>>2]++;
int plane
Definition: avisynth_c.h:384
#define s(width, name)
Definition: cbs_vp9.c:257

Referenced by encode_plane_bitstream().

#define WRITE2
Value:
put_bits(&s->pb, s->len[plane][y0], s->bits[plane][y0]);\
put_bits(&s->pb, s->len[plane][y1], s->bits[plane][y1]);
int plane
Definition: avisynth_c.h:384
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:208
#define s(width, name)
Definition: cbs_vp9.c:257

Referenced by encode_gray_bitstream(), and encode_plane_bitstream().

#define WRITE2_16
Value:
put_bits(&s->pb, s->len[plane][y0>>2], s->bits[plane][y0>>2]);\
put_bits(&s->pb, 2, y0&3);\
put_bits(&s->pb, s->len[plane][y1>>2], s->bits[plane][y1>>2]);\
put_bits(&s->pb, 2, y1&3);
int plane
Definition: avisynth_c.h:384
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:208
#define s(width, name)
Definition: cbs_vp9.c:257

Referenced by encode_plane_bitstream().

#define LOAD2
Value:
int y0 = s->temp[0][2 * i];\
int y1 = s->temp[0][2 * i + 1];
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
#define s(width, name)
Definition: cbs_vp9.c:257
int
#define STAT2
Value:
s->stats[0][y0]++;\
s->stats[0][y1]++;
#define s(width, name)
Definition: cbs_vp9.c:257
#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(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:208
#define s(width, name)
Definition: cbs_vp9.c:257
#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];
static const struct @314 planes[]
const char * g
Definition: vf_curves.c:115
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:36
#define A(x)
Definition: vp56_arith.h:28
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
#define R
Definition: huffyuvdsp.h:34
#define B
Definition: huffyuvdsp.h:32
const char * r
Definition: vf_curves.c:114
#define b
Definition: input.c:41
#define s(width, name)
Definition: cbs_vp9.c:257
int
#define G
Definition: huffyuvdsp.h:33

Referenced by encode_bgra_bitstream().

#define STAT_BGRA
Value:
s->stats[0][b]++; \
s->stats[1][g]++; \
s->stats[2][r]++; \
if (planes == 4) \
s->stats[2][a]++;
static const struct @314 planes[]
const char * g
Definition: vf_curves.c:115
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:36
const char * r
Definition: vf_curves.c:114
#define b
Definition: input.c:41
#define s(width, name)
Definition: cbs_vp9.c:257
if(ret)

Referenced by encode_bgra_bitstream().

#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]);
static const struct @314 planes[]
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:208
const char * g
Definition: vf_curves.c:115
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:36
const char * r
Definition: vf_curves.c:114
#define b
Definition: input.c:41
#define s(width, name)
Definition: cbs_vp9.c:257
if(ret)

Referenced by encode_bgra_bitstream().

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

Definition at line 1048 of file huffyuvenc.c.

Definition at line 1049 of file huffyuvenc.c.

#define COMMON_OPTIONS
Value:
{ "non_deterministic", "Allow multithreading for e.g. context=1 at the expense of determinism", \
OFFSET(non_determ), AV_OPT_TYPE_BOOL, { .i64 = 1 }, \
0, 1, VE }, \
{ "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" }, \
#define NULL
Definition: coverity.c:32
Definition: huffyuv.h:51
Definition: huffyuv.h:52
#define OFFSET(x)
Definition: huffyuvenc.c:1048
#define VE
Definition: huffyuvenc.c:1049
#define LEFT
Definition: cdgraphics.c:166

Definition at line 1051 of file huffyuvenc.c.

Function Documentation

static void diff_bytes ( HYuvContext s,
uint8_t dst,
const uint8_t src0,
const uint8_t src1,
int  w 
)
inlinestatic

Definition at line 41 of file huffyuvenc.c.

Referenced by encode_frame().

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

Definition at line 51 of file huffyuvenc.c.

Referenced by encode_frame().

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

Definition at line 82 of file huffyuvenc.c.

Referenced by encode_frame().

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 118 of file huffyuvenc.c.

Referenced by encode_frame().

static void sub_median_prediction ( HYuvContext s,
uint8_t dst,
const uint8_t src1,
const uint8_t src2,
int  w,
int left,
int left_top 
)
static

Definition at line 146 of file huffyuvenc.c.

Referenced by encode_frame().

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

Definition at line 155 of file huffyuvenc.c.

Referenced by store_huffman_tables().

static int store_huffman_tables ( HYuvContext s,
uint8_t buf 
)
static

Definition at line 180 of file huffyuvenc.c.

Referenced by encode_frame(), and encode_init().

static av_cold int encode_init ( AVCodecContext avctx)
static

Definition at line 202 of file huffyuvenc.c.

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

Definition at line 439 of file huffyuvenc.c.

Referenced by encode_frame().

static int encode_plane_bitstream ( HYuvContext s,
int  width,
int  plane 
)
static

Definition at line 494 of file huffyuvenc.c.

Referenced by encode_frame().

static int encode_gray_bitstream ( HYuvContext s,
int  count 
)
static

Definition at line 656 of file huffyuvenc.c.

Referenced by encode_frame().

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

Definition at line 701 of file huffyuvenc.c.

Referenced by encode_frame().

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

Definition at line 752 of file huffyuvenc.c.

static av_cold int encode_end ( AVCodecContext avctx)
static

Definition at line 1036 of file huffyuvenc.c.

Variable Documentation

const AVOption normal_options[]
static
Initial value:
= {
{ NULL },
}
#define NULL
Definition: coverity.c:32
#define COMMON_OPTIONS
Definition: huffyuvenc.c:1051

Definition at line 1060 of file huffyuvenc.c.

const AVOption ff_options[]
static
Initial value:
= {
{ "context", "Set per-frame huffman tables", OFFSET(context), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
{ NULL },
}
#define NULL
Definition: coverity.c:32
#define COMMON_OPTIONS
Definition: huffyuvenc.c:1051
#define OFFSET(x)
Definition: huffyuvenc.c:1048
#define VE
Definition: huffyuvenc.c:1049
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option keep it simple and lowercase description are in without and describe what they for example set the foo of the bar offset is the offset of the field in your local context

Definition at line 1065 of file huffyuvenc.c.

const AVClass normal_class
static
Initial value:
= {
.class_name = "huffyuv",
.item_name = av_default_item_name,
.option = normal_options,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191
static const AVOption normal_options[]
Definition: huffyuvenc.c:1060

Definition at line 1071 of file huffyuvenc.c.

const AVClass ff_class
static
Initial value:
= {
.class_name = "ffvhuff",
.item_name = av_default_item_name,
.option = ff_options,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191
static const AVOption ff_options[]
Definition: huffyuvenc.c:1065

Definition at line 1078 of file huffyuvenc.c.

AVCodec ff_huffyuv_encoder
Initial value:
= {
.name = "huffyuv",
.long_name = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"),
.priv_data_size = sizeof(HYuvContext),
.encode2 = encode_frame,
.close = encode_end,
.priv_class = &normal_class,
.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:202
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:68
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
#define AV_CODEC_CAP_INTRA_ONLY
Codec is intra only.
Definition: avcodec.h:1067
#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:752
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static const AVClass normal_class
Definition: huffyuvenc.c:1071
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: avcodec.h:1037
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
static av_cold int encode_end(AVCodecContext *avctx)
Definition: huffyuvenc.c:1036
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:360
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:275
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64

Definition at line 1085 of file huffyuvenc.c.