ffv1.c File Reference

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

Macros

#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)

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_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 void clear_state (FFV1Context *f)
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

Detailed Description

FF Video Codec 1 (a lossless codec)

Definition in file ffv1.c.

Macro Definition Documentation

#define CONTEXT_SIZE   32

Definition at line 38 of file ffv1.c.

Referenced by init_slice_state(), read_extra_header(), read_header(), and read_quant_table().

#define MAX_CONTEXT_INPUTS   5

Definition at line 41 of file ffv1.c.

#define MAX_PLANES   4

Definition at line 37 of file ffv1.c.

#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 
)
Value:
do{\
if(rc_stat){\
rc_stat[*(S)][B]++;\
rc_stat2[(S)-state][B]++;\
}\
put_rac(C,S,B);\
}while(0)

Referenced by put_symbol(), put_symbol2(), and put_symbol_inline().

Typedef Documentation

typedef struct FFV1Context FFV1Context
typedef struct PlaneContext PlaneContext
typedef struct VlcState VlcState

Function Documentation

static int allocate_initial_states ( FFV1Context f)
static

Definition at line 740 of file ffv1.c.

Referenced by read_extra_header().

static void clear_state ( FFV1Context f)
static

Definition at line 1031 of file ffv1.c.

Referenced by decode_frame().

static av_cold int common_end ( AVCodecContext avctx)
static

Definition at line 1211 of file ffv1.c.

static av_cold int common_init ( AVCodecContext avctx)
static

Definition at line 656 of file ffv1.c.

Referenced by decode_init().

static int decode_frame ( AVCodecContext avctx,
void data,
int *  data_size,
AVPacket avpkt 
)
static

Definition at line 1672 of file ffv1.c.

static av_cold int decode_init ( AVCodecContext avctx)
static

Definition at line 1657 of file ffv1.c.

static av_always_inline void decode_line ( FFV1Context s,
int  w,
int16_t *  sample[2],
int  plane_index,
int  bits 
)
static

Definition at line 1246 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 1307 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 1342 of file ffv1.c.

Referenced by decode_slice().

static int decode_slice ( AVCodecContext c,
void arg 
)
static

Definition at line 1384 of file ffv1.c.

Referenced by decode_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.

static av_always_inline int fold ( int  diff,
int  bits 
)
static

Definition at line 198 of file ffv1.c.

Referenced by get_vlc_symbol(), and put_vlc_symbol().

static int get_context ( PlaneContext p,
int16_t *  src,
int16_t *  last,
int16_t *  last2 
)
inlinestatic

Definition at line 219 of file ffv1.c.

Referenced by decode_line().

static int av_noinline get_symbol ( RangeCoder c,
uint8_t *  state,
int  is_signed 
)
static
static av_flatten int get_symbol_inline ( RangeCoder c,
uint8_t *  state,
int  is_signed 
)
inlinestatic

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 
)
inlinestatic

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

static int init_slice_state ( FFV1Context f)
static

Definition at line 676 of file ffv1.c.

Referenced by decode_frame().

static int predict ( int16_t *  src,
int16_t *  last 
)
inlinestatic

Definition at line 210 of file ffv1.c.

Referenced by decode_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.

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

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

Definition at line 384 of file ffv1.c.

static int read_extra_header ( FFV1Context f)
static

Definition at line 1453 of file ffv1.c.

Referenced by decode_init().

static int read_header ( FFV1Context f)
static

Definition at line 1513 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 1412 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 1440 of file ffv1.c.

Referenced by read_extra_header(), and read_header().

static void update_vlc_state ( VlcState *const  state,
const int  v 
)
inlinestatic

Definition at line 353 of file ffv1.c.

Referenced by get_vlc_symbol(), and put_vlc_symbol().

Variable Documentation

AVCodec ff_ffv1_decoder
Initial value:
{
.name = "ffv1",
.priv_data_size = sizeof(FFV1Context),
.long_name= NULL_IF_CONFIG_SMALL("FFmpeg video codec #1"),
}

Definition at line 1755 of file ffv1.c.

const uint8_t ff_log2_run[41]

Definition at line 35 of file bitstream.c.

const int8_t quant11[256]
static
Initial value:
{
0, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5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,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,
}

Definition at line 45 of file ffv1.c.

const int8_t quant9_10bit[256]
static
Initial value:
{
0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,
-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,
-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,
-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,
-4,-4,-4,-4,-4,-4,-4,-4,-4,-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,-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.

const uint8_t ver2_state[256]
static
Initial value:
{
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.