Mercurial > libavcodec.hg
comparison ffv1.c @ 7146:d3a1ac3e227b libavcodec
move ff_log2_run to bitstream.c and reuse in ffv1.c
author | stefang |
---|---|
date | Thu, 26 Jun 2008 16:39:21 +0000 |
parents | e943e1409077 |
children | 6efb15a24e91 |
comparison
equal
deleted
inserted
replaced
7145:8c367046eb81 | 7146:d3a1ac3e227b |
---|---|
31 #include "rangecoder.h" | 31 #include "rangecoder.h" |
32 #include "golomb.h" | 32 #include "golomb.h" |
33 | 33 |
34 #define MAX_PLANES 4 | 34 #define MAX_PLANES 4 |
35 #define CONTEXT_SIZE 32 | 35 #define CONTEXT_SIZE 32 |
36 | |
37 extern const uint8_t ff_log2_run[32]; | |
36 | 38 |
37 static const int8_t quant3[256]={ | 39 static const int8_t quant3[256]={ |
38 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 40 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
39 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 41 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
40 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 42 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
141 -5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5, | 143 -5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5, |
142 -5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5, | 144 -5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5, |
143 -4,-4,-4,-4,-4,-4,-4,-4,-4,-3,-3,-3,-3,-2,-2,-1, | 145 -4,-4,-4,-4,-4,-4,-4,-4,-4,-3,-3,-3,-3,-2,-2,-1, |
144 }; | 146 }; |
145 | 147 |
146 static const uint8_t log2_run[32]={ | |
147 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, | |
148 4, 4, 5, 5, 6, 6, 7, 7, | |
149 8, 9,10,11,12,13,14,15, | |
150 }; | |
151 | |
152 typedef struct VlcState{ | 148 typedef struct VlcState{ |
153 int16_t drift; | 149 int16_t drift; |
154 uint16_t error_sum; | 150 uint16_t error_sum; |
155 int8_t bias; | 151 int8_t bias; |
156 uint8_t count; | 152 uint8_t count; |
394 if(context == 0) run_mode=1; | 390 if(context == 0) run_mode=1; |
395 | 391 |
396 if(run_mode){ | 392 if(run_mode){ |
397 | 393 |
398 if(diff){ | 394 if(diff){ |
399 while(run_count >= 1<<log2_run[run_index]){ | 395 while(run_count >= 1<<ff_log2_run[run_index]){ |
400 run_count -= 1<<log2_run[run_index]; | 396 run_count -= 1<<ff_log2_run[run_index]; |
401 run_index++; | 397 run_index++; |
402 put_bits(&s->pb, 1, 1); | 398 put_bits(&s->pb, 1, 1); |
403 } | 399 } |
404 | 400 |
405 put_bits(&s->pb, 1 + log2_run[run_index], run_count); | 401 put_bits(&s->pb, 1 + ff_log2_run[run_index], run_count); |
406 if(run_index) run_index--; | 402 if(run_index) run_index--; |
407 run_count=0; | 403 run_count=0; |
408 run_mode=0; | 404 run_mode=0; |
409 if(diff>0) diff--; | 405 if(diff>0) diff--; |
410 }else{ | 406 }else{ |
417 if(run_mode == 0) | 413 if(run_mode == 0) |
418 put_vlc_symbol(&s->pb, &p->vlc_state[context], diff, bits); | 414 put_vlc_symbol(&s->pb, &p->vlc_state[context], diff, bits); |
419 } | 415 } |
420 } | 416 } |
421 if(run_mode){ | 417 if(run_mode){ |
422 while(run_count >= 1<<log2_run[run_index]){ | 418 while(run_count >= 1<<ff_log2_run[run_index]){ |
423 run_count -= 1<<log2_run[run_index]; | 419 run_count -= 1<<ff_log2_run[run_index]; |
424 run_index++; | 420 run_index++; |
425 put_bits(&s->pb, 1, 1); | 421 put_bits(&s->pb, 1, 1); |
426 } | 422 } |
427 | 423 |
428 if(run_count) | 424 if(run_count) |
733 if(context == 0 && run_mode==0) run_mode=1; | 729 if(context == 0 && run_mode==0) run_mode=1; |
734 | 730 |
735 if(run_mode){ | 731 if(run_mode){ |
736 if(run_count==0 && run_mode==1){ | 732 if(run_count==0 && run_mode==1){ |
737 if(get_bits1(&s->gb)){ | 733 if(get_bits1(&s->gb)){ |
738 run_count = 1<<log2_run[run_index]; | 734 run_count = 1<<ff_log2_run[run_index]; |
739 if(x + run_count <= w) run_index++; | 735 if(x + run_count <= w) run_index++; |
740 }else{ | 736 }else{ |
741 if(log2_run[run_index]) run_count = get_bits(&s->gb, log2_run[run_index]); | 737 if(ff_log2_run[run_index]) run_count = get_bits(&s->gb, ff_log2_run[run_index]); |
742 else run_count=0; | 738 else run_count=0; |
743 if(run_index) run_index--; | 739 if(run_index) run_index--; |
744 run_mode=2; | 740 run_mode=2; |
745 } | 741 } |
746 } | 742 } |