Fixed duplicate checking for merge cand and some cleanup

This commit is contained in:
Marko Viitanen 2015-03-31 12:23:46 +03:00
parent 004e8082ab
commit 06bc4f3d5e
3 changed files with 15 additions and 11 deletions

View file

@ -1130,7 +1130,6 @@ void encoder_compute_stats(encoder_state_t *state, FILE * const recout, uint32_t
void encoder_next_frame(encoder_state_t *state) { void encoder_next_frame(encoder_state_t *state) {
const encoder_control_t * const encoder = state->encoder_control; const encoder_control_t * const encoder = state->encoder_control;
int8_t use_as_ref[8] = { 1, 0, 1, 0, 1, 0, 1, 0 };
//Blocking call //Blocking call
threadqueue_waitfor(encoder->threadqueue, state->tqj_bitstream_written); threadqueue_waitfor(encoder->threadqueue, state->tqj_bitstream_written);

View file

@ -414,7 +414,7 @@ void inter_get_mv_cand(const encoder_state_t * const state, int32_t x, int32_t y
#define CALCULATE_SCALE(cu,tb,td) ((tb * ((0x4000 + (abs(td)>>1))/td) + 32) >> 6) #define CALCULATE_SCALE(cu,tb,td) ((tb * ((0x4000 + (abs(td)>>1))/td) + 32) >> 6)
#define APPLY_MV_SCALING(cu, cand, list) {int td = state->global->poc - state->global->ref->images[(cu)->inter.mv_ref[list]]->poc;\ #define APPLY_MV_SCALING(cu, cand, list) {int td = state->global->poc - state->global->ref->images[(cu)->inter.mv_ref[list]]->poc;\
int tb = state->global->poc - state->global->ref->images[cur_cu->inter.mv_ref[cur_cu->inter.mv_dir-1]]->poc;\ int tb = state->global->poc - state->global->ref->images[cur_cu->inter.mv_ref[(cur_cu->inter.mv_dir-1)&1]]->poc;\
if (td != tb) { \ if (td != tb) { \
int scale = CALCULATE_SCALE(cu,tb,td); \ int scale = CALCULATE_SCALE(cu,tb,td); \
mv_cand[cand][0] = ((scale * (cu)->inter.mv[list][0] + 127 + (scale * (cu)->inter.mv[list][0] < 0)) >> 8 ); \ mv_cand[cand][0] = ((scale * (cu)->inter.mv[list][0] + 127 + (scale * (cu)->inter.mv[list][0] < 0)) >> 8 ); \
@ -595,11 +595,11 @@ uint8_t inter_get_merge_cand(const encoder_state_t * const state, int32_t x, int
#define CHECK_DUPLICATE(CU1,CU2) {duplicate = 0; if ((CU2) && (CU2)->type == CU_INTER && \ #define CHECK_DUPLICATE(CU1,CU2) {duplicate = 0; if ((CU2) && (CU2)->type == CU_INTER && \
(!((CU1)->inter.mv_dir & 1) || \ (!(((CU1)->inter.mv_dir & 1) && ((CU2)->inter.mv_dir & 1)) || \
((CU1)->inter.mv[0][0] == (CU2)->inter.mv[0][0] && \ ((CU1)->inter.mv[0][0] == (CU2)->inter.mv[0][0] && \
(CU1)->inter.mv[0][1] == (CU2)->inter.mv[0][1] && \ (CU1)->inter.mv[0][1] == (CU2)->inter.mv[0][1] && \
(CU1)->inter.mv_ref[0] == (CU2)->inter.mv_ref[0]) ) && \ (CU1)->inter.mv_ref[0] == (CU2)->inter.mv_ref[0]) ) && \
(!((CU1)->inter.mv_dir & 2) || \ (!(((CU1)->inter.mv_dir & 2) && ((CU2)->inter.mv_dir & 2)) || \
((CU1)->inter.mv[1][0] == (CU2)->inter.mv[1][0] && \ ((CU1)->inter.mv[1][0] == (CU2)->inter.mv[1][0] && \
(CU1)->inter.mv[1][1] == (CU2)->inter.mv[1][1] && \ (CU1)->inter.mv[1][1] == (CU2)->inter.mv[1][1] && \
(CU1)->inter.mv_ref[1] == (CU2)->inter.mv_ref[1])) \ (CU1)->inter.mv_ref[1] == (CU2)->inter.mv_ref[1])) \

View file

@ -1022,8 +1022,13 @@ static int search_cu_inter(const encoder_state_t * const state, int x, int y, in
int mid_y_cu = (y + (LCU_WIDTH >> (depth+1))) / 8; int mid_y_cu = (y + (LCU_WIDTH >> (depth+1))) / 8;
cu_info_t *ref_cu = &state->global->ref->cu_arrays[ref_idx]->data[mid_x_cu + mid_y_cu * (frame->width_in_lcu << MAX_DEPTH)]; cu_info_t *ref_cu = &state->global->ref->cu_arrays[ref_idx]->data[mid_x_cu + mid_y_cu * (frame->width_in_lcu << MAX_DEPTH)];
if (ref_cu->type == CU_INTER) { if (ref_cu->type == CU_INTER) {
mv.x = ref_cu->inter.mv[0][0]; if (ref_cu->inter.mv_dir & 1) {
mv.y = ref_cu->inter.mv[0][1]; mv.x = ref_cu->inter.mv[0][0];
mv.y = ref_cu->inter.mv[0][1];
} else {
mv.x = ref_cu->inter.mv[1][0];
mv.y = ref_cu->inter.mv[1][1];
}
} }
} }
@ -1091,7 +1096,7 @@ static int search_cu_inter(const encoder_state_t * const state, int x, int y, in
cur_cu->inter.mvd[ref_list][0] = (int16_t)mvd.x; cur_cu->inter.mvd[ref_list][0] = (int16_t)mvd.x;
cur_cu->inter.mvd[ref_list][1] = (int16_t)mvd.y; cur_cu->inter.mvd[ref_list][1] = (int16_t)mvd.y;
cur_cu->inter.cost = temp_cost; cur_cu->inter.cost = temp_cost;
cur_cu->inter.bitcost = temp_bitcost + cur_cu->inter.mv_dir - 1 + cur_cu->inter.mv_ref_coded[cur_cu->inter.mv_dir - 1]; cur_cu->inter.bitcost = temp_bitcost + cur_cu->inter.mv_dir - 1 + cur_cu->inter.mv_ref_coded[ref_list];
cur_cu->inter.mv_cand = cu_mv_cand; cur_cu->inter.mv_cand = cu_mv_cand;
} }
} }
@ -2430,10 +2435,10 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth,
int y_in_lcu = ((y + temp_y) & ((LCU_WIDTH>>1)-1)); int y_in_lcu = ((y + temp_y) & ((LCU_WIDTH>>1)-1));
for (temp_x = 0; temp_x < LCU_WIDTH >> (depth+1); ++temp_x) { for (temp_x = 0; temp_x < LCU_WIDTH >> (depth+1); ++temp_x) {
int x_in_lcu = ((x + temp_x) & ((LCU_WIDTH>>1)-1)); int x_in_lcu = ((x + temp_x) & ((LCU_WIDTH>>1)-1));
lcu->rec.u[y_in_lcu * LCU_WIDTH>>1 + x_in_lcu] = (pixel_t)((int)lcu->rec.u[y_in_lcu * LCU_WIDTH>>1 + x_in_lcu] + lcu->rec.u[y_in_lcu * (LCU_WIDTH >> 1) + x_in_lcu] = (pixel_t)((int)lcu->rec.u[y_in_lcu * (LCU_WIDTH >> 1) + x_in_lcu] +
(int)temp_lcu_u[y_in_lcu * LCU_WIDTH>>1 + x_in_lcu]) >> 1; (int)temp_lcu_u[y_in_lcu * (LCU_WIDTH >> 1) + x_in_lcu]) >> 1;
lcu->rec.v[y_in_lcu * LCU_WIDTH >> 1 + x_in_lcu] = (pixel_t)((int)lcu->rec.v[y_in_lcu * LCU_WIDTH >> 1 + x_in_lcu] + lcu->rec.v[y_in_lcu * (LCU_WIDTH >> 1) + x_in_lcu] = (pixel_t)((int)lcu->rec.v[y_in_lcu * (LCU_WIDTH >> 1) + x_in_lcu] +
(int)temp_lcu_v[y_in_lcu * LCU_WIDTH >> 1 + x_in_lcu]) >> 1; (int)temp_lcu_v[y_in_lcu * (LCU_WIDTH >> 1) + x_in_lcu]) >> 1;
} }
} }
FREE_POINTER(temp_lcu_y); FREE_POINTER(temp_lcu_y);