Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: source/libvpx/vp8/encoder/bitstream.c

Issue 7671004: Update libvpx snapshot to v0.9.7-p1 (Cayuga). (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp8/encoder/asm_enc_offsets.c ('k') | source/libvpx/vp8/encoder/block.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 11
12 #include "vp8/common/header.h" 12 #include "vp8/common/header.h"
13 #include "encodemv.h" 13 #include "encodemv.h"
14 #include "vp8/common/entropymode.h" 14 #include "vp8/common/entropymode.h"
15 #include "vp8/common/findnearmv.h" 15 #include "vp8/common/findnearmv.h"
16 #include "mcomp.h" 16 #include "mcomp.h"
17 #include "vp8/common/systemdependent.h" 17 #include "vp8/common/systemdependent.h"
18 #include <assert.h> 18 #include <assert.h>
19 #include <stdio.h> 19 #include <stdio.h>
20 #include <limits.h>
20 #include "vp8/common/pragmas.h" 21 #include "vp8/common/pragmas.h"
22 #include "vpx/vpx_encoder.h"
21 #include "vpx_mem/vpx_mem.h" 23 #include "vpx_mem/vpx_mem.h"
22 #include "bitstream.h" 24 #include "bitstream.h"
25 #include "vp8/common/defaultcoefcounts.h"
23 26
24 const int vp8cx_base_skip_false_prob[128] = 27 const int vp8cx_base_skip_false_prob[128] =
25 { 28 {
26 255, 255, 255, 255, 255, 255, 255, 255, 29 255, 255, 255, 255, 255, 255, 255, 255,
27 255, 255, 255, 255, 255, 255, 255, 255, 30 255, 255, 255, 255, 255, 255, 255, 255,
28 255, 255, 255, 255, 255, 255, 255, 255, 31 255, 255, 255, 255, 255, 255, 255, 255,
29 255, 255, 255, 255, 255, 255, 255, 255, 32 255, 255, 255, 255, 255, 255, 255, 255,
30 255, 255, 255, 255, 255, 255, 255, 255, 33 255, 255, 255, 255, 255, 255, 255, 255,
31 255, 255, 255, 255, 255, 255, 255, 255, 34 255, 255, 255, 255, 255, 255, 255, 255,
32 255, 255, 255, 255, 255, 255, 255, 255, 35 255, 255, 255, 255, 255, 255, 255, 255,
33 251, 248, 244, 240, 236, 232, 229, 225, 36 251, 248, 244, 240, 236, 232, 229, 225,
34 221, 217, 213, 208, 204, 199, 194, 190, 37 221, 217, 213, 208, 204, 199, 194, 190,
35 187, 183, 179, 175, 172, 168, 164, 160, 38 187, 183, 179, 175, 172, 168, 164, 160,
36 157, 153, 149, 145, 142, 138, 134, 130, 39 157, 153, 149, 145, 142, 138, 134, 130,
37 127, 124, 120, 117, 114, 110, 107, 104, 40 127, 124, 120, 117, 114, 110, 107, 104,
38 101, 98, 95, 92, 89, 86, 83, 80, 41 101, 98, 95, 92, 89, 86, 83, 80,
39 77, 74, 71, 68, 65, 62, 59, 56, 42 77, 74, 71, 68, 65, 62, 59, 56,
40 53, 50, 47, 44, 41, 38, 35, 32, 43 53, 50, 47, 44, 41, 38, 35, 32,
41 30, 28, 26, 24, 22, 20, 18, 16, 44 30, 28, 26, 24, 22, 20, 18, 16,
42 }; 45 };
43 #ifdef VP8REF
44 #define __int64 long long
45 #endif
46 46
47 #if defined(SECTIONBITS_OUTPUT) 47 #if defined(SECTIONBITS_OUTPUT)
48 unsigned __int64 Sectionbits[500]; 48 unsigned __int64 Sectionbits[500];
49 #endif 49 #endif
50 50
51 #ifdef ENTROPY_STATS 51 #ifdef ENTROPY_STATS
52 int intra_mode_stats[10][10][10]; 52 int intra_mode_stats[10][10][10];
53 static unsigned int tree_update_hist [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTE XTS] [vp8_coef_tokens-1] [2]; 53 static unsigned int tree_update_hist [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTE XTS] [ENTROPY_NODES] [2];
54 extern unsigned int active_section; 54 extern unsigned int active_section;
55 #endif 55 #endif
56 56
57 #ifdef MODE_STATS 57 #ifdef MODE_STATS
58 int count_mb_seg[4] = { 0, 0, 0, 0 }; 58 int count_mb_seg[4] = { 0, 0, 0, 0 };
59 #endif 59 #endif
60 60
61 61
62 static void update_mode( 62 static void update_mode(
63 vp8_writer *const w, 63 vp8_writer *const w,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 vp8_write_token(bc, vp8_bmode_tree, p, vp8_bmode_encodings + m); 151 vp8_write_token(bc, vp8_bmode_tree, p, vp8_bmode_encodings + m);
152 } 152 }
153 153
154 static void write_split(vp8_writer *bc, int x) 154 static void write_split(vp8_writer *bc, int x)
155 { 155 {
156 vp8_write_token( 156 vp8_write_token(
157 bc, vp8_mbsplit_tree, vp8_mbsplit_probs, vp8_mbsplit_encodings + x 157 bc, vp8_mbsplit_tree, vp8_mbsplit_probs, vp8_mbsplit_encodings + x
158 ); 158 );
159 } 159 }
160 160
161 static const unsigned int norm[256] =
162 {
163 0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 , 3, 3, 3, 3, 3, 3,
164 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 , 2, 2, 2, 2, 2, 2,
165 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 , 1, 1, 1, 1, 1, 1,
166 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 , 1, 1, 1, 1, 1, 1,
167 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0,
168 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0,
169 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0,
170 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0
171 };
172
173 static void pack_tokens_c(vp8_writer *w, const TOKENEXTRA *p, int xcount) 161 static void pack_tokens_c(vp8_writer *w, const TOKENEXTRA *p, int xcount)
174 { 162 {
175 const TOKENEXTRA *const stop = p + xcount; 163 const TOKENEXTRA *const stop = p + xcount;
176 unsigned int split; 164 unsigned int split;
177 unsigned int shift; 165 unsigned int shift;
178 int count = w->count; 166 int count = w->count;
179 unsigned int range = w->range; 167 unsigned int range = w->range;
180 unsigned int lowvalue = w->lowvalue; 168 unsigned int lowvalue = w->lowvalue;
181 169
182 while (p < stop) 170 while (p < stop)
(...skipping 21 matching lines...) Expand all
204 if (bb) 192 if (bb)
205 { 193 {
206 lowvalue += split; 194 lowvalue += split;
207 range = range - split; 195 range = range - split;
208 } 196 }
209 else 197 else
210 { 198 {
211 range = split; 199 range = split;
212 } 200 }
213 201
214 shift = norm[range]; 202 shift = vp8_norm[range];
215 range <<= shift; 203 range <<= shift;
216 count += shift; 204 count += shift;
217 205
218 if (count >= 0) 206 if (count >= 0)
219 { 207 {
220 int offset = shift - count; 208 int offset = shift - count;
221 209
222 if ((lowvalue << (offset - 1)) & 0x80000000) 210 if ((lowvalue << (offset - 1)) & 0x80000000)
223 { 211 {
224 int x = w->pos - 1; 212 int x = w->pos - 1;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 if (bb) 252 if (bb)
265 { 253 {
266 lowvalue += split; 254 lowvalue += split;
267 range = range - split; 255 range = range - split;
268 } 256 }
269 else 257 else
270 { 258 {
271 range = split; 259 range = split;
272 } 260 }
273 261
274 shift = norm[range]; 262 shift = vp8_norm[range];
275 range <<= shift; 263 range <<= shift;
276 count += shift; 264 count += shift;
277 265
278 if (count >= 0) 266 if (count >= 0)
279 { 267 {
280 int offset = shift - count; 268 int offset = shift - count;
281 269
282 if ((lowvalue << (offset - 1)) & 0x80000000) 270 if ((lowvalue << (offset - 1)) & 0x80000000)
283 { 271 {
284 int x = w->pos - 1; 272 int x = w->pos - 1;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 } 358 }
371 359
372 static void pack_tokens_into_partitions_c(VP8_COMP *cpi, unsigned char *cx_data, int num_part, int *size) 360 static void pack_tokens_into_partitions_c(VP8_COMP *cpi, unsigned char *cx_data, int num_part, int *size)
373 { 361 {
374 362
375 int i; 363 int i;
376 unsigned char *ptr = cx_data; 364 unsigned char *ptr = cx_data;
377 unsigned int shift; 365 unsigned int shift;
378 vp8_writer *w = &cpi->bc2; 366 vp8_writer *w = &cpi->bc2;
379 *size = 3 * (num_part - 1); 367 *size = 3 * (num_part - 1);
368 cpi->partition_sz[0] += *size;
380 ptr = cx_data + (*size); 369 ptr = cx_data + (*size);
381 370
382 for (i = 0; i < num_part; i++) 371 for (i = 0; i < num_part; i++)
383 { 372 {
384 vp8_start_encode(w, ptr); 373 vp8_start_encode(w, ptr);
385 { 374 {
386 unsigned int split; 375 unsigned int split;
387 int count = w->count; 376 int count = w->count;
388 unsigned int range = w->range; 377 unsigned int range = w->range;
389 unsigned int lowvalue = w->lowvalue; 378 unsigned int lowvalue = w->lowvalue;
(...skipping 29 matching lines...) Expand all
419 if (bb) 408 if (bb)
420 { 409 {
421 lowvalue += split; 410 lowvalue += split;
422 range = range - split; 411 range = range - split;
423 } 412 }
424 else 413 else
425 { 414 {
426 range = split; 415 range = split;
427 } 416 }
428 417
429 shift = norm[range]; 418 shift = vp8_norm[range];
430 range <<= shift; 419 range <<= shift;
431 count += shift; 420 count += shift;
432 421
433 if (count >= 0) 422 if (count >= 0)
434 { 423 {
435 int offset = shift - count; 424 int offset = shift - count;
436 425
437 if ((lowvalue << (offset - 1)) & 0x80000000) 426 if ((lowvalue << (offset - 1)) & 0x80000000)
438 { 427 {
439 int x = w->pos - 1; 428 int x = w->pos - 1;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 if (bb) 468 if (bb)
480 { 469 {
481 lowvalue += split; 470 lowvalue += split;
482 range = range - split; 471 range = range - split;
483 } 472 }
484 else 473 else
485 { 474 {
486 range = split; 475 range = split;
487 } 476 }
488 477
489 shift = norm[range]; 478 shift = vp8_norm[range];
490 range <<= shift; 479 range <<= shift;
491 count += shift; 480 count += shift;
492 481
493 if (count >= 0) 482 if (count >= 0)
494 { 483 {
495 int offset = shift - count; 484 int offset = shift - count;
496 485
497 if ((lowvalue << (offset - 1)) & 0x80000000) 486 if ((lowvalue << (offset - 1)) & 0x80000000)
498 { 487 {
499 int x = w->pos - 1; 488 int x = w->pos - 1;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 555
567 w->count = count; 556 w->count = count;
568 w->lowvalue = lowvalue; 557 w->lowvalue = lowvalue;
569 w->range = range; 558 w->range = range;
570 559
571 } 560 }
572 561
573 vp8_stop_encode(w); 562 vp8_stop_encode(w);
574 *size += w->pos; 563 *size += w->pos;
575 564
565 /* The first partition size is set earlier */
566 cpi->partition_sz[i + 1] = w->pos;
567
576 if (i < (num_part - 1)) 568 if (i < (num_part - 1))
577 { 569 {
578 write_partition_size(cx_data, w->pos); 570 write_partition_size(cx_data, w->pos);
579 cx_data += 3; 571 cx_data += 3;
580 ptr += w->pos; 572 ptr += w->pos;
581 } 573 }
582 } 574 }
583 } 575 }
584 576
585 577
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 if (bb) 615 if (bb)
624 { 616 {
625 lowvalue += split; 617 lowvalue += split;
626 range = range - split; 618 range = range - split;
627 } 619 }
628 else 620 else
629 { 621 {
630 range = split; 622 range = split;
631 } 623 }
632 624
633 shift = norm[range]; 625 shift = vp8_norm[range];
634 range <<= shift; 626 range <<= shift;
635 count += shift; 627 count += shift;
636 628
637 if (count >= 0) 629 if (count >= 0)
638 { 630 {
639 int offset = shift - count; 631 int offset = shift - count;
640 632
641 if ((lowvalue << (offset - 1)) & 0x80000000) 633 if ((lowvalue << (offset - 1)) & 0x80000000)
642 { 634 {
643 int x = w->pos - 1; 635 int x = w->pos - 1;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 if (bb) 675 if (bb)
684 { 676 {
685 lowvalue += split; 677 lowvalue += split;
686 range = range - split; 678 range = range - split;
687 } 679 }
688 else 680 else
689 { 681 {
690 range = split; 682 range = split;
691 } 683 }
692 684
693 shift = norm[range]; 685 shift = vp8_norm[range];
694 range <<= shift; 686 range <<= shift;
695 count += shift; 687 count += shift;
696 688
697 if (count >= 0) 689 if (count >= 0)
698 { 690 {
699 int offset = shift - count; 691 int offset = shift - count;
700 692
701 if ((lowvalue << (offset - 1)) & 0x80000000) 693 if ((lowvalue << (offset - 1)) & 0x80000000)
702 { 694 {
703 int x = w->pos - 1; 695 int x = w->pos - 1;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 w->lowvalue = lowvalue; 764 w->lowvalue = lowvalue;
773 w->range = range; 765 w->range = range;
774 766
775 } 767 }
776 768
777 static void write_mv_ref 769 static void write_mv_ref
778 ( 770 (
779 vp8_writer *w, MB_PREDICTION_MODE m, const vp8_prob *p 771 vp8_writer *w, MB_PREDICTION_MODE m, const vp8_prob *p
780 ) 772 )
781 { 773 {
782 774 #if CONFIG_DEBUG
783 assert(NEARESTMV <= m && m <= SPLITMV); 775 assert(NEARESTMV <= m && m <= SPLITMV);
784 776 #endif
785 vp8_write_token(w, vp8_mv_ref_tree, p, 777 vp8_write_token(w, vp8_mv_ref_tree, p,
786 vp8_mv_ref_encoding_array - NEARESTMV + m); 778 vp8_mv_ref_encoding_array - NEARESTMV + m);
787 } 779 }
788 780
789 static void write_sub_mv_ref 781 static void write_sub_mv_ref
790 ( 782 (
791 vp8_writer *w, B_PREDICTION_MODE m, const vp8_prob *p 783 vp8_writer *w, B_PREDICTION_MODE m, const vp8_prob *p
792 ) 784 )
793 { 785 {
786 #if CONFIG_DEBUG
794 assert(LEFT4X4 <= m && m <= NEW4X4); 787 assert(LEFT4X4 <= m && m <= NEW4X4);
795 788 #endif
796 vp8_write_token(w, vp8_sub_mv_ref_tree, p, 789 vp8_write_token(w, vp8_sub_mv_ref_tree, p,
797 vp8_sub_mv_ref_encoding_array - LEFT4X4 + m); 790 vp8_sub_mv_ref_encoding_array - LEFT4X4 + m);
798 } 791 }
799 792
800 static void write_mv 793 static void write_mv
801 ( 794 (
802 vp8_writer *w, const MV *mv, const MV *ref, const MV_CONTEXT *mvc 795 vp8_writer *w, const MV *mv, const int_mv *ref, const MV_CONTEXT *mvc
803 ) 796 )
804 { 797 {
805 MV e; 798 MV e;
806 e.row = mv->row - ref->row; 799 e.row = mv->row - ref->as_mv.row;
807 e.col = mv->col - ref->col; 800 e.col = mv->col - ref->as_mv.col;
808 801
809 vp8_encode_motion_vector(w, &e, mvc); 802 vp8_encode_motion_vector(w, &e, mvc);
810 } 803 }
811 804
812 static void write_mb_features(vp8_writer *w, const MB_MODE_INFO *mi, const MACRO BLOCKD *x) 805 static void write_mb_features(vp8_writer *w, const MB_MODE_INFO *mi, const MACRO BLOCKD *x)
813 { 806 {
814 // Encode the MB segment id. 807 // Encode the MB segment id.
815 if (x->segmentation_enabled && x->update_mb_segmentation_map) 808 if (x->segmentation_enabled && x->update_mb_segmentation_map)
816 { 809 {
817 switch (mi->segment_id) 810 switch (mi->segment_id)
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 #ifdef ENTROPY_STATS 934 #ifdef ENTROPY_STATS
942 active_section = 6; 935 active_section = 6;
943 #endif 936 #endif
944 write_ymode(w, mode, pc->fc.ymode_prob); 937 write_ymode(w, mode, pc->fc.ymode_prob);
945 938
946 if (mode == B_PRED) 939 if (mode == B_PRED)
947 { 940 {
948 int j = 0; 941 int j = 0;
949 942
950 do 943 do
951 write_bmode(w, m->bmi[j].mode, pc->fc.bmode_prob); 944 write_bmode(w, m->bmi[j].as_mode, pc->fc.bmode_prob);
952
953 while (++j < 16); 945 while (++j < 16);
954 } 946 }
955 947
956 write_uv_mode(w, mi->uv_mode, pc->fc.uv_mode_prob); 948 write_uv_mode(w, mi->uv_mode, pc->fc.uv_mode_prob);
957 } 949 }
958 else /* inter coded */ 950 else /* inter coded */
959 { 951 {
960 MV best_mv; 952 int_mv best_mv;
961 vp8_prob mv_ref_p [VP8_MVREFS-1]; 953 vp8_prob mv_ref_p [VP8_MVREFS-1];
962 954
963 vp8_write(w, 1, cpi->prob_intra_coded); 955 vp8_write(w, 1, cpi->prob_intra_coded);
964 956
965 if (rf == LAST_FRAME) 957 if (rf == LAST_FRAME)
966 vp8_write(w, 0, prob_last_coded); 958 vp8_write(w, 0, prob_last_coded);
967 else 959 else
968 { 960 {
969 vp8_write(w, 1, prob_last_coded); 961 vp8_write(w, 1, prob_last_coded);
970 vp8_write(w, (rf == GOLDEN_FRAME) ? 0 : 1, prob_gf_coded); 962 vp8_write(w, (rf == GOLDEN_FRAME) ? 0 : 1, prob_gf_coded);
971 } 963 }
972 964
973 { 965 {
974 MV n1, n2; 966 int_mv n1, n2;
975 int ct[4]; 967 int ct[4];
976 968
977 vp8_find_near_mvs(xd, m, &n1, &n2, &best_mv, ct, rf, cpi->co mmon.ref_frame_sign_bias); 969 vp8_find_near_mvs(xd, m, &n1, &n2, &best_mv, ct, rf, cpi->co mmon.ref_frame_sign_bias);
978 vp8_mv_ref_probs(mv_ref_p, ct); 970 vp8_mv_ref_probs(mv_ref_p, ct);
979 971
980 #ifdef ENTROPY_STATS 972 #ifdef ENTROPY_STATS
981 accum_mv_refs(mode, ct); 973 accum_mv_refs(mode, ct);
982 #endif 974 #endif
983 975
984 } 976 }
(...skipping 20 matching lines...) Expand all
1005 int j = 0; 997 int j = 0;
1006 998
1007 #ifdef MODE_STATS 999 #ifdef MODE_STATS
1008 ++count_mb_seg [mi->partitioning]; 1000 ++count_mb_seg [mi->partitioning];
1009 #endif 1001 #endif
1010 1002
1011 write_split(w, mi->partitioning); 1003 write_split(w, mi->partitioning);
1012 1004
1013 do 1005 do
1014 { 1006 {
1015 const B_MODE_INFO *const b = cpi->mb.partition_info->bmi + j; 1007 B_PREDICTION_MODE blockmode;
1008 int_mv blockmv;
1016 const int *const L = vp8_mbsplits [mi->partitioning]; 1009 const int *const L = vp8_mbsplits [mi->partitioning];
1017 int k = -1; /* first block in subset j */ 1010 int k = -1; /* first block in subset j */
1018 int mv_contz; 1011 int mv_contz;
1012 int_mv leftmv, abovemv;
1019 1013
1014 blockmode = cpi->mb.partition_info->bmi[j].mode;
1015 blockmv = cpi->mb.partition_info->bmi[j].mv;
1016 #if CONFIG_DEBUG
1020 while (j != L[++k]) 1017 while (j != L[++k])
1021 if (k >= 16) 1018 if (k >= 16)
1022 assert(0); 1019 assert(0);
1020 #else
1021 while (j != L[++k]);
1022 #endif
1023 leftmv.as_int = left_block_mv(m, k);
1024 abovemv.as_int = above_block_mv(m, k, mis);
1025 mv_contz = vp8_mv_cont(&leftmv, &abovemv);
1023 1026
1024 mv_contz = vp8_mv_cont 1027 write_sub_mv_ref(w, blockmode, vp8_sub_mv_ref_prob2 [mv_ contz]);
1025 (&(vp8_left_bmi(m, k)->mv.as_mv),
1026 &(vp8_above_bmi(m, k, mis)->mv.as_mv));
1027 write_sub_mv_ref(w, b->mode, vp8_sub_mv_ref_prob2 [mv_co ntz]); //pc->fc.sub_mv_ref_prob);
1028 1028
1029 if (b->mode == NEW4X4) 1029 if (blockmode == NEW4X4)
1030 { 1030 {
1031 #ifdef ENTROPY_STATS 1031 #ifdef ENTROPY_STATS
1032 active_section = 11; 1032 active_section = 11;
1033 #endif 1033 #endif
1034 write_mv(w, &b->mv.as_mv, &best_mv, (const MV_CONTEX T *) mvc); 1034 write_mv(w, &blockmv.as_mv, &best_mv, (const MV_CONT EXT *) mvc);
1035 } 1035 }
1036 } 1036 }
1037 while (++j < cpi->mb.partition_info->count); 1037 while (++j < cpi->mb.partition_info->count);
1038 } 1038 }
1039 break; 1039 break;
1040 default: 1040 default:
1041 break; 1041 break;
1042 } 1042 }
1043 } 1043 }
1044 1044
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 1092
1093 kfwrite_ymode(bc, ym, c->kf_ymode_prob); 1093 kfwrite_ymode(bc, ym, c->kf_ymode_prob);
1094 1094
1095 if (ym == B_PRED) 1095 if (ym == B_PRED)
1096 { 1096 {
1097 const int mis = c->mode_info_stride; 1097 const int mis = c->mode_info_stride;
1098 int i = 0; 1098 int i = 0;
1099 1099
1100 do 1100 do
1101 { 1101 {
1102 const B_PREDICTION_MODE A = vp8_above_bmi(m, i, mis)->mode; 1102 const B_PREDICTION_MODE A = above_block_mode(m, i, mis);
1103 const B_PREDICTION_MODE L = vp8_left_bmi(m, i)->mode; 1103 const B_PREDICTION_MODE L = left_block_mode(m, i);
1104 const int bm = m->bmi[i].mode; 1104 const int bm = m->bmi[i].as_mode;
1105 1105
1106 #ifdef ENTROPY_STATS 1106 #ifdef ENTROPY_STATS
1107 ++intra_mode_stats [A] [L] [bm]; 1107 ++intra_mode_stats [A] [L] [bm];
1108 #endif 1108 #endif
1109 1109
1110 write_bmode(bc, bm, c->kf_bmode_prob [A] [L]); 1110 write_bmode(bc, bm, c->kf_bmode_prob [A] [L]);
1111 } 1111 }
1112 while (++i < 16); 1112 while (++i < 16);
1113 } 1113 }
1114 1114
1115 write_uv_mode(bc, (m++)->mbmi.uv_mode, c->kf_uv_mode_prob); 1115 write_uv_mode(bc, (m++)->mbmi.uv_mode, c->kf_uv_mode_prob);
1116 } 1116 }
1117 1117
1118 m++; // skip L prediction border 1118 m++; // skip L prediction border
1119 } 1119 }
1120 } 1120 }
1121
1122 /* This function is used for debugging probability trees. */
1123 static void print_prob_tree(vp8_prob
1124 coef_probs[BLOCK_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES])
1125 {
1126 /* print coef probability tree */
1127 int i,j,k,l;
1128 FILE* f = fopen("enc_tree_probs.txt", "a");
1129 fprintf(f, "{\n");
1130 for (i = 0; i < BLOCK_TYPES; i++)
1131 {
1132 fprintf(f, " {\n");
1133 for (j = 0; j < COEF_BANDS; j++)
1134 {
1135 fprintf(f, " {\n");
1136 for (k = 0; k < PREV_COEF_CONTEXTS; k++)
1137 {
1138 fprintf(f, " {");
1139 for (l = 0; l < ENTROPY_NODES; l++)
1140 {
1141 fprintf(f, "%3u, ",
1142 (unsigned int)(coef_probs [i][j][k][l]));
1143 }
1144 fprintf(f, " }\n");
1145 }
1146 fprintf(f, " }\n");
1147 }
1148 fprintf(f, " }\n");
1149 }
1150 fprintf(f, "}\n");
1151 fclose(f);
1152 }
1153
1154 static void sum_probs_over_prev_coef_context(
1155 const unsigned int probs[PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS],
1156 unsigned int* out)
1157 {
1158 int i, j;
1159 for (i=0; i < MAX_ENTROPY_TOKENS; ++i)
1160 {
1161 for (j=0; j < PREV_COEF_CONTEXTS; ++j)
1162 {
1163 const int tmp = out[i];
1164 out[i] += probs[j][i];
1165 /* check for wrap */
1166 if (out[i] < tmp)
1167 out[i] = UINT_MAX;
1168 }
1169 }
1170 }
1171
1172 static int prob_update_savings(const unsigned int *ct,
1173 const vp8_prob oldp, const vp8_prob newp,
1174 const vp8_prob upd)
1175 {
1176 const int old_b = vp8_cost_branch(ct, oldp);
1177 const int new_b = vp8_cost_branch(ct, newp);
1178 const int update_b = 8 +
1179 ((vp8_cost_one(upd) - vp8_cost_zero(upd)) >> 8);
1180
1181 return old_b - new_b - update_b;
1182 }
1183
1184 static int independent_coef_context_savings(VP8_COMP *cpi)
1185 {
1186 int savings = 0;
1187 int i = 0;
1188 do
1189 {
1190 int j = 0;
1191 do
1192 {
1193 int k = 0;
1194 unsigned int prev_coef_count_sum[MAX_ENTROPY_TOKENS] = {0};
1195 int prev_coef_savings[MAX_ENTROPY_TOKENS] = {0};
1196 /* Calculate new probabilities given the constraint that
1197 * they must be equal over the prev coef contexts
1198 */
1199 if (cpi->common.frame_type == KEY_FRAME)
1200 {
1201 /* Reset to default probabilities at key frames */
1202 sum_probs_over_prev_coef_context(vp8_default_coef_counts[i][j],
1203 prev_coef_count_sum);
1204 }
1205 else
1206 {
1207 sum_probs_over_prev_coef_context(cpi->coef_counts[i][j],
1208 prev_coef_count_sum);
1209 }
1210 do
1211 {
1212 /* at every context */
1213
1214 /* calc probs and branch cts for this frame only */
1215 //vp8_prob new_p [ENTROPY_NODES];
1216 //unsigned int branch_ct [ENTROPY_NODES] [2];
1217
1218 int t = 0; /* token/prob index */
1219
1220 vp8_tree_probs_from_distribution(
1221 MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
1222 cpi->frame_coef_probs[i][j][k],
1223 cpi->frame_branch_ct [i][j][k],
1224 prev_coef_count_sum,
1225 256, 1);
1226
1227 do
1228 {
1229 const unsigned int *ct = cpi->frame_branch_ct [i][j][k][t];
1230 const vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
1231 const vp8_prob oldp = cpi->common.fc.coef_probs [i][j][k][t] ;
1232 const vp8_prob upd = vp8_coef_update_probs [i][j][k][t];
1233 const int s = prob_update_savings(ct, oldp, newp, upd);
1234
1235 if (cpi->common.frame_type != KEY_FRAME ||
1236 (cpi->common.frame_type == KEY_FRAME && newp != oldp))
1237 prev_coef_savings[t] += s;
1238 }
1239 while (++t < ENTROPY_NODES);
1240 }
1241 while (++k < PREV_COEF_CONTEXTS);
1242 k = 0;
1243 do
1244 {
1245 /* We only update probabilities if we can save bits, except
1246 * for key frames where we have to update all probabilities
1247 * to get the equal probabilities across the prev coef
1248 * contexts.
1249 */
1250 if (prev_coef_savings[k] > 0 ||
1251 cpi->common.frame_type == KEY_FRAME)
1252 savings += prev_coef_savings[k];
1253 }
1254 while (++k < ENTROPY_NODES);
1255 }
1256 while (++j < COEF_BANDS);
1257 }
1258 while (++i < BLOCK_TYPES);
1259 return savings;
1260 }
1261
1262 static int default_coef_context_savings(VP8_COMP *cpi)
1263 {
1264 int savings = 0;
1265 int i = 0;
1266 do
1267 {
1268 int j = 0;
1269 do
1270 {
1271 int k = 0;
1272 do
1273 {
1274 /* at every context */
1275
1276 /* calc probs and branch cts for this frame only */
1277 //vp8_prob new_p [ENTROPY_NODES];
1278 //unsigned int branch_ct [ENTROPY_NODES] [2];
1279
1280 int t = 0; /* token/prob index */
1281
1282
1283 vp8_tree_probs_from_distribution(
1284 MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
1285 cpi->frame_coef_probs [i][j][k],
1286 cpi->frame_branch_ct [i][j][k],
1287 cpi->coef_counts [i][j][k],
1288 256, 1
1289 );
1290
1291 do
1292 {
1293 const unsigned int *ct = cpi->frame_branch_ct [i][j][k][t];
1294 const vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
1295 const vp8_prob oldp = cpi->common.fc.coef_probs [i][j][k][t] ;
1296 const vp8_prob upd = vp8_coef_update_probs [i][j][k][t];
1297 const int s = prob_update_savings(ct, oldp, newp, upd);
1298
1299 if (s > 0)
1300 {
1301 savings += s;
1302 }
1303 }
1304 while (++t < ENTROPY_NODES);
1305 }
1306 while (++k < PREV_COEF_CONTEXTS);
1307 }
1308 while (++j < COEF_BANDS);
1309 }
1310 while (++i < BLOCK_TYPES);
1311 return savings;
1312 }
1313
1121 int vp8_estimate_entropy_savings(VP8_COMP *cpi) 1314 int vp8_estimate_entropy_savings(VP8_COMP *cpi)
1122 { 1315 {
1123 int i = 0;
1124 int savings = 0; 1316 int savings = 0;
1125 1317
1126 const int *const rfct = cpi->count_mb_ref_frame_usage; 1318 const int *const rfct = cpi->count_mb_ref_frame_usage;
1127 const int rf_intra = rfct[INTRA_FRAME]; 1319 const int rf_intra = rfct[INTRA_FRAME];
1128 const int rf_inter = rfct[LAST_FRAME] + rfct[GOLDEN_FRAME] + rfct[ALTREF_FRA ME]; 1320 const int rf_inter = rfct[LAST_FRAME] + rfct[GOLDEN_FRAME] + rfct[ALTREF_FRA ME];
1129 int new_intra, new_last, gf_last, oldtotal, newtotal; 1321 int new_intra, new_last, gf_last, oldtotal, newtotal;
1130 int ref_frame_cost[MAX_REF_FRAMES]; 1322 int ref_frame_cost[MAX_REF_FRAMES];
1131 1323
1132 vp8_clear_system_state(); //__asm emms; 1324 vp8_clear_system_state(); //__asm emms;
1133 1325
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 oldtotal = 1365 oldtotal =
1174 rfct[INTRA_FRAME] * ref_frame_cost[INTRA_FRAME] + 1366 rfct[INTRA_FRAME] * ref_frame_cost[INTRA_FRAME] +
1175 rfct[LAST_FRAME] * ref_frame_cost[LAST_FRAME] + 1367 rfct[LAST_FRAME] * ref_frame_cost[LAST_FRAME] +
1176 rfct[GOLDEN_FRAME] * ref_frame_cost[GOLDEN_FRAME] + 1368 rfct[GOLDEN_FRAME] * ref_frame_cost[GOLDEN_FRAME] +
1177 rfct[ALTREF_FRAME] * ref_frame_cost[ALTREF_FRAME]; 1369 rfct[ALTREF_FRAME] * ref_frame_cost[ALTREF_FRAME];
1178 1370
1179 savings += (oldtotal - newtotal) / 256; 1371 savings += (oldtotal - newtotal) / 256;
1180 } 1372 }
1181 1373
1182 1374
1183 do 1375 if (cpi->oxcf.error_resilient_mode & VPX_ERROR_RESILIENT_PARTITIONS)
1184 { 1376 savings += independent_coef_context_savings(cpi);
1185 int j = 0; 1377 else
1378 savings += default_coef_context_savings(cpi);
1186 1379
1187 do
1188 {
1189 int k = 0;
1190
1191 do
1192 {
1193 /* at every context */
1194
1195 /* calc probs and branch cts for this frame only */
1196 //vp8_prob new_p [vp8_coef_tokens-1];
1197 //unsigned int branch_ct [vp8_coef_tokens-1] [2];
1198
1199 int t = 0; /* token/prob index */
1200
1201 vp8_tree_probs_from_distribution(
1202 vp8_coef_tokens, vp8_coef_encodings, vp8_coef_tree,
1203 cpi->frame_coef_probs [i][j][k], cpi->frame_branch_ct [i][j] [k], cpi->coef_counts [i][j][k],
1204 256, 1
1205 );
1206
1207 do
1208 {
1209 const unsigned int *ct = cpi->frame_branch_ct [i][j][k][t];
1210 const vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
1211
1212 const vp8_prob old = cpi->common.fc.coef_probs [i][j][k][t];
1213 const vp8_prob upd = vp8_coef_update_probs [i][j][k][t];
1214
1215 const int old_b = vp8_cost_branch(ct, old);
1216 const int new_b = vp8_cost_branch(ct, newp);
1217
1218 const int update_b = 8 +
1219 ((vp8_cost_one(upd) - vp8_cost_zero(upd )) >> 8);
1220
1221 const int s = old_b - new_b - update_b;
1222
1223 if (s > 0)
1224 savings += s;
1225
1226
1227 }
1228 while (++t < vp8_coef_tokens - 1);
1229
1230
1231 }
1232 while (++k < PREV_COEF_CONTEXTS);
1233 }
1234 while (++j < COEF_BANDS);
1235 }
1236 while (++i < BLOCK_TYPES);
1237 1380
1238 return savings; 1381 return savings;
1239 } 1382 }
1240 1383
1241 static void update_coef_probs(VP8_COMP *cpi) 1384 static void update_coef_probs(VP8_COMP *cpi)
1242 { 1385 {
1243 int i = 0; 1386 int i = 0;
1244 vp8_writer *const w = & cpi->bc; 1387 vp8_writer *const w = & cpi->bc;
1245 int savings = 0; 1388 int savings = 0;
1246 1389
1247 vp8_clear_system_state(); //__asm emms; 1390 vp8_clear_system_state(); //__asm emms;
1248 1391
1249
1250 do 1392 do
1251 { 1393 {
1252 int j = 0; 1394 int j = 0;
1253 1395
1254 do 1396 do
1255 { 1397 {
1256 int k = 0; 1398 int k = 0;
1399 int prev_coef_savings[ENTROPY_NODES] = {0};
1400 if (cpi->oxcf.error_resilient_mode & VPX_ERROR_RESILIENT_PARTITIONS)
1401 {
1402 for (k = 0; k < PREV_COEF_CONTEXTS; ++k)
1403 {
1404 int t; /* token/prob index */
1405 for (t = 0; t < ENTROPY_NODES; ++t)
1406 {
1407 const unsigned int *ct = cpi->frame_branch_ct [i][j]
1408 [k][t];
1409 const vp8_prob newp = cpi->frame_coef_probs[i][j][k][t];
1410 const vp8_prob oldp = cpi->common.fc.coef_probs[i][j]
1411 [k][t];
1412 const vp8_prob upd = vp8_coef_update_probs[i][j][k][t];
1257 1413
1414 prev_coef_savings[t] +=
1415 prob_update_savings(ct, oldp, newp, upd);
1416 }
1417 }
1418 k = 0;
1419 }
1258 do 1420 do
1259 { 1421 {
1260 //note: use result from vp8_estimate_entropy_savings, so no need to call vp8_tree_probs_from_distribution here. 1422 //note: use result from vp8_estimate_entropy_savings, so no need to call vp8_tree_probs_from_distribution here.
1261 /* at every context */ 1423 /* at every context */
1262 1424
1263 /* calc probs and branch cts for this frame only */ 1425 /* calc probs and branch cts for this frame only */
1264 //vp8_prob new_p [vp8_coef_tokens-1]; 1426 //vp8_prob new_p [ENTROPY_NODES];
1265 //unsigned int branch_ct [vp8_coef_tokens-1] [2]; 1427 //unsigned int branch_ct [ENTROPY_NODES] [2];
1266 1428
1267 int t = 0; /* token/prob index */ 1429 int t = 0; /* token/prob index */
1268 1430
1269 //vp8_tree_probs_from_distribution( 1431 //vp8_tree_probs_from_distribution(
1270 // vp8_coef_tokens, vp8_coef_encodings, vp8_coef_tree, 1432 // MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree,
1271 // new_p, branch_ct, (unsigned int *)cpi->coef_counts [i][j][ k], 1433 // new_p, branch_ct, (unsigned int *)cpi->coef_counts [i][j][ k],
1272 // 256, 1 1434 // 256, 1
1273 // ); 1435 // );
1274 1436
1275 do 1437 do
1276 { 1438 {
1277 const unsigned int *ct = cpi->frame_branch_ct [i][j][k][t];
1278 const vp8_prob newp = cpi->frame_coef_probs [i][j][k][t]; 1439 const vp8_prob newp = cpi->frame_coef_probs [i][j][k][t];
1279 1440
1280 vp8_prob *Pold = cpi->common.fc.coef_probs [i][j][k] + t; 1441 vp8_prob *Pold = cpi->common.fc.coef_probs [i][j][k] + t;
1281 const vp8_prob old = *Pold;
1282 const vp8_prob upd = vp8_coef_update_probs [i][j][k][t]; 1442 const vp8_prob upd = vp8_coef_update_probs [i][j][k][t];
1283 1443
1284 const int old_b = vp8_cost_branch(ct, old); 1444 int s = prev_coef_savings[t];
1285 const int new_b = vp8_cost_branch(ct, newp); 1445 int u = 0;
1286 1446
1287 const int update_b = 8 + 1447 if (!(cpi->oxcf.error_resilient_mode &
1288 ((vp8_cost_one(upd) - vp8_cost_zero(upd )) >> 8); 1448 VPX_ERROR_RESILIENT_PARTITIONS))
1449 {
1450 s = prob_update_savings(
1451 cpi->frame_branch_ct [i][j][k][t],
1452 *Pold, newp, upd);
1453 }
1289 1454
1290 const int s = old_b - new_b - update_b; 1455 if (s > 0)
1291 const int u = s > 0 ? 1 : 0; 1456 u = 1;
1457
1458 /* Force updates on key frames if the new is different,
1459 * so that we can be sure we end up with equal probabilities
1460 * over the prev coef contexts.
1461 */
1462 if ((cpi->oxcf.error_resilient_mode &
1463 VPX_ERROR_RESILIENT_PARTITIONS) &&
1464 cpi->common.frame_type == KEY_FRAME && newp != *Pold)
1465 u = 1;
1292 1466
1293 vp8_write(w, u, upd); 1467 vp8_write(w, u, upd);
1294 1468
1295 1469
1296 #ifdef ENTROPY_STATS 1470 #ifdef ENTROPY_STATS
1297 ++ tree_update_hist [i][j][k][t] [u]; 1471 ++ tree_update_hist [i][j][k][t] [u];
1298 #endif 1472 #endif
1299 1473
1300 if (u) 1474 if (u)
1301 { 1475 {
1302 /* send/use new probability */ 1476 /* send/use new probability */
1303 1477
1304 *Pold = newp; 1478 *Pold = newp;
1305 vp8_write_literal(w, newp, 8); 1479 vp8_write_literal(w, newp, 8);
1306 1480
1307 savings += s; 1481 savings += s;
1308 1482
1309 } 1483 }
1310 1484
1311 } 1485 }
1312 while (++t < vp8_coef_tokens - 1); 1486 while (++t < ENTROPY_NODES);
1313 1487
1314 /* Accum token counts for generation of default statistics */ 1488 /* Accum token counts for generation of default statistics */
1315 #ifdef ENTROPY_STATS 1489 #ifdef ENTROPY_STATS
1316 t = 0; 1490 t = 0;
1317 1491
1318 do 1492 do
1319 { 1493 {
1320 context_counters [i][j][k][t] += cpi->coef_counts [i][j][k][ t]; 1494 context_counters [i][j][k][t] += cpi->coef_counts [i][j][k][ t];
1321 } 1495 }
1322 while (++t < vp8_coef_tokens); 1496 while (++t < MAX_ENTROPY_TOKENS);
1323 1497
1324 #endif 1498 #endif
1325 1499
1326 } 1500 }
1327 while (++k < PREV_COEF_CONTEXTS); 1501 while (++k < PREV_COEF_CONTEXTS);
1328 } 1502 }
1329 while (++j < COEF_BANDS); 1503 while (++j < COEF_BANDS);
1330 } 1504 }
1331 while (++i < BLOCK_TYPES); 1505 while (++i < BLOCK_TYPES);
1332 1506
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 vp8_write_literal(bc, pc->copy_buffer_to_gf, 2); 1752 vp8_write_literal(bc, pc->copy_buffer_to_gf, 2);
1579 1753
1580 if (!pc->refresh_alt_ref_frame) 1754 if (!pc->refresh_alt_ref_frame)
1581 vp8_write_literal(bc, pc->copy_buffer_to_arf, 2); 1755 vp8_write_literal(bc, pc->copy_buffer_to_arf, 2);
1582 1756
1583 // Indicate reference frame sign bias for Golden and ARF frames (always 0 for last frame buffer) 1757 // Indicate reference frame sign bias for Golden and ARF frames (always 0 for last frame buffer)
1584 vp8_write_bit(bc, pc->ref_frame_sign_bias[GOLDEN_FRAME]); 1758 vp8_write_bit(bc, pc->ref_frame_sign_bias[GOLDEN_FRAME]);
1585 vp8_write_bit(bc, pc->ref_frame_sign_bias[ALTREF_FRAME]); 1759 vp8_write_bit(bc, pc->ref_frame_sign_bias[ALTREF_FRAME]);
1586 } 1760 }
1587 1761
1762 if (cpi->oxcf.error_resilient_mode & VPX_ERROR_RESILIENT_PARTITIONS)
1763 {
1764 if (pc->frame_type == KEY_FRAME)
1765 pc->refresh_entropy_probs = 1;
1766 else
1767 pc->refresh_entropy_probs = 0;
1768 }
1769
1588 vp8_write_bit(bc, pc->refresh_entropy_probs); 1770 vp8_write_bit(bc, pc->refresh_entropy_probs);
1589 1771
1590 if (pc->frame_type != KEY_FRAME) 1772 if (pc->frame_type != KEY_FRAME)
1591 vp8_write_bit(bc, pc->refresh_last_frame); 1773 vp8_write_bit(bc, pc->refresh_last_frame);
1592 1774
1593 #ifdef ENTROPY_STATS 1775 #ifdef ENTROPY_STATS
1594 1776
1595 if (pc->frame_type == INTER_FRAME) 1777 if (pc->frame_type == INTER_FRAME)
1596 active_section = 0; 1778 active_section = 0;
1597 else 1779 else
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 (oh.show_frame << 4) | 1825 (oh.show_frame << 4) |
1644 (oh.version << 1) | 1826 (oh.version << 1) |
1645 oh.type; 1827 oh.type;
1646 1828
1647 dest[0] = v; 1829 dest[0] = v;
1648 dest[1] = v >> 8; 1830 dest[1] = v >> 8;
1649 dest[2] = v >> 16; 1831 dest[2] = v >> 16;
1650 } 1832 }
1651 1833
1652 *size = VP8_HEADER_SIZE + extra_bytes_packed + cpi->bc.pos; 1834 *size = VP8_HEADER_SIZE + extra_bytes_packed + cpi->bc.pos;
1835 cpi->partition_sz[0] = *size;
1653 1836
1654 if (pc->multi_token_partition != ONE_PARTITION) 1837 if (pc->multi_token_partition != ONE_PARTITION)
1655 { 1838 {
1656 int num_part; 1839 int num_part;
1657 int asize; 1840 int asize;
1658 num_part = 1 << pc->multi_token_partition; 1841 num_part = 1 << pc->multi_token_partition;
1659 1842
1660 pack_tokens_into_partitions(cpi, cx_data + bc->pos, num_part, &asize); 1843 pack_tokens_into_partitions(cpi, cx_data + bc->pos, num_part, &asize);
1661 1844
1662 *size += asize; 1845 *size += asize;
1663 } 1846 }
1664 else 1847 else
1665 { 1848 {
1666 vp8_start_encode(&cpi->bc2, cx_data + bc->pos); 1849 vp8_start_encode(&cpi->bc2, cx_data + bc->pos);
1667 1850
1668 #if CONFIG_MULTITHREAD 1851 #if CONFIG_MULTITHREAD
1669 if (cpi->b_multi_threaded) 1852 if (cpi->b_multi_threaded)
1670 pack_mb_row_tokens(cpi, &cpi->bc2); 1853 pack_mb_row_tokens(cpi, &cpi->bc2);
1671 else 1854 else
1672 #endif 1855 #endif
1673 pack_tokens(&cpi->bc2, cpi->tok, cpi->tok_count); 1856 pack_tokens(&cpi->bc2, cpi->tok, cpi->tok_count);
1674 1857
1675 vp8_stop_encode(&cpi->bc2); 1858 vp8_stop_encode(&cpi->bc2);
1676 1859
1677 *size += cpi->bc2.pos; 1860 *size += cpi->bc2.pos;
1861 cpi->partition_sz[1] = cpi->bc2.pos;
1678 } 1862 }
1679 } 1863 }
1680 1864
1681 #ifdef ENTROPY_STATS 1865 #ifdef ENTROPY_STATS
1682 void print_tree_update_probs() 1866 void print_tree_update_probs()
1683 { 1867 {
1684 int i, j, k, l; 1868 int i, j, k, l;
1685 FILE *f = fopen("context.c", "a"); 1869 FILE *f = fopen("context.c", "a");
1686 int Sum; 1870 int Sum;
1687 fprintf(f, "\n/* Update probabilities for token entropy tree. */\n\n"); 1871 fprintf(f, "\n/* Update probabilities for token entropy tree. */\n\n");
1688 fprintf(f, "const vp8_prob tree_update_probs[BLOCK_TYPES] [COEF_BANDS] [PREV _COEF_CONTEXTS] [vp8_coef_tokens-1] = {\n"); 1872 fprintf(f, "const vp8_prob tree_update_probs[BLOCK_TYPES] [COEF_BANDS] [PREV _COEF_CONTEXTS] [ENTROPY_NODES] = {\n");
1689 1873
1690 for (i = 0; i < BLOCK_TYPES; i++) 1874 for (i = 0; i < BLOCK_TYPES; i++)
1691 { 1875 {
1692 fprintf(f, " { \n"); 1876 fprintf(f, " { \n");
1693 1877
1694 for (j = 0; j < COEF_BANDS; j++) 1878 for (j = 0; j < COEF_BANDS; j++)
1695 { 1879 {
1696 fprintf(f, " {\n"); 1880 fprintf(f, " {\n");
1697 1881
1698 for (k = 0; k < PREV_COEF_CONTEXTS; k++) 1882 for (k = 0; k < PREV_COEF_CONTEXTS; k++)
1699 { 1883 {
1700 fprintf(f, " {"); 1884 fprintf(f, " {");
1701 1885
1702 for (l = 0; l < MAX_ENTROPY_TOKENS - 1; l++) 1886 for (l = 0; l < ENTROPY_NODES; l++)
1703 { 1887 {
1704 Sum = tree_update_hist[i][j][k][l][0] + tree_update_hist[i][ j][k][l][1]; 1888 Sum = tree_update_hist[i][j][k][l][0] + tree_update_hist[i][ j][k][l][1];
1705 1889
1706 if (Sum > 0) 1890 if (Sum > 0)
1707 { 1891 {
1708 if (((tree_update_hist[i][j][k][l][0] * 255) / Sum) > 0) 1892 if (((tree_update_hist[i][j][k][l][0] * 255) / Sum) > 0)
1709 fprintf(f, "%3ld, ", (tree_update_hist[i][j][k][l][0 ] * 255) / Sum); 1893 fprintf(f, "%3ld, ", (tree_update_hist[i][j][k][l][0 ] * 255) / Sum);
1710 else 1894 else
1711 fprintf(f, "%3ld, ", 1); 1895 fprintf(f, "%3ld, ", 1);
1712 } 1896 }
1713 else 1897 else
1714 fprintf(f, "%3ld, ", 128); 1898 fprintf(f, "%3ld, ", 128);
1715 } 1899 }
1716 1900
1717 fprintf(f, "},\n"); 1901 fprintf(f, "},\n");
1718 } 1902 }
1719 1903
1720 fprintf(f, " },\n"); 1904 fprintf(f, " },\n");
1721 } 1905 }
1722 1906
1723 fprintf(f, " },\n"); 1907 fprintf(f, " },\n");
1724 } 1908 }
1725 1909
1726 fprintf(f, "};\n"); 1910 fprintf(f, "};\n");
1727 fclose(f); 1911 fclose(f);
1728 } 1912 }
1729 #endif 1913 #endif
OLDNEW
« no previous file with comments | « source/libvpx/vp8/encoder/asm_enc_offsets.c ('k') | source/libvpx/vp8/encoder/block.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698