FF Video Codec 1 (a lossless codec). More...
#include "avcodec.h"
#include "get_bits.h"
#include "put_bits.h"
#include "dsputil.h"
#include "rangecoder.h"
#include "golomb.h"
#include "mathops.h"
#include "libavutil/avassert.h"
Go to the source code of this file.
Data Structures | |
struct | VlcState |
struct | PlaneContext |
struct | FFV1Context |
Defines | |
#define | MAX_PLANES 4 |
#define | CONTEXT_SIZE 32 |
#define | MAX_QUANT_TABLES 8 |
#define | MAX_CONTEXT_INPUTS 5 |
#define | MAX_SLICES 256 |
#define | put_rac(C, S, B) |
#define | COST(old, new) |
#define | COST2(old, new) |
#define | STATS_OUT_SIZE 1024*1024*6 |
Typedefs | |
typedef struct VlcState | VlcState |
typedef struct PlaneContext | PlaneContext |
typedef struct FFV1Context | FFV1Context |
Functions | |
static av_always_inline int | fold (int diff, int bits) |
static int | predict (int16_t *src, int16_t *last) |
static int | get_context (PlaneContext *p, int16_t *src, int16_t *last, int16_t *last2) |
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 void av_noinline | put_symbol (RangeCoder *c, uint8_t *state, int v, int is_signed) |
static av_flatten int | get_symbol_inline (RangeCoder *c, uint8_t *state, int is_signed) |
static int av_noinline | get_symbol (RangeCoder *c, uint8_t *state, int is_signed) |
static void | update_vlc_state (VlcState *const state, const int v) |
static void | put_vlc_symbol (PutBitContext *pb, VlcState *const state, int v, int bits) |
static int | get_vlc_symbol (GetBitContext *gb, VlcState *const state, int bits) |
static av_always_inline int | encode_line (FFV1Context *s, int w, int16_t *sample[2], 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, uint32_t *src, int w, int h, int stride) |
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 av_cold int | common_init (AVCodecContext *avctx) |
static int | init_slice_state (FFV1Context *f) |
static av_cold int | init_slice_contexts (FFV1Context *f) |
static int | allocate_initial_states (FFV1Context *f) |
static int | write_extra_header (FFV1Context *f) |
static int | sort_stt (FFV1Context *s, uint8_t stt[256]) |
static av_cold int | encode_init (AVCodecContext *avctx) |
static void | clear_state (FFV1Context *f) |
static int | encode_slice (AVCodecContext *c, void *arg) |
static int | encode_frame (AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data) |
static av_cold int | common_end (AVCodecContext *avctx) |
static av_always_inline void | decode_line (FFV1Context *s, int w, int16_t *sample[2], int plane_index, int bits) |
static void | decode_plane (FFV1Context *s, uint8_t *src, int w, int h, int stride, int plane_index) |
static void | decode_rgb_frame (FFV1Context *s, uint32_t *src, int w, int h, int stride) |
static int | decode_slice (AVCodecContext *c, void *arg) |
static int | read_quant_table (RangeCoder *c, int16_t *quant_table, int scale) |
static int | read_quant_tables (RangeCoder *c, int16_t quant_table[MAX_CONTEXT_INPUTS][256]) |
static int | read_extra_header (FFV1Context *f) |
static int | read_header (FFV1Context *f) |
static av_cold int | decode_init (AVCodecContext *avctx) |
static int | decode_frame (AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) |
Variables | |
const uint8_t | ff_log2_run [41] |
static const int8_t | quant5_10bit [256] |
static const int8_t | quant5 [256] |
static const int8_t | quant9_10bit [256] |
static const int8_t | quant11 [256] |
static const uint8_t | ver2_state [256] |
AVCodec | ff_ffv1_decoder |
AVCodec | ff_ffv1_encoder |
FF Video Codec 1 (a lossless codec).
Definition in file ffv1.c.
#define CONTEXT_SIZE 32 |
Definition at line 38 of file ffv1.c.
Referenced by clear_state(), init_slice_state(), and write_extra_header().
#define COST | ( | old, | ||
new | ||||
) |
s->rc_stat[old][0]*-log2((256-(new))/256.0)\ +s->rc_stat[old][1]*-log2( (new) /256.0)
#define COST2 | ( | old, | ||
new | ||||
) |
Referenced by sort_stt().
#define MAX_QUANT_TABLES 8 |
Definition at line 40 of file ffv1.c.
Referenced by read_extra_header().
#define MAX_SLICES 256 |
Definition at line 156 of file ffv1.c.
Referenced by read_header().
#define put_rac | ( | C, | ||
S, | ||||
B | ||||
) |
Referenced by encode_frame(), encode_header(), encode_q_branch(), encode_q_branch2(), encode_subband_c0run(), put_symbol(), put_symbol2(), put_symbol_inline(), write_extra_header(), and write_header().
#define STATS_OUT_SIZE 1024*1024*6 |
Referenced by encode_init().
typedef struct FFV1Context FFV1Context |
typedef struct PlaneContext PlaneContext |
static int allocate_initial_states | ( | FFV1Context * | f | ) | [static] |
Definition at line 736 of file ffv1.c.
Referenced by encode_init(), and read_extra_header().
static void clear_state | ( | FFV1Context * | f | ) | [static] |
Definition at line 1027 of file ffv1.c.
Referenced by decode_frame(), and encode_frame().
static av_cold int common_end | ( | AVCodecContext * | avctx | ) | [static] |
static av_cold int common_init | ( | AVCodecContext * | avctx | ) | [static] |
Definition at line 656 of file ffv1.c.
Referenced by decode_init(), and encode_init().
static int decode_frame | ( | AVCodecContext * | avctx, | |
void * | data, | |||
int * | data_size, | |||
AVPacket * | avpkt | |||
) | [static] |
static av_cold int decode_init | ( | AVCodecContext * | avctx | ) | [static] |
static av_always_inline void decode_line | ( | FFV1Context * | s, | |
int | w, | |||
int16_t * | sample[2], | |||
int | plane_index, | |||
int | bits | |||
) | [static] |
Definition at line 1242 of file ffv1.c.
Referenced by decode_plane(), and decode_rgb_frame().
static void decode_plane | ( | FFV1Context * | s, | |
uint8_t * | src, | |||
int | w, | |||
int | h, | |||
int | stride, | |||
int | plane_index | |||
) | [static] |
Definition at line 1303 of file ffv1.c.
Referenced by decode_slice().
static void decode_rgb_frame | ( | FFV1Context * | s, | |
uint32_t * | src, | |||
int | w, | |||
int | h, | |||
int | stride | |||
) | [static] |
Definition at line 1338 of file ffv1.c.
Referenced by decode_slice().
static int decode_slice | ( | AVCodecContext * | c, | |
void * | arg | |||
) | [static] |
Definition at line 1380 of file ffv1.c.
Referenced by decode_frame().
static int encode_frame | ( | AVCodecContext * | avctx, | |
unsigned char * | buf, | |||
int | buf_size, | |||
void * | data | |||
) | [static] |
static av_cold int encode_init | ( | AVCodecContext * | avctx | ) | [static] |
static av_always_inline int encode_line | ( | FFV1Context * | s, | |
int | w, | |||
int16_t * | sample[2], | |||
int | plane_index, | |||
int | bits | |||
) | [static] |
Definition at line 440 of file ffv1.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 525 of file ffv1.c.
Referenced by encode_slice().
static void encode_rgb_frame | ( | FFV1Context * | s, | |
uint32_t * | src, | |||
int | w, | |||
int | h, | |||
int | stride | |||
) | [static] |
Definition at line 555 of file ffv1.c.
Referenced by encode_slice().
static int encode_slice | ( | AVCodecContext * | c, | |
void * | arg | |||
) | [static] |
Definition at line 1056 of file ffv1.c.
Referenced by encode_frame().
static void find_best_state | ( | uint8_t | best_state[256][256], | |
const uint8_t | one_state[256] | |||
) | [static] |
Definition at line 236 of file ffv1.c.
Referenced by encode_init().
static av_always_inline int fold | ( | int | diff, | |
int | bits | |||
) | [static] |
Definition at line 198 of file ffv1.c.
Referenced by encode_line(), get_vlc_symbol(), and put_vlc_symbol().
static int get_context | ( | PlaneContext * | p, | |
int16_t * | src, | |||
int16_t * | last, | |||
int16_t * | last2 | |||
) | [inline, static] |
Definition at line 219 of file ffv1.c.
Referenced by decode_line(), and encode_line().
static int av_noinline get_symbol | ( | RangeCoder * | c, | |
uint8_t * | state, | |||
int | is_signed | |||
) | [static] |
Definition at line 349 of file ffv1.c.
Referenced by decode_header(), decode_q_branch(), decode_qlogs(), read_extra_header(), read_header(), and read_quant_table().
static av_flatten int get_symbol_inline | ( | RangeCoder * | c, | |
uint8_t * | state, | |||
int | is_signed | |||
) | [inline, static] |
Definition at line 329 of file ffv1.c.
Referenced by decode_line(), and get_symbol().
static int get_vlc_symbol | ( | GetBitContext * | gb, | |
VlcState *const | state, | |||
int | bits | |||
) | [inline, static] |
Definition at line 411 of file ffv1.c.
Referenced by decode_line().
static av_cold int init_slice_contexts | ( | FFV1Context * | f | ) | [static] |
Definition at line 707 of file ffv1.c.
Referenced by decode_init(), and encode_init().
static int init_slice_state | ( | FFV1Context * | f | ) | [static] |
Definition at line 676 of file ffv1.c.
Referenced by decode_frame(), and encode_init().
static int predict | ( | int16_t * | src, | |
int16_t * | last | |||
) | [inline, static] |
Definition at line 210 of file ffv1.c.
Referenced by decode_line(), and encode_line().
static void av_noinline put_symbol | ( | RangeCoder * | c, | |
uint8_t * | state, | |||
int | v, | |||
int | is_signed | |||
) | [static] |
Definition at line 325 of file ffv1.c.
Referenced by encode_header(), encode_q_branch(), encode_q_branch2(), encode_qlogs(), write_extra_header(), write_header(), and write_quant_table().
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 278 of file ffv1.c.
Referenced by encode_line(), and put_symbol().
static void put_vlc_symbol | ( | PutBitContext * | pb, | |
VlcState *const | state, | |||
int | v, | |||
int | bits | |||
) | [inline, static] |
Definition at line 384 of file ffv1.c.
Referenced by encode_line().
static int read_extra_header | ( | FFV1Context * | f | ) | [static] |
Definition at line 1449 of file ffv1.c.
Referenced by decode_init().
static int read_header | ( | FFV1Context * | f | ) | [static] |
Definition at line 1509 of file ffv1.c.
Referenced by decode_frame(), and mjpegb_decode_frame().
static int read_quant_table | ( | RangeCoder * | c, | |
int16_t * | quant_table, | |||
int | scale | |||
) | [static] |
Definition at line 1408 of file ffv1.c.
Referenced by read_quant_tables().
static int read_quant_tables | ( | RangeCoder * | c, | |
int16_t | quant_table[MAX_CONTEXT_INPUTS][256] | |||
) | [static] |
Definition at line 1436 of file ffv1.c.
Referenced by read_extra_header(), and read_header().
static int sort_stt | ( | FFV1Context * | s, | |
uint8_t | stt[256] | |||
) | [static] |
Definition at line 804 of file ffv1.c.
Referenced by encode_init().
static void update_vlc_state | ( | VlcState *const | state, | |
const int | v | |||
) | [inline, static] |
Definition at line 353 of file ffv1.c.
Referenced by get_vlc_symbol(), and put_vlc_symbol().
static int write_extra_header | ( | FFV1Context * | f | ) | [static] |
Definition at line 749 of file ffv1.c.
Referenced by encode_init().
static void write_header | ( | FFV1Context * | f | ) | [static] |
Definition at line 615 of file ffv1.c.
Referenced by encode_frame().
static void write_quant_table | ( | RangeCoder * | c, | |
int16_t * | quant_table | |||
) | [static] |
Definition at line 594 of file ffv1.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 609 of file ffv1.c.
Referenced by write_extra_header(), and write_header().
{ .name = "ffv1", .type = AVMEDIA_TYPE_VIDEO, .id = CODEC_ID_FFV1, .priv_data_size = sizeof(FFV1Context), .init = decode_init, .close = common_end, .decode = decode_frame, .capabilities = CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS, .long_name= NULL_IF_CONFIG_SMALL("FFmpeg video codec #1"), }
{ .name = "ffv1", .type = AVMEDIA_TYPE_VIDEO, .id = CODEC_ID_FFV1, .priv_data_size = sizeof(FFV1Context), .init = encode_init, .encode = encode_frame, .close = common_end, .capabilities = CODEC_CAP_SLICE_THREADS, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV411P, PIX_FMT_YUV410P, PIX_FMT_RGB32, PIX_FMT_YUV420P16, PIX_FMT_YUV422P16, PIX_FMT_YUV444P16, PIX_FMT_NONE}, .long_name= NULL_IF_CONFIG_SMALL("FFmpeg video codec #1"), }
const uint8_t ff_log2_run[41] |
Definition at line 35 of file bitstream.c.
const int8_t quant11[256] [static] |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3,-3,-3,-3,-3, -3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3,-3, -3,-3,-3,-3,-3,-3,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2, -2,-2,-2,-2,-1,-1,-1,-1,-1,-1,-1,-1,-0,-0,-0,-0, }
Definition at line 83 of file ffv1.c.
Referenced by encode_init().
const uint8_t ver2_state[256] [static] |
{ 0, 10, 10, 10, 10, 16, 16, 16, 28, 16, 16, 29, 42, 49, 20, 49, 59, 25, 26, 26, 27, 31, 33, 33, 33, 34, 34, 37, 67, 38, 39, 39, 40, 40, 41, 79, 43, 44, 45, 45, 48, 48, 64, 50, 51, 52, 88, 52, 53, 74, 55, 57, 58, 58, 74, 60, 101, 61, 62, 84, 66, 66, 68, 69, 87, 82, 71, 97, 73, 73, 82, 75, 111, 77, 94, 78, 87, 81, 83, 97, 85, 83, 94, 86, 99, 89, 90, 99, 111, 92, 93, 134, 95, 98, 105, 98, 105, 110, 102, 108, 102, 118, 103, 106, 106, 113, 109, 112, 114, 112, 116, 125, 115, 116, 117, 117, 126, 119, 125, 121, 121, 123, 145, 124, 126, 131, 127, 129, 165, 130, 132, 138, 133, 135, 145, 136, 137, 139, 146, 141, 143, 142, 144, 148, 147, 155, 151, 149, 151, 150, 152, 157, 153, 154, 156, 168, 158, 162, 161, 160, 172, 163, 169, 164, 166, 184, 167, 170, 177, 174, 171, 173, 182, 176, 180, 178, 175, 189, 179, 181, 186, 183, 192, 185, 200, 187, 191, 188, 190, 197, 193, 196, 197, 194, 195, 196, 198, 202, 199, 201, 210, 203, 207, 204, 205, 206, 208, 214, 209, 211, 221, 212, 213, 215, 224, 216, 217, 218, 219, 220, 222, 228, 223, 225, 226, 224, 227, 229, 240, 230, 231, 232, 233, 234, 235, 236, 238, 239, 237, 242, 241, 243, 242, 244, 245, 246, 247, 248, 249, 250, 251, 252, 252, 253, 254, 255, }
Definition at line 121 of file ffv1.c.
Referenced by encode_init().