diff options
Diffstat (limited to 'vp8/encoder')
-rw-r--r-- | vp8/encoder/arm/armv5te/vp8_packtokens_armv5.asm | 18 | ||||
-rw-r--r-- | vp8/encoder/arm/armv5te/vp8_packtokens_mbrow_armv5.asm | 13 | ||||
-rw-r--r-- | vp8/encoder/arm/armv5te/vp8_packtokens_partitions_armv5.asm | 13 | ||||
-rw-r--r-- | vp8/encoder/arm/vpx_vp8_enc_asm_offsets.c | 5 | ||||
-rw-r--r-- | vp8/encoder/ethreading.c | 1 | ||||
-rw-r--r-- | vp8/encoder/mcomp.c | 94 | ||||
-rw-r--r-- | vp8/encoder/mcomp.h | 2 | ||||
-rw-r--r-- | vp8/encoder/onyx_if.c | 26 | ||||
-rw-r--r-- | vp8/encoder/rdopt.c | 19 | ||||
-rw-r--r-- | vp8/encoder/tokenize.c | 2 | ||||
-rw-r--r-- | vp8/encoder/tokenize.h | 4 |
11 files changed, 115 insertions, 82 deletions
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/ethreading.c b/vp8/encoder/ethreading.c index a40897ba2..0cab70253 100644 --- a/vp8/encoder/ethreading.c +++ b/vp8/encoder/ethreading.c @@ -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; diff --git a/vp8/encoder/mcomp.c b/vp8/encoder/mcomp.c index b9d86a20e..c5209ff85 100644 --- a/vp8/encoder/mcomp.c +++ b/vp8/encoder/mcomp.c @@ -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; diff --git a/vp8/encoder/mcomp.h b/vp8/encoder/mcomp.h index b54fe7377..122debcae 100644 --- a/vp8/encoder/mcomp.h +++ b/vp8/encoder/mcomp.h @@ -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); diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c index 37f22fe7e..6f912c99d 100644 --- a/vp8/encoder/onyx_if.c +++ b/vp8/encoder/onyx_if.c @@ -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 diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c index 9b8b3b326..aa17b31e3 100644 --- a/vp8/encoder/rdopt.c +++ b/vp8/encoder/rdopt.c @@ -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 diff --git a/vp8/encoder/tokenize.c b/vp8/encoder/tokenize.c index 50dabf4a5..5e018634f 100644 --- a/vp8/encoder/tokenize.c +++ b/vp8/encoder/tokenize.c @@ -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]; diff --git a/vp8/encoder/tokenize.h b/vp8/encoder/tokenize.h index cb5b15405..ed5eb0ce9 100644 --- a/vp8/encoder/tokenize.h +++ b/vp8/encoder/tokenize.h @@ -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 *); |