ffv1enc.c File Reference

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

#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 "dsputil.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 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)
 

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 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 OFFSET (   x)    offsetof(FFV1Context, x)

Definition at line 1057 of file ffv1enc.c.

#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: dsputil.c:1897
static uint32_t state
Definition: trasher.c:27
#define put_rac(C, S, B)
if(!(ptr_align%ac->ptr_align)&&samples_align >=aligned_len)

Referenced by encode_header(), encode_q_branch(), encode_q_branch2(), encode_slice(), encode_subband_c0run(), ffv1_encode_frame(), put_symbol(), put_symbol2(), put_symbol_inline(), write_extradata(), and write_header().

#define STATS_OUT_SIZE   1024 * 1024 * 6

Definition at line 1058 of file ffv1enc.c.

Function Documentation

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.

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.

static int encode_slice ( AVCodecContext c,
void arg 
)
static

Definition at line 869 of file ffv1enc.c.

Referenced by ffv1_encode_frame().

static void encode_slice_header ( FFV1Context f,
FFV1Context fs 
)
static

Definition at line 843 of file ffv1enc.c.

Referenced by encode_slice().

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

Definition at line 924 of file ffv1enc.c.

static av_cold int ffv1_encode_init ( AVCodecContext avctx)
static

Definition at line 559 of file ffv1enc.c.

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 int init_slices_state ( FFV1Context f)
static

Definition at line 548 of file ffv1enc.c.

Referenced by ffv1_encode_init().

static av_noinline void put_symbol ( RangeCoder c,
uint8_t state,
int  v,
int  is_signed 
)
static
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 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 int sort_stt ( FFV1Context s,
uint8_t  stt[256] 
)
static

Definition at line 500 of file ffv1enc.c.

Referenced by ffv1_encode_init().

static int write_extradata ( FFV1Context f)
static

Definition at line 427 of file ffv1enc.c.

Referenced by ffv1_encode_init().

static void write_header ( FFV1Context f)
static

Definition at line 380 of file ffv1enc.c.

Referenced by ffv1_encode_frame().

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().

Variable Documentation

const { ... }
class_name = "ffv1 encoder"

Definition at line 1066 of file ffv1enc.c.

Referenced by av_opt_show2().

AVCodec ff_ffv1_encoder
Initial value:
= {
.name = "ffv1",
.priv_data_size = sizeof(FFV1Context),
.encode2 = ffv1_encode_frame,
.capabilities = CODEC_CAP_SLICE_THREADS,
.pix_fmts = (const enum AVPixelFormat[]) {
},
.long_name = NULL_IF_CONFIG_SMALL("FFmpeg video codec #1"),
.defaults = ffv1_defaults,
.priv_class = &class,
}
static const AVCodecDefault ffv1_defaults[]
Definition: ffv1enc.c:1072
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
static int ffv1_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
Definition: ffv1enc.c:924
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:102
struct FFV1Context FFV1Context
static int init(AVCodecParserContext *s)
Definition: h264_parser.c:335
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:161
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:88
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:69
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:162
static void close(AVCodecParserContext *s)
Definition: h264_parser.c:326
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:71
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:65
Y , 8bpp.
Definition: pixfmt.h:73
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:72
av_cold int ffv1_close(AVCodecContext *avctx)
Definition: ffv1.c:269
AVPixelFormat
Pixel format.
Definition: pixfmt.h:63

Definition at line 1077 of file ffv1enc.c.

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

Definition at line 1072 of file ffv1enc.c.

item_name = av_default_item_name

Definition at line 1067 of file ffv1enc.c.

option = options

Definition at line 1068 of file ffv1enc.c.

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:1058
NULL
Definition: eval.c:52
#define OFFSET(x)
Definition: ffv1enc.c:1057

Definition at line 1059 of file ffv1enc.c.