Libav
Macros | Functions | Variables
ffv1enc.c File Reference

FF Video Codec 1 (a lossless codec) encoder. More...

#include "libavutil/attributes.h"
#include "libavutil/avassert.h"
#include "libavutil/pixdesc.h"
#include "libavutil/crc.h"
#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "internal.h"
#include "get_bits.h"
#include "put_bits.h"
#include "rangecoder.h"
#include "golomb.h"
#include "mathops.h"
#include "ffv1.h"

Go to the source code of this file.

Macros

#define put_rac(C, S, B)
 
#define COST(old, new)
 
#define COST2(old, new)   COST(old, new) + COST(256 - (old), 256 - (new))
 
#define STATS_OUT_SIZE   1024 * 1024 * 6
 
#define OFFSET(x)   offsetof(FFV1Context, x)
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

Functions

static void find_best_state (uint8_t best_state[256][256], const uint8_t one_state[256])
 
static av_always_inline
av_flatten void 
put_symbol_inline (RangeCoder *c, uint8_t *state, int v, int is_signed, uint64_t rc_stat[256][2], uint64_t rc_stat2[32][2])
 
static av_noinline void put_symbol (RangeCoder *c, uint8_t *state, int v, int is_signed)
 
static void put_vlc_symbol (PutBitContext *pb, VlcState *const state, int v, int bits)
 
static av_always_inline int encode_line (FFV1Context *s, int w, int16_t *sample[3], int plane_index, int bits)
 
static void encode_plane (FFV1Context *s, uint8_t *src, int w, int h, int stride, int plane_index)
 
static void encode_rgb_frame (FFV1Context *s, uint8_t *src[3], int w, int h, int stride[3])
 
static void write_quant_table (RangeCoder *c, int16_t *quant_table)
 
static void write_quant_tables (RangeCoder *c, int16_t quant_table[MAX_CONTEXT_INPUTS][256])
 
static void write_header (FFV1Context *f)
 
static int write_extradata (FFV1Context *f)
 
static int sort_stt (FFV1Context *s, uint8_t stt[256])
 
static av_cold int init_slices_state (FFV1Context *f)
 
static av_cold int ffv1_encode_init (AVCodecContext *avctx)
 
static void encode_slice_header (FFV1Context *f, FFV1Context *fs)
 
static int encode_slice (AVCodecContext *c, void *arg)
 
static int ffv1_encode_frame (AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
 
static av_cold int ffv1_encode_close (AVCodecContext *avctx)
 

Variables

static const AVOption options []
 
class {
      class_name = "ffv1 encoder"
 
      item_name = av_default_item_name
 
      option = options
 
      version = LIBAVUTIL_VERSION_INT
 
}; 
 
static const AVCodecDefault ffv1_defaults []
 
AVCodec ff_ffv1_encoder
 

Detailed Description

FF Video Codec 1 (a lossless codec) encoder.

Definition in file ffv1enc.c.

Macro Definition Documentation

#define put_rac (   C,
  S,
  B 
)
Value:
do { \
if (rc_stat) { \
rc_stat[*(S)][B]++; \
rc_stat2[(S) - state][B]++; \
} \
put_rac(C, S, B); \
} while (0)
#define B
Definition: huffyuv.h:49
#define S(s, c, i)
if(ac->has_optimized_func)
static uint32_t state
Definition: trasher.c:27
#define put_rac(C, S, B)

Referenced by encode_slice(), ffv1_encode_frame(), put_symbol_inline(), write_extradata(), and write_header().

#define COST (   old,
  new 
)
Value:
s->rc_stat[old][0] * -log2((256 - (new)) / 256.0) + \
s->rc_stat[old][1] * -log2((new) / 256.0)
#define log2(x)
Definition: libm.h:111
#define COST2 (   old,
  new 
)    COST(old, new) + COST(256 - (old), 256 - (new))

Referenced by sort_stt().

#define STATS_OUT_SIZE   1024 * 1024 * 6
#define OFFSET (   x)    offsetof(FFV1Context, x)

Definition at line 1068 of file ffv1enc.c.

Definition at line 1069 of file ffv1enc.c.

Function Documentation

static void find_best_state ( uint8_t  best_state[256][256],
const uint8_t  one_state[256] 
)
static

Definition at line 43 of file ffv1enc.c.

Referenced by ffv1_encode_init().

static av_always_inline av_flatten void put_symbol_inline ( RangeCoder c,
uint8_t state,
int  v,
int  is_signed,
uint64_t  rc_stat[256][2],
uint64_t  rc_stat2[32][2] 
)
static

Definition at line 85 of file ffv1enc.c.

Referenced by encode_line(), and put_symbol().

static av_noinline void put_symbol ( RangeCoder c,
uint8_t state,
int  v,
int  is_signed 
)
static

Definition at line 133 of file ffv1enc.c.

Referenced by encode_slice_header(), write_extradata(), write_header(), and write_quant_table().

static void put_vlc_symbol ( PutBitContext pb,
VlcState *const  state,
int  v,
int  bits 
)
inlinestatic

Definition at line 139 of file ffv1enc.c.

Referenced by encode_line().

static av_always_inline int encode_line ( FFV1Context s,
int  w,
int16_t *  sample[3],
int  plane_index,
int  bits 
)
static

Definition at line 170 of file ffv1enc.c.

Referenced by encode_plane(), and encode_rgb_frame().

static void encode_plane ( FFV1Context s,
uint8_t src,
int  w,
int  h,
int  stride,
int  plane_index 
)
static

Definition at line 260 of file ffv1enc.c.

Referenced by encode_slice().

static void encode_rgb_frame ( FFV1Context s,
uint8_t src[3],
int  w,
int  h,
int  stride[3] 
)
static

Definition at line 296 of file ffv1enc.c.

Referenced by encode_slice().

static void write_quant_table ( RangeCoder c,
int16_t *  quant_table 
)
static

Definition at line 357 of file ffv1enc.c.

Referenced by write_quant_tables().

static void write_quant_tables ( RangeCoder c,
int16_t  quant_table[MAX_CONTEXT_INPUTS][256] 
)
static

Definition at line 372 of file ffv1enc.c.

Referenced by write_extradata(), and write_header().

static void write_header ( FFV1Context f)
static

Definition at line 380 of file ffv1enc.c.

Referenced by ffv1_encode_frame().

static int write_extradata ( FFV1Context f)
static

Definition at line 427 of file ffv1enc.c.

Referenced by ffv1_encode_init().

static int sort_stt ( FFV1Context s,
uint8_t  stt[256] 
)
static

Definition at line 500 of file ffv1enc.c.

Referenced by ffv1_encode_init().

static av_cold int init_slices_state ( FFV1Context f)
static

Definition at line 548 of file ffv1enc.c.

Referenced by ffv1_encode_init().

static av_cold int ffv1_encode_init ( AVCodecContext avctx)
static

Definition at line 559 of file ffv1enc.c.

static void encode_slice_header ( FFV1Context f,
FFV1Context fs 
)
static

Definition at line 848 of file ffv1enc.c.

Referenced by encode_slice().

static int encode_slice ( AVCodecContext c,
void arg 
)
static

Definition at line 874 of file ffv1enc.c.

Referenced by ffv1_encode_frame().

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

Definition at line 929 of file ffv1enc.c.

static av_cold int ffv1_encode_close ( AVCodecContext avctx)
static

Definition at line 1061 of file ffv1enc.c.

Variable Documentation

const AVOption options[]
static
Initial value:
= {
{ "slicecrc", "Protect slices with CRCs", OFFSET(ec), AV_OPT_TYPE_INT,
{ .i64 = -1 }, -1, 1, VE },
{ NULL }
}
#define VE
Definition: ffv1enc.c:1069
NULL
Definition: eval.c:55
#define OFFSET(x)
Definition: ffv1enc.c:1068

Definition at line 1070 of file ffv1enc.c.

class_name = "ffv1 encoder"

Definition at line 1077 of file ffv1enc.c.

Referenced by av_opt_show2().

item_name = av_default_item_name

Definition at line 1078 of file ffv1enc.c.

option = options

Definition at line 1079 of file ffv1enc.c.

Referenced by open_input_file(), and open_output_file().

const { ... }
const AVCodecDefault ffv1_defaults[]
static
Initial value:
= {
{ "coder", "-1" },
{ NULL },
}
NULL
Definition: eval.c:55

Definition at line 1083 of file ffv1enc.c.

AVCodec ff_ffv1_encoder
Initial value:
= {
.name = "ffv1",
.long_name = NULL_IF_CONFIG_SMALL("FFmpeg video codec #1"),
.priv_data_size = sizeof(FFV1Context),
.encode2 = ffv1_encode_frame,
.capabilities = CODEC_CAP_SLICE_THREADS,
.pix_fmts = (const enum AVPixelFormat[]) {
},
.defaults = ffv1_defaults,
.priv_class = &class,
}
static const AVCodecDefault ffv1_defaults[]
Definition: ffv1enc.c:1083
static av_cold int ffv1_encode_init(AVCodecContext *avctx)
Definition: ffv1enc.c:559
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:70
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:251
static int ffv1_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
Definition: ffv1enc.c:929
static av_cold int ffv1_encode_close(AVCodecContext *avctx)
Definition: ffv1enc.c:1061
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:104
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:250
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:248
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:170
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:150
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:245
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:69
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:241
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:227
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:242
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:246
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:171
static void close(AVCodecParserContext *s)
Definition: h264_parser.c:490
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:222
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:243
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:71
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:240
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:244
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:65
Y , 8bpp.
Definition: pixfmt.h:73
#define CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: avcodec.h:759
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:72
static av_cold int init(AVCodecParserContext *s)
Definition: h264_parser.c:499
AVPixelFormat
Pixel format.
Definition: pixfmt.h:63
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:247

Definition at line 1088 of file ffv1enc.c.