Merge remote branch 'internal/upstream' into HEAD

Conflicts:
	vp8/common/entropy.c

Change-Id: Ic95302e327f80afd0261ac5bd9881f38296def47
This commit is contained in:
John Koleszar 2010-12-15 08:11:07 -05:00
commit f7224e14c8
13 changed files with 128 additions and 99 deletions

View File

@ -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, 13);
}
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, 13, 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, 13, 67},
{ 0, 0, 0, 0}
};
#include "defaultcoefcounts.h"

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -281,6 +281,7 @@ static void setup_mbby_copy(MACROBLOCK *mbdst, MACROBLOCK *mbsrc)
z->vp8_short_fdct8x4 = x->vp8_short_fdct8x4;
z->short_walsh4x4 = x->short_walsh4x4;
z->quantize_b = x->quantize_b;
z->optimize = x->optimize;
/*
z->mvc = x->mvc;

View File

@ -941,6 +941,18 @@ int vp8_diamond_search_sad
unsigned char *check_here;
int thissad;
int search_range = 128>>search_param;
*num00 = 0;
// Trap uncodable vectors
if (((abs(ref_mv->col - center_mv->col) + (search_range<<4)) > MAX_POSSIBLE_MV) || ((abs(ref_mv->row - center_mv->row) + (search_range<<4)) > MAX_POSSIBLE_MV))
{
best_mv->row = ref_row;
best_mv->col = ref_col;
return INT_MAX;
}
// Work out the start point for the search
in_what = (unsigned char *)(*(d->base_pre) + d->pre + (ref_row * (d->pre_stride)) + ref_col);
best_address = in_what;
@ -962,8 +974,6 @@ int vp8_diamond_search_sad
best_mv->row = ref_row;
best_mv->col = ref_col;
*num00 = 0;
for (step = 0; step < tot_steps ; step++)
{
for (j = 0 ; j < x->searches_per_step ; j++)
@ -1057,6 +1067,18 @@ int vp8_diamond_search_sadx4
unsigned char *check_here;
unsigned int thissad;
int search_range = 128>>search_param;
*num00 = 0;
// Trap uncodable vectors
if (((abs(ref_mv->col - center_mv->col) + (search_range<<4)) > MAX_POSSIBLE_MV) || ((abs(ref_mv->row - center_mv->row) + (search_range<<4)) > MAX_POSSIBLE_MV))
{
best_mv->row = ref_row;
best_mv->col = ref_col;
return INT_MAX;
}
// Work out the start point for the search
in_what = (unsigned char *)(*(d->base_pre) + d->pre + (ref_row * (d->pre_stride)) + ref_col);
best_address = in_what;
@ -1078,8 +1100,6 @@ int vp8_diamond_search_sadx4
best_mv->row = ref_row;
best_mv->col = ref_col;
*num00 = 0;
for (step = 0; step < tot_steps ; step++)
{
int all_in = 1, t;
@ -1194,10 +1214,24 @@ int vp8_full_search_sad(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int erro
int ref_row = ref_mv->row >> 3;
int ref_col = ref_mv->col >> 3;
int row_min = ref_row - distance;
int row_max = ref_row + distance;
int col_min = ref_col - distance;
int col_max = ref_col + distance;
int row_min, row_max, col_min, col_max;
int drow = abs(ref_mv->row - center_mv->row);
int dcol = abs(ref_mv->col - center_mv->col);
// reduce search distance and make sure MV obtained is in range.
if (((dcol + (distance<<3)) > MAX_POSSIBLE_MV) || (( drow + (distance<<3)) > MAX_POSSIBLE_MV))
{
if(dcol > drow)
distance = (MAX_POSSIBLE_MV - dcol)>>3;
else
distance = (MAX_POSSIBLE_MV - drow)>>3;
}
row_min = ref_row - distance;
row_max = ref_row + distance;
col_min = ref_col - distance;
col_max = ref_col + distance;
// Work out the mid point for the search
in_what = *(d->base_pre) + d->pre;
@ -1284,12 +1318,24 @@ int vp8_full_search_sadx3(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int er
int ref_row = ref_mv->row >> 3;
int ref_col = ref_mv->col >> 3;
int row_min = ref_row - distance;
int row_max = ref_row + distance;
int col_min = ref_col - distance;
int col_max = ref_col + distance;
int row_min, row_max, col_min, col_max;
unsigned int sad_array[3];
int drow = abs(ref_mv->row - center_mv->row);
int dcol = abs(ref_mv->col - center_mv->col);
// reduce search distance and make sure MV obtained is in range.
if (((dcol + (distance<<3)) > MAX_POSSIBLE_MV) || (( drow + (distance<<3)) > MAX_POSSIBLE_MV))
{
if(dcol > drow)
distance = (MAX_POSSIBLE_MV - dcol)>>3;
else
distance = (MAX_POSSIBLE_MV - drow)>>3;
}
row_min = ref_row - distance;
row_max = ref_row + distance;
col_min = ref_col - distance;
col_max = ref_col + distance;
// Work out the mid point for the search
in_what = *(d->base_pre) + d->pre;
@ -1409,13 +1455,25 @@ int vp8_full_search_sadx8(MACROBLOCK *x, BLOCK *b, BLOCKD *d, MV *ref_mv, int er
int ref_row = ref_mv->row >> 3;
int ref_col = ref_mv->col >> 3;
int row_min = ref_row - distance;
int row_max = ref_row + distance;
int col_min = ref_col - distance;
int col_max = ref_col + distance;
int row_min, row_max, col_min, col_max;
unsigned short sad_array8[8];
unsigned int sad_array[3];
int drow = abs(ref_mv->row - center_mv->row);
int dcol = abs(ref_mv->col - center_mv->col);
// reduce search distance and make sure MV obtained is in range.
if (((dcol + (distance<<3)) > MAX_POSSIBLE_MV) || (( drow + (distance<<3)) > MAX_POSSIBLE_MV))
{
if(dcol > drow)
distance = (MAX_POSSIBLE_MV - dcol)>>3;
else
distance = (MAX_POSSIBLE_MV - drow)>>3;
}
row_min = ref_row - distance;
row_max = ref_row + distance;
col_min = ref_col - distance;
col_max = ref_col + distance;
// Work out the mid point for the search
in_what = *(d->base_pre) + d->pre;

View File

@ -24,7 +24,7 @@ extern void accum_mv_refs(MB_PREDICTION_MODE, const int near_mv_ref_cts[4]);
#define MAX_MVSEARCH_STEPS 8 // The maximum number of steps in a step search given the largest allowed initial step
#define MAX_FULL_PEL_VAL ((1 << (MAX_MVSEARCH_STEPS+3)) - 8) // Max full pel mv specified in 1/8 pel units
#define MAX_FIRST_STEP (1 << (MAX_MVSEARCH_STEPS-1)) // Maximum size of the first step in full pel units
#define MAX_POSSIBLE_MV (1 << 11) // Maximum MV in 1/8 pel units
extern void print_mode_context(void);
extern int vp8_mv_bit_cost(MV *mv, MV *ref, int *mvcost[2], int Weight);

View File

@ -4220,8 +4220,7 @@ static void encode_frame_to_data_rate
// Update the GF useage maps.
// This is done after completing the compression of a frame when all modes etc. are finalized but before loop filter
vp8_update_gf_useage_maps(cpi, cm, &cpi->mb);
////////////////////////////////
////////////////////////////////
// This frame's MVs are saved and will be used in next frame's MV prediction.
if(cm->show_frame) //do not save for altref frame
{
@ -4230,21 +4229,6 @@ static void encode_frame_to_data_rate
MODE_INFO *tmp = cm->mip; //point to beginning of allocated MODE_INFO arrays.
//static int last_video_frame = 0;
/*
if (cm->current_video_frame == 0) //first frame: set to 0
{
for (mb_row = 0; mb_row < cm->mb_rows+1; mb_row ++)
{
for (mb_col = 0; mb_col < cm->mb_cols+1; mb_col ++)
{
cpi->lfmv[mb_col + mb_row*(cm->mode_info_stride)].as_int = 0;
cpi->lf_ref_frame_sign_bias[mb_col + mb_row*(cm->mode_info_stride)] = 0;
cpi->lf_ref_frame[mb_col + mb_row*(cm->mode_info_stride)] = 0;
}
}
}else
*/
if(cm->frame_type != KEY_FRAME)
{
for (mb_row = 0; mb_row < cm->mb_rows+1; mb_row ++)
@ -4256,20 +4240,12 @@ static void encode_frame_to_data_rate
cpi->lf_ref_frame_sign_bias[mb_col + mb_row*(cm->mode_info_stride)] = cm->ref_frame_sign_bias[tmp->mbmi.ref_frame];
cpi->lf_ref_frame[mb_col + mb_row*(cm->mode_info_stride)] = tmp->mbmi.ref_frame;
//printf("[%d, %d] ", cpi->lfmv[mb_col + mb_row*(cm->mode_info_stride-1)].as_mv.row, cpi->lfmv[mb_col + mb_row*(cm->mode_info_stride-1)].as_mv.col);
tmp++;
}
}
//last_video_frame = cm->current_video_frame;
}
}
//printf("after: %d %d \n", cm->current_video_frame, cm->show_frame );
// Update the GF useage maps.
// This is done after completing the compression of a frame when all modes etc. are finalized but before loop filter

View File

@ -1344,8 +1344,6 @@ static int vp8_rd_pick_best_mbsegmentation(VP8_COMP *cpi, MACROBLOCK *x,
}
/////////////////////////
static void mv_bias(const MODE_INFO *x, int refframe, int_mv *mvp, const int *ref_frame_sign_bias)
{
MV xmv;
@ -1884,6 +1882,16 @@ int vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
vp8_mv_pred(cpi, &x->e_mbd, x->e_mbd.mode_info_context, &mvp,
x->e_mbd.mode_info_context->mbmi.ref_frame, cpi->common.ref_frame_sign_bias, &sr, &near_sadidx[0]);
/* adjust mvp to make sure it is within MV range */
if(mvp.row > best_ref_mv.row + MAX_POSSIBLE_MV)
mvp.row = best_ref_mv.row + MAX_POSSIBLE_MV;
if(mvp.row < best_ref_mv.row - MAX_POSSIBLE_MV)
mvp.row = best_ref_mv.row - MAX_POSSIBLE_MV;
if(mvp.col > best_ref_mv.col + MAX_POSSIBLE_MV)
mvp.col = best_ref_mv.col + MAX_POSSIBLE_MV;
if(mvp.col < best_ref_mv.col - MAX_POSSIBLE_MV)
mvp.col = best_ref_mv.col - MAX_POSSIBLE_MV;
}
// Estimate the reference frame signaling cost and add it to the rolling cost variable.
@ -2163,13 +2171,6 @@ int vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
{
int sadpb = x->sadperbit16 >> 2;
thissme = cpi->full_search_sad(x, b, d, &full_mvp, sadpb, search_range, &cpi->fn_ptr[BLOCK_16X16], x->mvcost, x->mvsadcost,&best_ref_mv);
/*
MV dia_ref_mv;
dia_ref_mv.row = d->bmi.mv.as_mv.row << 3;
dia_ref_mv.col = d->bmi.mv.as_mv.col << 3;
thissme = cpi->full_search_sad(x, b, d, &dia_ref_mv, sadpb, search_range, &cpi->fn_ptr[BLOCK_16X16], x->mvcost, x->mvsadcost,&best_ref_mv);
*/
}
// Barrier threshold to initiating full search

View File

@ -131,6 +131,7 @@ static void tokenize2nd_order_b
t->Token = x;
t->context_tree = cpi->common.fc.coef_probs [type] [band] [pt];
t->skip_eob_node = pt == 0 && ((band > 0 && type > 0) || (band > 1 && type == 0));
++cpi->coef_counts [type] [band] [pt] [x];
@ -181,6 +182,7 @@ static void tokenize1st_order_b
t->Token = x;
t->context_tree = cpi->common.fc.coef_probs [type] [band] [pt];
t->skip_eob_node = pt == 0 && ((band > 0 && type > 0) || (band > 1 && type == 0));
++cpi->coef_counts [type] [band] [pt] [x];

View File

@ -26,9 +26,9 @@ typedef struct
typedef struct
{
const vp8_prob *context_tree;
char skip_eob_node;
char Token;
short Extra;
unsigned char Token;
unsigned char skip_eob_node;
} TOKENEXTRA;
int rd_cost_mby(MACROBLOCKD *);