From 825adc464f8ed54660ad6ca4e5b4f571ceb4821b Mon Sep 17 00:00:00 2001 From: Johann Date: Tue, 14 Dec 2010 09:35:18 -0500 Subject: [PATCH] shrink TOKENEXTRA and vp8_extra_bit_struct Per John's previous change, shrink TOKENEXTRA from 20 to 8 bytes original: b7b1e6fb reverted: 41f4458a Also drop unused field from vp8_extra_bit_struct Update ARM ASM to deal with this change. In particular, Extra is signed and needs to be sign-extended when loaded. Change-Id: Ibd0ddc058432bc7bb09222d6ce4ef77e93a30b41 --- vp8/common/entropy.c | 29 +++++++++---------- vp8/common/entropy.h | 1 - .../arm/armv5te/vp8_packtokens_armv5.asm | 18 +++++------- .../armv5te/vp8_packtokens_mbrow_armv5.asm | 13 ++++----- .../vp8_packtokens_partitions_armv5.asm | 13 ++++----- vp8/encoder/arm/vpx_vp8_enc_asm_offsets.c | 5 ++-- vp8/encoder/tokenize.c | 6 ---- vp8/encoder/tokenize.h | 7 ++--- 8 files changed, 38 insertions(+), 54 deletions(-) diff --git a/vp8/common/entropy.c b/vp8/common/entropy.c index 61dbe4af7..a1fe4f4ab 100644 --- a/vp8/common/entropy.c +++ b/vp8/common/entropy.c @@ -36,7 +36,7 @@ DECLARE_ALIGNED(16, const int, vp8_default_zig_zag1d[16]) = 7, 11, 14, 15, }; -DECLARE_ALIGNED(16, const short, vp8_default_inv_zig_zag[16]) = +DECLARE_ALIGNED(16, const short, vp8_default_inv_zig_zag[16]) = { 1, 2, 6, 7, 3, 5, 8, 13, @@ -114,23 +114,20 @@ static void init_bit_trees() init_bit_tree(cat6, 11); } - -static vp8bc_index_t bcc1[1], bcc2[2], bcc3[3], bcc4[4], bcc5[5], bcc6[11]; - vp8_extra_bit_struct vp8_extra_bits[12] = { - { 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 1}, - { 0, 0, 0, 0, 2}, - { 0, 0, 0, 0, 3}, - { 0, 0, 0, 0, 4}, - { cat1, Pcat1, bcc1, 1, 5}, - { cat2, Pcat2, bcc2, 2, 7}, - { cat3, Pcat3, bcc3, 3, 11}, - { cat4, Pcat4, bcc4, 4, 19}, - { cat5, Pcat5, bcc5, 5, 35}, - { cat6, Pcat6, bcc6, 11, 67}, - { 0, 0, 0, 0, 0} + { 0, 0, 0, 0}, + { 0, 0, 0, 1}, + { 0, 0, 0, 2}, + { 0, 0, 0, 3}, + { 0, 0, 0, 4}, + { cat1, Pcat1, 1, 5}, + { cat2, Pcat2, 2, 7}, + { cat3, Pcat3, 3, 11}, + { cat4, Pcat4, 4, 19}, + { cat5, Pcat5, 5, 35}, + { cat6, Pcat6, 11, 67}, + { 0, 0, 0, 0} }; #include "defaultcoefcounts.h" diff --git a/vp8/common/entropy.h b/vp8/common/entropy.h index fa2fce47b..d174e45b9 100644 --- a/vp8/common/entropy.h +++ b/vp8/common/entropy.h @@ -42,7 +42,6 @@ typedef struct { vp8_tree_p tree; const vp8_prob *prob; - vp8bc_index_t *prob_bc; int Len; int base_val; } vp8_extra_bit_struct; diff --git a/vp8/encoder/arm/armv5te/vp8_packtokens_armv5.asm b/vp8/encoder/arm/armv5te/vp8_packtokens_armv5.asm index 3233d2a96..b2abadf29 100644 --- a/vp8/encoder/arm/armv5te/vp8_packtokens_armv5.asm +++ b/vp8/encoder/arm/armv5te/vp8_packtokens_armv5.asm @@ -29,10 +29,9 @@ push {r4-r11, lr} ; Add size of xcount * sizeof (TOKENEXTRA) to get stop - ; sizeof (TOKENEXTRA) is 20 - add r2, r2, r2, lsl #2 ; xcount + ; sizeof (TOKENEXTRA) is 8 sub sp, sp, #12 - add r2, r1, r2, lsl #2 ; stop = p + xcount + add r2, r1, r2, lsl #3 ; stop = p + xcount*sizeof(TOKENEXTRA) str r2, [sp, #0] str r3, [sp, #8] ; save vp8_coef_encodings ldr r2, [r0, #vp8_writer_lowvalue] @@ -41,13 +40,13 @@ b check_p_lt_stop while_p_lt_stop - ldr r6, [r1, #tokenextra_token] ; t + ldrb r6, [r1, #tokenextra_token] ; t ldr r4, [sp, #8] ; vp8_coef_encodings mov lr, #0 add r4, r4, r6, lsl #3 ; a = vp8_coef_encodings + t ldr r9, [r1, #tokenextra_context_tree] ; pp - ldr r7, [r1, #tokenextra_skip_eob_node] + ldrb r7, [r1, #tokenextra_skip_eob_node] ldr r6, [r4, #vp8_token_value] ; v ldr r8, [r4, #vp8_token_len] ; n @@ -142,12 +141,11 @@ token_count_lt_zero subs r8, r8, #1 ; --n bne token_loop - ldr r6, [r1, #tokenextra_token] ; t + ldrb r6, [r1, #tokenextra_token] ; t ldr r7, [sp, #48] ; vp8_extra_bits ; Add t * sizeof (vp8_extra_bit_struct) to get the desired - ; element. Here vp8_extra_bit_struct == 20 - add r6, r6, r6, lsl #2 ; b = vp8_extra_bits + t - add r12, r7, r6, lsl #2 ; b = vp8_extra_bits + t + ; element. Here vp8_extra_bit_struct == 16 + add r12, r7, r6, lsl #4 ; b = vp8_extra_bits + t ldr r4, [r12, #vp8_extra_bit_struct_base_val] cmp r4, #0 @@ -155,7 +153,7 @@ token_count_lt_zero ; if( b->base_val) ldr r8, [r12, #vp8_extra_bit_struct_len] ; L - ldr lr, [r1, #tokenextra_extra] ; e = p->Extra + ldrsh lr, [r1, #tokenextra_extra] ; e = p->Extra cmp r8, #0 ; if( L) beq no_extra_bits diff --git a/vp8/encoder/arm/armv5te/vp8_packtokens_mbrow_armv5.asm b/vp8/encoder/arm/armv5te/vp8_packtokens_mbrow_armv5.asm index a9b552ae1..f9c3852e3 100644 --- a/vp8/encoder/arm/armv5te/vp8_packtokens_mbrow_armv5.asm +++ b/vp8/encoder/arm/armv5te/vp8_packtokens_mbrow_armv5.asm @@ -62,13 +62,13 @@ mb_row_loop ; actuall work gets done here! while_p_lt_stop - ldr r6, [r1, #tokenextra_token] ; t + ldrb r6, [r1, #tokenextra_token] ; t ldr r4, [sp, #20] ; vp8_coef_encodings mov lr, #0 add r4, r4, r6, lsl #3 ; a = vp8_coef_encodings + t ldr r9, [r1, #tokenextra_context_tree] ; pp - ldr r7, [r1, #tokenextra_skip_eob_node] + ldrb r7, [r1, #tokenextra_skip_eob_node] ldr r6, [r4, #vp8_token_value] ; v ldr r8, [r4, #vp8_token_len] ; n @@ -163,12 +163,11 @@ token_count_lt_zero subs r8, r8, #1 ; --n bne token_loop - ldr r6, [r1, #tokenextra_token] ; t + ldrb r6, [r1, #tokenextra_token] ; t ldr r7, [sp, #8] ; vp8_extra_bits ; Add t * sizeof (vp8_extra_bit_struct) to get the desired - ; element. Here vp8_extra_bit_struct == 20 - add r6, r6, r6, lsl #2 ; b = vp8_extra_bits + t - add r12, r7, r6, lsl #2 ; b = vp8_extra_bits + t + ; element. Here vp8_extra_bit_struct == 16 + add r12, r7, r6, lsl #4 ; b = vp8_extra_bits + t ldr r4, [r12, #vp8_extra_bit_struct_base_val] cmp r4, #0 @@ -176,7 +175,7 @@ token_count_lt_zero ; if( b->base_val) ldr r8, [r12, #vp8_extra_bit_struct_len] ; L - ldr lr, [r1, #tokenextra_extra] ; e = p->Extra + ldrsh lr, [r1, #tokenextra_extra] ; e = p->Extra cmp r8, #0 ; if( L) beq no_extra_bits diff --git a/vp8/encoder/arm/armv5te/vp8_packtokens_partitions_armv5.asm b/vp8/encoder/arm/armv5te/vp8_packtokens_partitions_armv5.asm index 0835164e5..57cd318ee 100644 --- a/vp8/encoder/arm/armv5te/vp8_packtokens_partitions_armv5.asm +++ b/vp8/encoder/arm/armv5te/vp8_packtokens_partitions_armv5.asm @@ -90,13 +90,13 @@ mb_row_loop ; actual work gets done here! while_p_lt_stop - ldr r6, [r1, #tokenextra_token] ; t + ldrb r6, [r1, #tokenextra_token] ; t ldr r4, [sp, #80] ; vp8_coef_encodings mov lr, #0 add r4, r4, r6, lsl #3 ; a = vp8_coef_encodings + t ldr r9, [r1, #tokenextra_context_tree] ; pp - ldr r7, [r1, #tokenextra_skip_eob_node] + ldrb r7, [r1, #tokenextra_skip_eob_node] ldr r6, [r4, #vp8_token_value] ; v ldr r8, [r4, #vp8_token_len] ; n @@ -191,12 +191,11 @@ token_count_lt_zero subs r8, r8, #1 ; --n bne token_loop - ldr r6, [r1, #tokenextra_token] ; t + ldrb r6, [r1, #tokenextra_token] ; t ldr r7, [sp, #84] ; vp8_extra_bits ; Add t * sizeof (vp8_extra_bit_struct) to get the desired - ; element. Here vp8_extra_bit_struct == 20 - add r6, r6, r6, lsl #2 ; b = vp8_extra_bits + t - add r12, r7, r6, lsl #2 ; b = vp8_extra_bits + t + ; element. Here vp8_extra_bit_struct == 16 + add r12, r7, r6, lsl #4 ; b = vp8_extra_bits + t ldr r4, [r12, #vp8_extra_bit_struct_base_val] cmp r4, #0 @@ -204,7 +203,7 @@ token_count_lt_zero ; if( b->base_val) ldr r8, [r12, #vp8_extra_bit_struct_len] ; L - ldr lr, [r1, #tokenextra_extra] ; e = p->Extra + ldrsh lr, [r1, #tokenextra_extra] ; e = p->Extra cmp r8, #0 ; if( L) beq no_extra_bits diff --git a/vp8/encoder/arm/vpx_vp8_enc_asm_offsets.c b/vp8/encoder/arm/vpx_vp8_enc_asm_offsets.c index c595ca3c0..4703a84b5 100644 --- a/vp8/encoder/arm/vpx_vp8_enc_asm_offsets.c +++ b/vp8/encoder/arm/vpx_vp8_enc_asm_offsets.c @@ -51,7 +51,6 @@ DEFINE(vp8_token_len, offsetof(vp8_token, Len)); DEFINE(vp8_extra_bit_struct_tree, offsetof(vp8_extra_bit_struct, tree)); DEFINE(vp8_extra_bit_struct_prob, offsetof(vp8_extra_bit_struct, prob)); -DEFINE(vp8_extra_bit_struct_prob_bc, offsetof(vp8_extra_bit_struct, prob_bc)); DEFINE(vp8_extra_bit_struct_len, offsetof(vp8_extra_bit_struct, Len)); DEFINE(vp8_extra_bit_struct_base_val, offsetof(vp8_extra_bit_struct, base_val)); @@ -67,8 +66,8 @@ DEFINE(vp8_common_mb_rows, offsetof(VP8_COMMON, mb_rows)); // These two sizes are used in vp7cx_pack_tokens. They are hard coded // so if the size changes this will have to be adjusted. -ct_assert(TOKENEXTRA_SZ, sizeof(TOKENEXTRA) == 20) -ct_assert(vp8_extra_bit_struct_sz, sizeof(vp8_extra_bit_struct) == 20) +ct_assert(TOKENEXTRA_SZ, sizeof(TOKENEXTRA) == 8) +ct_assert(vp8_extra_bit_struct_sz, sizeof(vp8_extra_bit_struct) == 16) //add asserts for any offset that is not supported by assembly code //add asserts for any size that is not supported by assembly code diff --git a/vp8/encoder/tokenize.c b/vp8/encoder/tokenize.c index e4da83379..5e018634f 100644 --- a/vp8/encoder/tokenize.c +++ b/vp8/encoder/tokenize.c @@ -132,8 +132,6 @@ static void tokenize2nd_order_b t->Token = x; t->context_tree = cpi->common.fc.coef_probs [type] [band] [pt]; - t->section = frametype * BLOCK_TYPES * 2 + 2 * type + (c == 0); - t->skip_eob_node = pt == 0 && ((band > 0 && type > 0) || (band > 1 && type == 0)); ++cpi->coef_counts [type] [band] [pt] [x]; @@ -185,7 +183,6 @@ static void tokenize1st_order_b t->Token = x; t->context_tree = cpi->common.fc.coef_probs [type] [band] [pt]; - t->section = frametype * BLOCK_TYPES * 2 + 2 * type + (c == 0); t->skip_eob_node = pt == 0 && ((band > 0 && type > 0) || (band > 1 && type == 0)); ++cpi->coef_counts [type] [band] [pt] [x]; @@ -434,7 +431,6 @@ static __inline void stuff2nd_order_b t->Token = DCT_EOB_TOKEN; t->context_tree = cpi->common.fc.coef_probs [1] [0] [pt]; - t->section = 11; t->skip_eob_node = 0; ++cpi->coef_counts [1] [0] [pt] [DCT_EOB_TOKEN]; ++t; @@ -465,7 +461,6 @@ static __inline void stuff1st_order_b t->Token = DCT_EOB_TOKEN; t->context_tree = cpi->common.fc.coef_probs [0] [1] [pt]; - t->section = 8; t->skip_eob_node = 0; ++cpi->coef_counts [0] [1] [pt] [DCT_EOB_TOKEN]; ++t; @@ -495,7 +490,6 @@ void stuff1st_order_buv t->Token = DCT_EOB_TOKEN; t->context_tree = cpi->common.fc.coef_probs [2] [0] [pt]; - t->section = 13; t->skip_eob_node = 0; ++cpi->coef_counts[2] [0] [pt] [DCT_EOB_TOKEN]; ++t; diff --git a/vp8/encoder/tokenize.h b/vp8/encoder/tokenize.h index 01e8ec6d7..ed5eb0ce9 100644 --- a/vp8/encoder/tokenize.h +++ b/vp8/encoder/tokenize.h @@ -25,11 +25,10 @@ typedef struct typedef struct { - int Token; - int Extra; const vp8_prob *context_tree; - int skip_eob_node; - int section; + short Extra; + unsigned char Token; + unsigned char skip_eob_node; } TOKENEXTRA; int rd_cost_mby(MACROBLOCKD *);