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,-5,-5,-5,-5,-5,
115 -5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,
116 -5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-4,-4,
117 -4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,
118 -4,-4,-4,-4,-4,-3,-3,-3,-3,-3,-3,-3,-2,-2,-2,-1,
122 0, 10, 10, 10, 10, 16, 16, 16, 28, 16, 16, 29, 42, 49, 20, 49,
123 59, 25, 26, 26, 27, 31, 33, 33, 33, 34, 34, 37, 67, 38, 39, 39,
124 40, 40, 41, 79, 43, 44, 45, 45, 48, 48, 64, 50, 51, 52, 88, 52,
125 53, 74, 55, 57, 58, 58, 74, 60, 101, 61, 62, 84, 66, 66, 68, 69,
126 87, 82, 71, 97, 73, 73, 82, 75, 111, 77, 94, 78, 87, 81, 83, 97,
127 85, 83, 94, 86, 99, 89, 90, 99, 111, 92, 93, 134, 95, 98, 105, 98,
128 105, 110, 102, 108, 102, 118, 103, 106, 106, 113, 109, 112, 114, 112, 116, 125,
129 115, 116, 117, 117, 126, 119, 125, 121, 121, 123, 145, 124, 126, 131, 127, 129,
130 165, 130, 132, 138, 133, 135, 145, 136, 137, 139, 146, 141, 143, 142, 144, 148,
131 147, 155, 151, 149, 151, 150, 152, 157, 153, 154, 156, 168, 158, 162, 161, 160,
132 172, 163, 169, 164, 166, 184, 167, 170, 177, 174, 171, 173, 182, 176, 180, 178,
133 175, 189, 179, 181, 186, 183, 192, 185, 200, 187, 191, 188, 190, 197, 193, 196,
134 197, 194, 195, 196, 198, 202, 199, 201, 210, 203, 207, 204, 205, 206, 208, 214,
135 209, 211, 221, 212, 213, 215, 224, 216, 217, 218, 219, 220, 222, 228, 223, 225,
136 226, 224, 227, 229, 240, 230, 231, 232, 233, 234, 235, 236, 238, 239, 237, 242,
137 241, 243, 242, 244, 245, 246, 247, 248, 249, 250, 251, 252, 252, 253, 254, 255,
156 #define MAX_SLICES 256
210 static inline int predict(int16_t *src, int16_t *last)
212 const int LT= last[-1];
213 const int T= last[ 0];
214 const int L = src[-1];
220 int16_t *last, int16_t *last2)
222 const int LT= last[-1];
223 const int T= last[ 0];
224 const int RT= last[ 1];
225 const int L = src[-1];
228 const int TT= last2[0];
229 const int LL= src[-2];
236 static void find_best_state(uint8_t best_state[256][256],
const uint8_t one_state[256]){
241 l2tab[i]=
log2(i/256.0);
243 for(i=0; i<256; i++){
244 double best_len[256];
254 for(k=0; k<256; k++){
255 double newocc[256]={0};
256 for(m=0; m<256; m++){
258 len -=occ[m]*( p *l2tab[ m]
259 + (1-p)*l2tab[256-m]);
262 if(len < best_len[k]){
266 for(m=0; m<256; m++){
268 newocc[ one_state[ m]] += occ[m]* p ;
269 newocc[256-one_state[256-m]] += occ[m]*(1-p);
272 memcpy(occ, newocc,
sizeof(occ));
281 #define put_rac(C,S,B) \
285 rc_stat2[(S)-state][B]++;\
292 const int e= av_log2(a);
300 for(i=e-1; i>=0; i--){
301 put_rac(c, state+22+i, (a>>i)&1);
305 put_rac(c, state+11 + e, v < 0);
312 for(i=e-1; i>=0; i--){
317 put_rac(c, state+11 + 10, v < 0);
340 for(i=e-1; i>=0; i--){
354 int drift= state->
drift;
355 int count= state->
count;
367 if(state->
bias > -128) state->
bias--;
373 if(state->
bias < 127) state->
bias++;
391 while(i < state->error_sum){
399 if(k==0 && 2*state->
drift <= - state->
count) code= v ^ (-1);
402 code= v ^ ((2*state->
drift + state->
count)>>31);
416 while(i < state->error_sum){
427 if(k==0 && 2*state->
drift <= - state->
count) v ^= (-1);
439 #if CONFIG_FFV1_ENCODER
442 int plane_index,
int bits)
466 context=
get_context(p, sample[0]+x, sample[1]+x, sample[2]+x);
467 diff= sample[0][x] -
predict(sample[0]+x, sample[1]+x);
474 diff=
fold(diff, bits);
483 if(context == 0) run_mode=1;
495 if(run_index) run_index--;
525 static void encode_plane(
FFV1Context *s, uint8_t *src,
int w,
int h,
int stride,
int plane_index){
534 for(i=0; i<ring_size; i++)
537 sample[0][-1]= sample[1][0 ];
538 sample[1][ w]= sample[1][w-1];
542 sample[0][x]= src[x + stride*y];
544 encode_line(s, w, sample, plane_index, 8);
555 static void encode_rgb_frame(
FFV1Context *s, uint32_t *src,
int w,
int h,
int stride){
558 int16_t *sample[3][3];
564 for(i=0; i<ring_size; i++)
566 sample[p][i]= s->
sample_buffer + p*ring_size*(w+6) + ((h+i-y)%ring_size)*(w+6) + 3;
569 int v= src[x + stride*y];
587 sample[p][0][-1]= sample[p][1][0 ];
588 sample[p][1][ w]= sample[p][1][w-1];
589 encode_line(s, w, sample[p],
FFMIN(p, 1), 9);
598 memset(state, 128,
sizeof(state));
600 for(i=1; i<128 ; i++){
601 if(quant_table[i] != quant_table[i-1]){
612 write_quant_table(c, quant_table[i]);
620 memset(state, 128,
sizeof(state));
626 for(i=1; i<256; i++){
697 for(j=1; j<256; j++){
725 memcpy(fs, f,
sizeof(*fs));
752 #if CONFIG_FFV1_ENCODER
759 memset(state2, 128,
sizeof(state2));
760 memset(state, 128,
sizeof(state));
769 for(i=1; i<256; i++){
808 static int sort_stt(
FFV1Context *s, uint8_t stt[256]){
809 int i,i2,changed,print=0;
813 for(i=12; i<244; i++){
814 for(i2=i+1; i2<245 && i2<i+4; i2++){
815 #define COST(old, new) \
816 s->rc_stat[old][0]*-log2((256-(new))/256.0)\
817 +s->rc_stat[old][1]*-log2( (new) /256.0)
819 #define COST2(old, new) \
821 +COST(256-(old), 256-(new))
823 double size0= COST2(i, i ) + COST2(i2, i2);
824 double sizeX= COST2(i, i2) + COST2(i2, i );
825 if(sizeX < size0 && i!=128 && i2!=128){
827 FFSWAP(
int, stt[ i], stt[ i2]);
831 FFSWAP(
int, stt[256-i], stt[256-i2]);
835 for(j=1; j<256; j++){
836 if (stt[j] == i ) stt[j] = i2;
837 else if(stt[j] == i2) stt[j] = i ;
839 if (stt[256-j] == 256-i ) stt[256-j] = 256-i2;
840 else if(stt[256-j] == 256-i2) stt[256-j] = 256-i ;
866 for(i=0; i<256; i++){
913 av_log(avctx,
AV_LOG_ERROR,
"bits_per_raw_sample of more than 8 needs -coder 1 currently\n");
944 uint8_t best_state[256][256];
951 for(j=0; j<256; j++){
953 s->
rc_stat[j][i]= strtol(p, &next, 0);
965 s->
rc_stat2[i][j][k][m]= strtol(p, &next, 0);
975 gob_count= strtol(p, &next, 0);
976 if(next==p || gob_count <0){
981 while(*p==
'\n' || *p==
' ') p++;
1004 write_extra_header(s);
1012 #define STATS_OUT_SIZE 1024*1024*6
1059 #if CONFIG_FFV1_ENCODER
1077 encode_plane(fs, p->
data[1] + cx+cy*p->
linesize[1], chroma_width, chroma_height, p->
linesize[1], 1);
1078 encode_plane(fs, p->
data[2] + cx+cy*p->
linesize[2], chroma_width, chroma_height, p->
linesize[2], 1);
1080 encode_rgb_frame(fs, (uint32_t*)(p->
data[0]) + x + y*(p->
linesize[0]/4), width, height, p->
linesize[0]/4);
1093 uint8_t keystate=128;
1120 for(i=1; i<256; i++){
1128 uint8_t *start= buf + (buf_size-used_count)*i/f->
slice_count;
1166 char *end= p + STATS_OUT_SIZE;
1174 for(i=0; i<256; i++){
1180 for(m=0; m<32; m++){
1188 for(j=0; j<256; j++){
1189 snprintf(p, end-p,
"%"PRIu64
" %"PRIu64
" ", f->
rc_stat[j][0], f->
rc_stat[j][1]);
1192 snprintf(p, end-p,
"\n");
1196 for(m=0; m<32; m++){
1197 snprintf(p, end-p,
"%"PRIu64
" %"PRIu64
" ", f->
rc_stat2[i][j][m][0], f->
rc_stat2[i][j][m][1]);
1202 snprintf(p, end-p,
"%d\n", f->
gob_count);
1248 int plane_index,
int bits)
1258 int diff, context, sign;
1260 context=
get_context(p, sample[1] + x, sample[0] + x, sample[1] + x);
1272 if(context == 0 && run_mode==0) run_mode=1;
1275 if(run_count==0 && run_mode==1){
1278 if(x + run_count <= w) run_index++;
1282 if(run_index) run_index--;
1300 if(sign) diff= -diff;
1302 sample[1][x]= (
predict(sample[1] + x, sample[0] + x) + diff) & ((1<<bits)-1);
1318 int16_t *temp = sample[0];
1320 sample[0]= sample[1];
1323 sample[1][-1]= sample[0][0 ];
1324 sample[0][ w]= sample[0][w-1];
1330 src[x + stride*y]= sample[1][x];
1344 int16_t *sample[3][2];
1356 int16_t *temp = sample[p][0];
1358 sample[p][0]= sample[p][1];
1361 sample[p][1][-1]= sample[p][0][0 ];
1362 sample[p][0][ w]= sample[p][0][w-1];
1366 int g= sample[0][1][x];
1367 int b= sample[1][1][x];
1368 int r= sample[2][1][x];
1379 src[x + stride*y]= b + (g<<8) + (r<<16) + (0xFF<<24);
1417 memset(state, 128,
sizeof(state));
1419 for(v=0; i<128 ; v++){
1422 if(len + i > 128)
return -1;
1425 quant_table[i] = scale*
v;
1432 for(i=1; i<128; i++){
1433 quant_table[256-i]= -quant_table[i];
1435 quant_table[128]= -quant_table[127];
1446 if(context_count > 32768
U){
1450 return (context_count+1)/2;
1459 memset(state2, 128,
sizeof(state2));
1460 memset(state, 128,
sizeof(state));
1468 for(i=1; i<256; i++){
1518 memset(state, 128,
sizeof(state));
1525 "invalid version %d in version 1 header\n", v);
1533 for (i = 1; i < 256; i++)
1599 if(context_count < 0){
1673 const uint8_t *buf = avpkt->
data;
1674 int buf_size = avpkt->
size;
1679 uint8_t keystate= 128;
1680 const uint8_t *buf_p;
1706 for(i=1; i<256; i++){
1730 buf_p= buf + buf_size;
1734 if(buf_p - buf <= v){
1767 #if CONFIG_FFV1_ENCODER
1777 .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},
static av_flatten int get_symbol_inline(RangeCoder *c, uint8_t *state, int is_signed)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int(* get_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of each frame to get a buffer for it.
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
static int read_quant_table(RangeCoder *c, int16_t *quant_table, int scale)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void ff_init_range_encoder(RangeCoder *c, uint8_t *buf, int buf_size)
static av_always_inline int fold(int diff, int bits)
static int read_quant_tables(RangeCoder *c, int16_t quant_table[MAX_CONTEXT_INPUTS][256])
static const uint8_t ver2_state[256]
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
int16_t quant_table[MAX_CONTEXT_INPUTS][256]
AVFrame * coded_frame
the picture in the bitstream
static av_cold int encode_init(AVCodecContext *avctx)
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
static int get_context(PlaneContext *p, int16_t *src, int16_t *last, int16_t *last2)
char * stats_in
pass2 encoding statistics input buffer Concatenated stuff from stats_out of pass1 should be placed he...
int(* decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt)
uint64_t(*[MAX_QUANT_TABLES] rc_stat2)[32][2]
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
#define CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
#define PIX_FMT_YUV422P16
int ff_rac_terminate(RangeCoder *c)
static int predict(int16_t *src, int16_t *last)
int context_model
context model
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
const uint8_t ff_log2_run[41]
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static int get_rac(RangeCoder *c, uint8_t *const state)
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
#define FF_DEBUG_PICT_INFO
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
#define PIX_FMT_YUV420P16
uint8_t(*[MAX_QUANT_TABLES] initial_states)[32]
static int read_header(FFV1Context *f)
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 int init_slice_state(FFV1Context *f)
bitstream reader API header.
static const int8_t quant9_10bit[256]
char * stats_out
pass1 encoding statistics output buffer
av_cold void dsputil_init(DSPContext *c, AVCodecContext *avctx)
static int init(AVCodecParserContext *s)
static void decode_rgb_frame(FFV1Context *s, uint32_t *src, int w, int h, int stride)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int decode_slice(AVCodecContext *c, void *arg)
static void decode_plane(FFV1Context *s, uint8_t *src, int w, int h, int stride, int plane_index)
#define CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
int16_t quant_tables[MAX_QUANT_TABLES][MAX_CONTEXT_INPUTS][256]
static const int8_t quant11[256]
int reference
is this picture used as reference The values for this are the same as the MpegEncContext.picture_structure variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
simple assert() macros that are a bit more flexible than ISO C assert().
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
static void put_bits(PutBitContext *s, int n, unsigned int value)
Write up to 31 bits into a bitstream.
static av_cold int common_init(AVCodecContext *avctx)
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static int put_bits_count(PutBitContext *s)
struct PlaneContext PlaneContext
static av_always_inline void emms_c(void)
Empty mmx state.
int ac
1=range coder <-> 0=golomb rice
int16_t quant_table[MAX_CONTEXT_INPUTS][256]
static int read_extra_header(FFV1Context *f)
uint8_t state_transition[256]
enum AVPictureType pict_type
Picture type of the frame, see ?_TYPE below.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
int width
picture width / height.
struct AVFrame AVFrame
Audio Video Frame.
static float quant_table[96]
void ff_build_rac_states(RangeCoder *c, int factor, int max_p)
static av_cold int init_slice_contexts(FFV1Context *f)
struct FFV1Context FFV1Context
static const int8_t quant5_10bit[256]
static const float pred[4]
void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *v_shift)
int context_count[MAX_QUANT_TABLES]
static int av_noinline get_symbol(RangeCoder *c, uint8_t *state, int is_signed)
static void av_noinline put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signed)
int AC3_NAME() encode_frame(AVCodecContext *avctx, unsigned char *frame, int buf_size, void *data)
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
static const int8_t quant5[256]
main external API structure.
static void close(AVCodecParserContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static unsigned int get_bits1(GetBitContext *s)
static void find_best_state(uint8_t best_state[256][256], const uint8_t one_state[256])
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static av_cold int common_end(AVCodecContext *avctx)
static void set_sr_golomb(PutBitContext *pb, int i, int k, int limit, int esc_len)
write signed golomb rice code (ffv1).
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
void ff_init_range_decoder(RangeCoder *c, const uint8_t *buf, int buf_size)
static av_cold int decode_init(AVCodecContext *avctx)
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
static const uint16_t scale[4]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AV_WL32 AV_WL24 AV_WL16 AV_WB32 AV_RB24
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
#define PIX_FMT_YUV444P16
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static int get_vlc_symbol(GetBitContext *gb, VlcState *const state, int bits)
uint8_t(* state)[CONTEXT_SIZE]
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
uint8_t * bytestream_start
PlaneContext plane[MAX_PLANES]
int(* execute)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size)
The codec may call this to execute several independent things.
static int allocate_initial_states(FFV1Context *f)
#define CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
int key_frame
1 -> keyframe, 0-> not
struct FFV1Context * slice_context[MAX_SLICES]
static av_always_inline void decode_line(FFV1Context *s, int w, int16_t *sample[2], int plane_index, int bits)
static void put_vlc_symbol(PutBitContext *pb, VlcState *const state, int v, int bits)
uint8_t interlace_bit_state[2]
#define FFSWAP(type, a, b)
enum AVColorSpace colorspace
static void clear_state(FFV1Context *f)
static void update_vlc_state(VlcState *const state, const int v)
static int get_sr_golomb(GetBitContext *gb, int k, int limit, int esc_len)
read signed golomb rice code (ffv1).
#define MAX_CONTEXT_INPUTS