| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 MV mvp_full; | 125 MV mvp_full; |
| 126 const int ref = mbmi->ref_frame[0]; | 126 const int ref = mbmi->ref_frame[0]; |
| 127 const MV ref_mv = mbmi->ref_mvs[ref][0].as_mv; | 127 const MV ref_mv = mbmi->ref_mvs[ref][0].as_mv; |
| 128 int dis; | 128 int dis; |
| 129 int rate_mode; | 129 int rate_mode; |
| 130 const int tmp_col_min = x->mv_col_min; | 130 const int tmp_col_min = x->mv_col_min; |
| 131 const int tmp_col_max = x->mv_col_max; | 131 const int tmp_col_max = x->mv_col_max; |
| 132 const int tmp_row_min = x->mv_row_min; | 132 const int tmp_row_min = x->mv_row_min; |
| 133 const int tmp_row_max = x->mv_row_max; | 133 const int tmp_row_max = x->mv_row_max; |
| 134 int rv = 0; | 134 int rv = 0; |
| 135 int sad_list[5]; | 135 int cost_list[5]; |
| 136 const YV12_BUFFER_CONFIG *scaled_ref_frame = vp9_get_scaled_ref_frame(cpi, | 136 const YV12_BUFFER_CONFIG *scaled_ref_frame = vp9_get_scaled_ref_frame(cpi, |
| 137 ref); | 137 ref); |
| 138 if (cpi->common.show_frame && | 138 if (cpi->common.show_frame && |
| 139 (x->pred_mv_sad[ref] >> 3) > x->pred_mv_sad[LAST_FRAME]) | 139 (x->pred_mv_sad[ref] >> 3) > x->pred_mv_sad[LAST_FRAME]) |
| 140 return rv; | 140 return rv; |
| 141 | 141 |
| 142 if (scaled_ref_frame) { | 142 if (scaled_ref_frame) { |
| 143 int i; | 143 int i; |
| 144 // Swap out the reference frame for a version that's been scaled to | 144 // Swap out the reference frame for a version that's been scaled to |
| 145 // match the resolution of the current frame, allowing the existing | 145 // match the resolution of the current frame, allowing the existing |
| 146 // motion search code to be used without additional modifications. | 146 // motion search code to be used without additional modifications. |
| 147 for (i = 0; i < MAX_MB_PLANE; i++) | 147 for (i = 0; i < MAX_MB_PLANE; i++) |
| 148 backup_yv12[i] = xd->plane[i].pre[0]; | 148 backup_yv12[i] = xd->plane[i].pre[0]; |
| 149 vp9_setup_pre_planes(xd, 0, scaled_ref_frame, mi_row, mi_col, NULL); | 149 vp9_setup_pre_planes(xd, 0, scaled_ref_frame, mi_row, mi_col, NULL); |
| 150 } | 150 } |
| 151 vp9_set_mv_search_range(x, &ref_mv); | 151 vp9_set_mv_search_range(x, &ref_mv); |
| 152 | 152 |
| 153 assert(x->mv_best_ref_index[ref] <= 2); | 153 assert(x->mv_best_ref_index[ref] <= 2); |
| 154 if (x->mv_best_ref_index[ref] < 2) | 154 if (x->mv_best_ref_index[ref] < 2) |
| 155 mvp_full = mbmi->ref_mvs[ref][x->mv_best_ref_index[ref]].as_mv; | 155 mvp_full = mbmi->ref_mvs[ref][x->mv_best_ref_index[ref]].as_mv; |
| 156 else | 156 else |
| 157 mvp_full = x->pred_mv[ref]; | 157 mvp_full = x->pred_mv[ref]; |
| 158 | 158 |
| 159 mvp_full.col >>= 3; | 159 mvp_full.col >>= 3; |
| 160 mvp_full.row >>= 3; | 160 mvp_full.row >>= 3; |
| 161 | 161 |
| 162 vp9_full_pixel_search(cpi, x, bsize, &mvp_full, step_param, sadpb, | 162 vp9_full_pixel_search(cpi, x, bsize, &mvp_full, step_param, sadpb, |
| 163 cond_sad_list(cpi, sad_list), | 163 cond_cost_list(cpi, cost_list), |
| 164 &ref_mv, &tmp_mv->as_mv, INT_MAX, 0); | 164 &ref_mv, &tmp_mv->as_mv, INT_MAX, 0); |
| 165 | 165 |
| 166 x->mv_col_min = tmp_col_min; | 166 x->mv_col_min = tmp_col_min; |
| 167 x->mv_col_max = tmp_col_max; | 167 x->mv_col_max = tmp_col_max; |
| 168 x->mv_row_min = tmp_row_min; | 168 x->mv_row_min = tmp_row_min; |
| 169 x->mv_row_max = tmp_row_max; | 169 x->mv_row_max = tmp_row_max; |
| 170 | 170 |
| 171 // calculate the bit cost on motion vector | 171 // calculate the bit cost on motion vector |
| 172 mvp_full.row = tmp_mv->as_mv.row * 8; | 172 mvp_full.row = tmp_mv->as_mv.row * 8; |
| 173 mvp_full.col = tmp_mv->as_mv.col * 8; | 173 mvp_full.col = tmp_mv->as_mv.col * 8; |
| 174 | 174 |
| 175 *rate_mv = vp9_mv_bit_cost(&mvp_full, &ref_mv, | 175 *rate_mv = vp9_mv_bit_cost(&mvp_full, &ref_mv, |
| 176 x->nmvjointcost, x->mvcost, MV_COST_WEIGHT); | 176 x->nmvjointcost, x->mvcost, MV_COST_WEIGHT); |
| 177 | 177 |
| 178 rate_mode = cpi->inter_mode_cost[mbmi->mode_context[ref]] | 178 rate_mode = cpi->inter_mode_cost[mbmi->mode_context[ref]] |
| 179 [INTER_OFFSET(NEWMV)]; | 179 [INTER_OFFSET(NEWMV)]; |
| 180 rv = !(RDCOST(x->rdmult, x->rddiv, (*rate_mv + rate_mode), 0) > | 180 rv = !(RDCOST(x->rdmult, x->rddiv, (*rate_mv + rate_mode), 0) > |
| 181 best_rd_sofar); | 181 best_rd_sofar); |
| 182 | 182 |
| 183 if (rv) { | 183 if (rv) { |
| 184 cpi->find_fractional_mv_step(x, &tmp_mv->as_mv, &ref_mv, | 184 cpi->find_fractional_mv_step(x, &tmp_mv->as_mv, &ref_mv, |
| 185 cpi->common.allow_high_precision_mv, | 185 cpi->common.allow_high_precision_mv, |
| 186 x->errorperbit, | 186 x->errorperbit, |
| 187 &cpi->fn_ptr[bsize], | 187 &cpi->fn_ptr[bsize], |
| 188 cpi->sf.mv.subpel_force_stop, | 188 cpi->sf.mv.subpel_force_stop, |
| 189 cpi->sf.mv.subpel_iters_per_step, | 189 cpi->sf.mv.subpel_iters_per_step, |
| 190 cond_sad_list(cpi, sad_list), | 190 cond_cost_list(cpi, cost_list), |
| 191 x->nmvjointcost, x->mvcost, | 191 x->nmvjointcost, x->mvcost, |
| 192 &dis, &x->pred_sse[ref], NULL, 0, 0); | 192 &dis, &x->pred_sse[ref], NULL, 0, 0); |
| 193 x->pred_mv[ref] = tmp_mv->as_mv; | 193 x->pred_mv[ref] = tmp_mv->as_mv; |
| 194 } | 194 } |
| 195 | 195 |
| 196 if (scaled_ref_frame) { | 196 if (scaled_ref_frame) { |
| 197 int i; | 197 int i; |
| 198 for (i = 0; i < MAX_MB_PLANE; i++) | 198 for (i = 0; i < MAX_MB_PLANE; i++) |
| 199 xd->plane[i].pre[0] = backup_yv12[i]; | 199 xd->plane[i].pre[0] = backup_yv12[i]; |
| 200 } | 200 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 228 else | 228 else |
| 229 x->skip_txfm[0] = 0; | 229 x->skip_txfm[0] = 0; |
| 230 | 230 |
| 231 if (cpi->common.tx_mode == TX_MODE_SELECT) { | 231 if (cpi->common.tx_mode == TX_MODE_SELECT) { |
| 232 if (sse > (var << 2)) | 232 if (sse > (var << 2)) |
| 233 xd->mi[0].src_mi->mbmi.tx_size = | 233 xd->mi[0].src_mi->mbmi.tx_size = |
| 234 MIN(max_txsize_lookup[bsize], | 234 MIN(max_txsize_lookup[bsize], |
| 235 tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); | 235 tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); |
| 236 else | 236 else |
| 237 xd->mi[0].src_mi->mbmi.tx_size = TX_8X8; | 237 xd->mi[0].src_mi->mbmi.tx_size = TX_8X8; |
| 238 |
| 239 if (cpi->sf.partition_search_type == VAR_BASED_PARTITION && |
| 240 xd->mi[0].src_mi->mbmi.tx_size > TX_16X16) |
| 241 xd->mi[0].src_mi->mbmi.tx_size = TX_16X16; |
| 238 } else { | 242 } else { |
| 239 xd->mi[0].src_mi->mbmi.tx_size = | 243 xd->mi[0].src_mi->mbmi.tx_size = |
| 240 MIN(max_txsize_lookup[bsize], | 244 MIN(max_txsize_lookup[bsize], |
| 241 tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); | 245 tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); |
| 242 } | 246 } |
| 243 | 247 |
| 248 #if CONFIG_VP9_HIGHBITDEPTH |
| 249 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { |
| 250 vp9_model_rd_from_var_lapndz(sse - var, 1 << num_pels_log2_lookup[bsize], |
| 251 dc_quant >> (xd->bd - 5), &rate, &dist); |
| 252 } else { |
| 253 vp9_model_rd_from_var_lapndz(sse - var, 1 << num_pels_log2_lookup[bsize], |
| 254 dc_quant >> 3, &rate, &dist); |
| 255 } |
| 256 #else |
| 244 vp9_model_rd_from_var_lapndz(sse - var, 1 << num_pels_log2_lookup[bsize], | 257 vp9_model_rd_from_var_lapndz(sse - var, 1 << num_pels_log2_lookup[bsize], |
| 245 dc_quant >> 3, &rate, &dist); | 258 dc_quant >> 3, &rate, &dist); |
| 259 #endif // CONFIG_VP9_HIGHBITDEPTH |
| 260 |
| 246 *out_rate_sum = rate >> 1; | 261 *out_rate_sum = rate >> 1; |
| 247 *out_dist_sum = dist << 3; | 262 *out_dist_sum = dist << 3; |
| 248 | 263 |
| 249 vp9_model_rd_from_var_lapndz(var, 1 << num_pels_log2_lookup[bsize], | 264 #if CONFIG_VP9_HIGHBITDEPTH |
| 250 ac_quant >> 3, &rate, &dist); | 265 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { |
| 266 vp9_model_rd_from_var_lapndz(var, |
| 267 1 << num_pels_log2_lookup[bsize], |
| 268 ac_quant >> (xd->bd - 5), |
| 269 &rate, |
| 270 &dist); |
| 271 } else { |
| 272 vp9_model_rd_from_var_lapndz(var, |
| 273 1 << num_pels_log2_lookup[bsize], |
| 274 ac_quant >> 3, |
| 275 &rate, |
| 276 &dist); |
| 277 } |
| 278 #else |
| 279 vp9_model_rd_from_var_lapndz(var, |
| 280 1 << num_pels_log2_lookup[bsize], |
| 281 ac_quant >> 3, |
| 282 &rate, |
| 283 &dist); |
| 284 #endif // CONFIG_VP9_HIGHBITDEPTH |
| 285 |
| 251 *out_rate_sum += rate; | 286 *out_rate_sum += rate; |
| 252 *out_dist_sum += dist << 4; | 287 *out_dist_sum += dist << 4; |
| 253 } | 288 } |
| 254 | 289 |
| 255 static int get_pred_buffer(PRED_BUFFER *p, int len) { | 290 static int get_pred_buffer(PRED_BUFFER *p, int len) { |
| 256 int i; | 291 int i; |
| 257 | 292 |
| 258 for (i = 0; i < len; i++) { | 293 for (i = 0; i < len; i++) { |
| 259 if (!p[i].in_use) { | 294 if (!p[i].in_use) { |
| 260 p[i].in_use = 1; | 295 p[i].in_use = 1; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 286 // Skipping threshold for dc. | 321 // Skipping threshold for dc. |
| 287 unsigned int thresh_dc; | 322 unsigned int thresh_dc; |
| 288 if (x->encode_breakout > 0) { | 323 if (x->encode_breakout > 0) { |
| 289 // Set a maximum for threshold to avoid big PSNR loss in low bit rate | 324 // Set a maximum for threshold to avoid big PSNR loss in low bit rate |
| 290 // case. Use extreme low threshold for static frames to limit | 325 // case. Use extreme low threshold for static frames to limit |
| 291 // skipping. | 326 // skipping. |
| 292 const unsigned int max_thresh = 36000; | 327 const unsigned int max_thresh = 36000; |
| 293 // The encode_breakout input | 328 // The encode_breakout input |
| 294 const unsigned int min_thresh = | 329 const unsigned int min_thresh = |
| 295 MIN(((unsigned int)x->encode_breakout << 4), max_thresh); | 330 MIN(((unsigned int)x->encode_breakout << 4), max_thresh); |
| 331 #if CONFIG_VP9_HIGHBITDEPTH |
| 332 const int shift = 2 * xd->bd - 16; |
| 333 #endif |
| 296 | 334 |
| 297 // Calculate threshold according to dequant value. | 335 // Calculate threshold according to dequant value. |
| 298 thresh_ac = (xd->plane[0].dequant[1] * xd->plane[0].dequant[1]) / 9; | 336 thresh_ac = (xd->plane[0].dequant[1] * xd->plane[0].dequant[1]) / 9; |
| 337 #if CONFIG_VP9_HIGHBITDEPTH |
| 338 if ((xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) && shift > 0) { |
| 339 thresh_ac = ROUND_POWER_OF_TWO(thresh_ac, shift); |
| 340 } |
| 341 #endif // CONFIG_VP9_HIGHBITDEPTH |
| 299 thresh_ac = clamp(thresh_ac, min_thresh, max_thresh); | 342 thresh_ac = clamp(thresh_ac, min_thresh, max_thresh); |
| 300 | 343 |
| 301 // Adjust ac threshold according to partition size. | 344 // Adjust ac threshold according to partition size. |
| 302 thresh_ac >>= | 345 thresh_ac >>= |
| 303 8 - (b_width_log2(bsize) + b_height_log2(bsize)); | 346 8 - (b_width_log2_lookup[bsize] + b_height_log2_lookup[bsize]); |
| 304 | 347 |
| 305 thresh_dc = (xd->plane[0].dequant[0] * xd->plane[0].dequant[0] >> 6); | 348 thresh_dc = (xd->plane[0].dequant[0] * xd->plane[0].dequant[0] >> 6); |
| 349 #if CONFIG_VP9_HIGHBITDEPTH |
| 350 if ((xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) && shift > 0) { |
| 351 thresh_dc = ROUND_POWER_OF_TWO(thresh_dc, shift); |
| 352 } |
| 353 #endif // CONFIG_VP9_HIGHBITDEPTH |
| 306 } else { | 354 } else { |
| 307 thresh_ac = 0; | 355 thresh_ac = 0; |
| 308 thresh_dc = 0; | 356 thresh_dc = 0; |
| 309 } | 357 } |
| 310 | 358 |
| 311 // Y skipping condition checking for ac and dc. | 359 // Y skipping condition checking for ac and dc. |
| 312 if (var <= thresh_ac && (sse - var) <= thresh_dc) { | 360 if (var <= thresh_ac && (sse - var) <= thresh_dc) { |
| 313 unsigned int sse_u, sse_v; | 361 unsigned int sse_u, sse_v; |
| 314 unsigned int var_u, var_v; | 362 unsigned int var_u, var_v; |
| 315 | 363 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 int64_t dist; | 430 int64_t dist; |
| 383 unsigned int var_y, sse_y; | 431 unsigned int var_y, sse_y; |
| 384 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j); | 432 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j); |
| 385 assert(plane == 0); | 433 assert(plane == 0); |
| 386 (void) plane; | 434 (void) plane; |
| 387 | 435 |
| 388 p->src.buf = &src_buf_base[4 * (j * src_stride + i)]; | 436 p->src.buf = &src_buf_base[4 * (j * src_stride + i)]; |
| 389 pd->dst.buf = &dst_buf_base[4 * (j * dst_stride + i)]; | 437 pd->dst.buf = &dst_buf_base[4 * (j * dst_stride + i)]; |
| 390 // Use source buffer as an approximation for the fully reconstructed buffer. | 438 // Use source buffer as an approximation for the fully reconstructed buffer. |
| 391 vp9_predict_intra_block(xd, block >> (2 * tx_size), | 439 vp9_predict_intra_block(xd, block >> (2 * tx_size), |
| 392 b_width_log2(plane_bsize), | 440 b_width_log2_lookup[plane_bsize], |
| 393 tx_size, args->mode, | 441 tx_size, args->mode, |
| 394 p->src.buf, src_stride, | 442 p->src.buf, src_stride, |
| 395 pd->dst.buf, dst_stride, | 443 pd->dst.buf, dst_stride, |
| 396 i, j, 0); | 444 i, j, 0); |
| 397 // This procedure assumes zero offset from p->src.buf and pd->dst.buf. | 445 // This procedure assumes zero offset from p->src.buf and pd->dst.buf. |
| 398 model_rd_for_sb_y(cpi, bsize_tx, x, xd, &rate, &dist, &var_y, &sse_y); | 446 model_rd_for_sb_y(cpi, bsize_tx, x, xd, &rate, &dist, &var_y, &sse_y); |
| 399 p->src.buf = src_buf_base; | 447 p->src.buf = src_buf_base; |
| 400 pd->dst.buf = dst_buf_base; | 448 pd->dst.buf = dst_buf_base; |
| 401 args->rate += rate; | 449 args->rate += rate; |
| 402 args->dist += dist; | 450 args->dist += dist; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 431 static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG, | 479 static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG, |
| 432 VP9_ALT_FLAG }; | 480 VP9_ALT_FLAG }; |
| 433 int64_t best_rd = INT64_MAX; | 481 int64_t best_rd = INT64_MAX; |
| 434 int64_t this_rd = INT64_MAX; | 482 int64_t this_rd = INT64_MAX; |
| 435 uint8_t skip_txfm = 0; | 483 uint8_t skip_txfm = 0; |
| 436 int rate = INT_MAX; | 484 int rate = INT_MAX; |
| 437 int64_t dist = INT64_MAX; | 485 int64_t dist = INT64_MAX; |
| 438 // var_y and sse_y are saved to be used in skipping checking | 486 // var_y and sse_y are saved to be used in skipping checking |
| 439 unsigned int var_y = UINT_MAX; | 487 unsigned int var_y = UINT_MAX; |
| 440 unsigned int sse_y = UINT_MAX; | 488 unsigned int sse_y = UINT_MAX; |
| 441 | 489 // Reduce the intra cost penalty for small blocks (<=16x16). |
| 442 const int intra_cost_penalty = | 490 const int reduction_fac = |
| 443 20 * vp9_dc_quant(cm->base_qindex, cm->y_dc_delta_q, cm->bit_depth); | 491 (cpi->sf.partition_search_type == VAR_BASED_PARTITION && |
| 492 bsize <= BLOCK_16X16) ? 4 : 1; |
| 493 const int intra_cost_penalty = vp9_get_intra_cost_penalty( |
| 494 cm->base_qindex, cm->y_dc_delta_q, cm->bit_depth) / reduction_fac; |
| 444 const int64_t inter_mode_thresh = RDCOST(x->rdmult, x->rddiv, | 495 const int64_t inter_mode_thresh = RDCOST(x->rdmult, x->rddiv, |
| 445 intra_cost_penalty, 0); | 496 intra_cost_penalty, 0); |
| 446 const int intra_mode_cost = 50; | 497 const int intra_mode_cost = 50; |
| 447 | 498 |
| 448 const int8_t segment_id = mbmi->segment_id; | 499 const int8_t segment_id = mbmi->segment_id; |
| 449 const int *const rd_threshes = cpi->rd.threshes[segment_id][bsize]; | 500 const int *const rd_threshes = cpi->rd.threshes[segment_id][bsize]; |
| 450 const int *const rd_thresh_freq_fact = cpi->rd.thresh_freq_fact[bsize]; | 501 const int *const rd_thresh_freq_fact = cpi->rd.thresh_freq_fact[bsize]; |
| 451 INTERP_FILTER filter_ref = cm->interp_filter; | 502 INTERP_FILTER filter_ref = cm->interp_filter; |
| 452 const int bsl = mi_width_log2(bsize); | 503 const int bsl = mi_width_log2_lookup[bsize]; |
| 453 const int pred_filter_search = cm->interp_filter == SWITCHABLE ? | 504 const int pred_filter_search = cm->interp_filter == SWITCHABLE ? |
| 454 (((mi_row + mi_col) >> bsl) + | 505 (((mi_row + mi_col) >> bsl) + |
| 455 get_chessboard_index(cm->current_video_frame)) & 0x1 : 0; | 506 get_chessboard_index(cm->current_video_frame)) & 0x1 : 0; |
| 456 int const_motion[MAX_REF_FRAMES] = { 0 }; | 507 int const_motion[MAX_REF_FRAMES] = { 0 }; |
| 457 const int bh = num_4x4_blocks_high_lookup[bsize] << 2; | 508 const int bh = num_4x4_blocks_high_lookup[bsize] << 2; |
| 458 const int bw = num_4x4_blocks_wide_lookup[bsize] << 2; | 509 const int bw = num_4x4_blocks_wide_lookup[bsize] << 2; |
| 459 // For speed 6, the result of interp filter is reused later in actual encoding | 510 // For speed 6, the result of interp filter is reused later in actual encoding |
| 460 // process. | 511 // process. |
| 461 // tmp[3] points to dst buffer, and the other 3 point to allocated buffers. | 512 // tmp[3] points to dst buffer, and the other 3 point to allocated buffers. |
| 462 PRED_BUFFER tmp[4]; | 513 PRED_BUFFER tmp[4]; |
| 463 DECLARE_ALIGNED_ARRAY(16, uint8_t, pred_buf, 3 * 64 * 64); | 514 DECLARE_ALIGNED_ARRAY(16, uint8_t, pred_buf, 3 * 64 * 64); |
| 515 #if CONFIG_VP9_HIGHBITDEPTH |
| 516 DECLARE_ALIGNED_ARRAY(16, uint16_t, pred_buf_16, 3 * 64 * 64); |
| 517 #endif |
| 464 struct buf_2d orig_dst = pd->dst; | 518 struct buf_2d orig_dst = pd->dst; |
| 465 PRED_BUFFER *best_pred = NULL; | 519 PRED_BUFFER *best_pred = NULL; |
| 466 PRED_BUFFER *this_mode_pred = NULL; | 520 PRED_BUFFER *this_mode_pred = NULL; |
| 521 const int pixels_in_block = bh * bw; |
| 467 | 522 |
| 468 if (cpi->sf.reuse_inter_pred_sby) { | 523 if (cpi->sf.reuse_inter_pred_sby) { |
| 469 int i; | 524 int i; |
| 470 for (i = 0; i < 3; i++) { | 525 for (i = 0; i < 3; i++) { |
| 471 tmp[i].data = &pred_buf[bw * bh * i]; | 526 #if CONFIG_VP9_HIGHBITDEPTH |
| 527 if (cm->use_highbitdepth) |
| 528 tmp[i].data = CONVERT_TO_BYTEPTR(&pred_buf_16[pixels_in_block * i]); |
| 529 else |
| 530 tmp[i].data = &pred_buf[pixels_in_block * i]; |
| 531 #else |
| 532 tmp[i].data = &pred_buf[pixels_in_block * i]; |
| 533 #endif // CONFIG_VP9_HIGHBITDEPTH |
| 472 tmp[i].stride = bw; | 534 tmp[i].stride = bw; |
| 473 tmp[i].in_use = 0; | 535 tmp[i].in_use = 0; |
| 474 } | 536 } |
| 475 tmp[3].data = pd->dst.buf; | 537 tmp[3].data = pd->dst.buf; |
| 476 tmp[3].stride = pd->dst.stride; | 538 tmp[3].stride = pd->dst.stride; |
| 477 tmp[3].in_use = 0; | 539 tmp[3].in_use = 0; |
| 478 } | 540 } |
| 479 | 541 |
| 480 x->skip_encode = cpi->sf.skip_encode_frame && x->q_index < QIDX_SKIP_THRESH; | 542 x->skip_encode = cpi->sf.skip_encode_frame && x->q_index < QIDX_SKIP_THRESH; |
| 481 x->skip = 0; | 543 x->skip = 0; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 continue; | 612 continue; |
| 551 | 613 |
| 552 mode_rd_thresh = | 614 mode_rd_thresh = |
| 553 rd_threshes[mode_idx[ref_frame - | 615 rd_threshes[mode_idx[ref_frame - |
| 554 LAST_FRAME][INTER_OFFSET(this_mode)]]; | 616 LAST_FRAME][INTER_OFFSET(this_mode)]]; |
| 555 if (rd_less_than_thresh(best_rd, mode_rd_thresh, | 617 if (rd_less_than_thresh(best_rd, mode_rd_thresh, |
| 556 rd_thresh_freq_fact[this_mode])) | 618 rd_thresh_freq_fact[this_mode])) |
| 557 continue; | 619 continue; |
| 558 | 620 |
| 559 if (this_mode == NEWMV) { | 621 if (this_mode == NEWMV) { |
| 560 if (this_rd < (int64_t)(1 << num_pels_log2_lookup[bsize])) | 622 if (cpi->sf.partition_search_type != VAR_BASED_PARTITION && |
| 623 this_rd < (int64_t)(1 << num_pels_log2_lookup[bsize])) |
| 561 continue; | 624 continue; |
| 562 if (!combined_motion_search(cpi, x, bsize, mi_row, mi_col, | 625 if (!combined_motion_search(cpi, x, bsize, mi_row, mi_col, |
| 563 &frame_mv[NEWMV][ref_frame], | 626 &frame_mv[NEWMV][ref_frame], |
| 564 &rate_mv, best_rd)) | 627 &rate_mv, best_rd)) |
| 565 continue; | 628 continue; |
| 566 } | 629 } |
| 567 | 630 |
| 568 if (this_mode != NEARESTMV && | 631 if (this_mode != NEARESTMV && |
| 569 frame_mv[this_mode][ref_frame].as_int == | 632 frame_mv[this_mode][ref_frame].as_int == |
| 570 frame_mv[NEARESTMV][ref_frame].as_int) | 633 frame_mv[NEARESTMV][ref_frame].as_int) |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 // we are done. | 759 // we are done. |
| 697 if (best_rd < INT64_MAX) | 760 if (best_rd < INT64_MAX) |
| 698 break; | 761 break; |
| 699 } | 762 } |
| 700 | 763 |
| 701 // If best prediction is not in dst buf, then copy the prediction block from | 764 // If best prediction is not in dst buf, then copy the prediction block from |
| 702 // temp buf to dst buf. | 765 // temp buf to dst buf. |
| 703 if (best_pred != NULL && cpi->sf.reuse_inter_pred_sby && | 766 if (best_pred != NULL && cpi->sf.reuse_inter_pred_sby && |
| 704 best_pred->data != orig_dst.buf) { | 767 best_pred->data != orig_dst.buf) { |
| 705 pd->dst = orig_dst; | 768 pd->dst = orig_dst; |
| 769 #if CONFIG_VP9_HIGHBITDEPTH |
| 770 if (cm->use_highbitdepth) { |
| 771 vp9_highbd_convolve_copy(best_pred->data, bw, pd->dst.buf, pd->dst.stride, |
| 772 NULL, 0, NULL, 0, bw, bh, xd->bd); |
| 773 } else { |
| 774 vp9_convolve_copy(best_pred->data, bw, pd->dst.buf, pd->dst.stride, |
| 775 NULL, 0, NULL, 0, bw, bh); |
| 776 } |
| 777 #else |
| 706 vp9_convolve_copy(best_pred->data, bw, pd->dst.buf, pd->dst.stride, NULL, 0, | 778 vp9_convolve_copy(best_pred->data, bw, pd->dst.buf, pd->dst.stride, NULL, 0, |
| 707 NULL, 0, bw, bh); | 779 NULL, 0, bw, bh); |
| 780 #endif // CONFIG_VP9_HIGHBITDEPTH |
| 708 } | 781 } |
| 709 | 782 |
| 710 mbmi->mode = best_mode; | 783 mbmi->mode = best_mode; |
| 711 mbmi->interp_filter = best_pred_filter; | 784 mbmi->interp_filter = best_pred_filter; |
| 712 mbmi->tx_size = best_tx_size; | 785 mbmi->tx_size = best_tx_size; |
| 713 mbmi->ref_frame[0] = best_ref_frame; | 786 mbmi->ref_frame[0] = best_ref_frame; |
| 714 mbmi->mv[0].as_int = frame_mv[best_mode][best_ref_frame].as_int; | 787 mbmi->mv[0].as_int = frame_mv[best_mode][best_ref_frame].as_int; |
| 715 xd->mi[0].src_mi->bmi[0].as_mv[0].as_int = mbmi->mv[0].as_int; | 788 xd->mi[0].src_mi->bmi[0].as_mv[0].as_int = mbmi->mv[0].as_int; |
| 716 x->skip_txfm[0] = skip_txfm; | 789 x->skip_txfm[0] = skip_txfm; |
| 717 | 790 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 mbmi->uv_mode = this_mode; | 828 mbmi->uv_mode = this_mode; |
| 756 mbmi->mv[0].as_int = INVALID_MV; | 829 mbmi->mv[0].as_int = INVALID_MV; |
| 757 } else { | 830 } else { |
| 758 x->skip_txfm[0] = skip_txfm; | 831 x->skip_txfm[0] = skip_txfm; |
| 759 } | 832 } |
| 760 } | 833 } |
| 761 if (cpi->sf.reuse_inter_pred_sby) | 834 if (cpi->sf.reuse_inter_pred_sby) |
| 762 pd->dst = orig_dst; | 835 pd->dst = orig_dst; |
| 763 } | 836 } |
| 764 } | 837 } |
| OLD | NEW |