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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 struct macroblockd_plane *const pd = &xd->plane[0]; | 217 struct macroblockd_plane *const pd = &xd->plane[0]; |
218 const int64_t dc_thr = p->quant_thred[0] >> 6; | 218 const int64_t dc_thr = p->quant_thred[0] >> 6; |
219 const int64_t ac_thr = p->quant_thred[1] >> 6; | 219 const int64_t ac_thr = p->quant_thred[1] >> 6; |
220 const uint32_t dc_quant = pd->dequant[0]; | 220 const uint32_t dc_quant = pd->dequant[0]; |
221 const uint32_t ac_quant = pd->dequant[1]; | 221 const uint32_t ac_quant = pd->dequant[1]; |
222 unsigned int var = cpi->fn_ptr[bsize].vf(p->src.buf, p->src.stride, | 222 unsigned int var = cpi->fn_ptr[bsize].vf(p->src.buf, p->src.stride, |
223 pd->dst.buf, pd->dst.stride, &sse); | 223 pd->dst.buf, pd->dst.stride, &sse); |
224 *var_y = var; | 224 *var_y = var; |
225 *sse_y = sse; | 225 *sse_y = sse; |
226 | 226 |
227 x->skip_txfm[0] = 0; | |
228 // Check if all ac coefficients can be quantized to zero. | |
229 if (var < ac_thr || var == 0) { | |
230 x->skip_txfm[0] = 2; | |
231 // Check if dc coefficient can be quantized to zero. | |
232 if (sse - var < dc_thr || sse == var) | |
233 x->skip_txfm[0] = 1; | |
234 } | |
235 | |
236 if (cpi->common.tx_mode == TX_MODE_SELECT) { | 227 if (cpi->common.tx_mode == TX_MODE_SELECT) { |
237 if (sse > (var << 2)) | 228 if (sse > (var << 2)) |
238 xd->mi[0].src_mi->mbmi.tx_size = | 229 xd->mi[0].src_mi->mbmi.tx_size = |
239 MIN(max_txsize_lookup[bsize], | 230 MIN(max_txsize_lookup[bsize], |
240 tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); | 231 tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); |
241 else | 232 else |
242 xd->mi[0].src_mi->mbmi.tx_size = TX_8X8; | 233 xd->mi[0].src_mi->mbmi.tx_size = TX_8X8; |
243 | 234 |
244 if (cpi->sf.partition_search_type == VAR_BASED_PARTITION) { | 235 if (cpi->sf.partition_search_type == VAR_BASED_PARTITION) { |
245 if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && | 236 if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && |
246 xd->mi[0].src_mi->mbmi.segment_id != CR_SEGMENT_ID_BASE) | 237 xd->mi[0].src_mi->mbmi.segment_id != CR_SEGMENT_ID_BASE) |
247 xd->mi[0].src_mi->mbmi.tx_size = TX_8X8; | 238 xd->mi[0].src_mi->mbmi.tx_size = TX_8X8; |
248 else if (xd->mi[0].src_mi->mbmi.tx_size > TX_16X16) | 239 else if (xd->mi[0].src_mi->mbmi.tx_size > TX_16X16) |
249 xd->mi[0].src_mi->mbmi.tx_size = TX_16X16; | 240 xd->mi[0].src_mi->mbmi.tx_size = TX_16X16; |
250 } | 241 } |
251 } else { | 242 } else { |
252 xd->mi[0].src_mi->mbmi.tx_size = | 243 xd->mi[0].src_mi->mbmi.tx_size = |
253 MIN(max_txsize_lookup[bsize], | 244 MIN(max_txsize_lookup[bsize], |
254 tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); | 245 tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); |
255 } | 246 } |
256 | 247 |
| 248 // Evaluate if the partition block is a skippable block in Y plane. |
| 249 { |
| 250 const BLOCK_SIZE unit_size = |
| 251 txsize_to_bsize[xd->mi[0].src_mi->mbmi.tx_size]; |
| 252 const unsigned int num_blk_log2 = |
| 253 (b_width_log2_lookup[bsize] - b_width_log2_lookup[unit_size]) + |
| 254 (b_height_log2_lookup[bsize] - b_height_log2_lookup[unit_size]); |
| 255 const unsigned int sse_tx = sse >> num_blk_log2; |
| 256 const unsigned int var_tx = var >> num_blk_log2; |
| 257 |
| 258 x->skip_txfm[0] = 0; |
| 259 // Check if all ac coefficients can be quantized to zero. |
| 260 if (var_tx < ac_thr || var == 0) { |
| 261 x->skip_txfm[0] = 2; |
| 262 // Check if dc coefficient can be quantized to zero. |
| 263 if (sse_tx - var_tx < dc_thr || sse == var) |
| 264 x->skip_txfm[0] = 1; |
| 265 } |
| 266 } |
| 267 |
| 268 if (x->skip_txfm[0] == 1) { |
| 269 *out_rate_sum = 0; |
| 270 *out_dist_sum = sse << 4; |
| 271 return; |
| 272 } |
| 273 |
257 #if CONFIG_VP9_HIGHBITDEPTH | 274 #if CONFIG_VP9_HIGHBITDEPTH |
258 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { | 275 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { |
259 vp9_model_rd_from_var_lapndz(sse - var, num_pels_log2_lookup[bsize], | 276 vp9_model_rd_from_var_lapndz(sse - var, num_pels_log2_lookup[bsize], |
260 dc_quant >> (xd->bd - 5), &rate, &dist); | 277 dc_quant >> (xd->bd - 5), &rate, &dist); |
261 } else { | 278 } else { |
262 vp9_model_rd_from_var_lapndz(sse - var, num_pels_log2_lookup[bsize], | 279 vp9_model_rd_from_var_lapndz(sse - var, num_pels_log2_lookup[bsize], |
263 dc_quant >> 3, &rate, &dist); | 280 dc_quant >> 3, &rate, &dist); |
264 } | 281 } |
265 #else | 282 #else |
266 vp9_model_rd_from_var_lapndz(sse - var, num_pels_log2_lookup[bsize], | 283 vp9_model_rd_from_var_lapndz(sse - var, num_pels_log2_lookup[bsize], |
(...skipping 11 matching lines...) Expand all Loading... |
278 vp9_model_rd_from_var_lapndz(var, num_pels_log2_lookup[bsize], | 295 vp9_model_rd_from_var_lapndz(var, num_pels_log2_lookup[bsize], |
279 ac_quant >> 3, &rate, &dist); | 296 ac_quant >> 3, &rate, &dist); |
280 } | 297 } |
281 #else | 298 #else |
282 vp9_model_rd_from_var_lapndz(var, num_pels_log2_lookup[bsize], | 299 vp9_model_rd_from_var_lapndz(var, num_pels_log2_lookup[bsize], |
283 ac_quant >> 3, &rate, &dist); | 300 ac_quant >> 3, &rate, &dist); |
284 #endif // CONFIG_VP9_HIGHBITDEPTH | 301 #endif // CONFIG_VP9_HIGHBITDEPTH |
285 | 302 |
286 *out_rate_sum += rate; | 303 *out_rate_sum += rate; |
287 *out_dist_sum += dist << 4; | 304 *out_dist_sum += dist << 4; |
288 | |
289 if (*out_rate_sum == 0) | |
290 x->skip_txfm[0] = 1; | |
291 } | 305 } |
292 | 306 |
293 static void model_rd_for_sb_uv(VP9_COMP *cpi, BLOCK_SIZE bsize, | 307 static void model_rd_for_sb_uv(VP9_COMP *cpi, BLOCK_SIZE bsize, |
294 MACROBLOCK *x, MACROBLOCKD *xd, | 308 MACROBLOCK *x, MACROBLOCKD *xd, |
295 int *out_rate_sum, int64_t *out_dist_sum, | 309 int *out_rate_sum, int64_t *out_dist_sum, |
296 unsigned int *var_y, unsigned int *sse_y) { | 310 unsigned int *var_y, unsigned int *sse_y) { |
297 // Note our transform coeffs are 8 times an orthogonal transform. | 311 // Note our transform coeffs are 8 times an orthogonal transform. |
298 // Hence quantizer step is also 8 times. To get effective quantizer | 312 // Hence quantizer step is also 8 times. To get effective quantizer |
299 // we need to divide by 8 before sending to modeling function. | 313 // we need to divide by 8 before sending to modeling function. |
300 unsigned int sse; | 314 unsigned int sse; |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 &frame_mv[NEARMV][ref_frame]); | 730 &frame_mv[NEARMV][ref_frame]); |
717 | 731 |
718 if (!vp9_is_scaled(sf) && bsize >= BLOCK_8X8) | 732 if (!vp9_is_scaled(sf) && bsize >= BLOCK_8X8) |
719 vp9_mv_pred(cpi, x, yv12_mb[ref_frame][0].buf, yv12->y_stride, | 733 vp9_mv_pred(cpi, x, yv12_mb[ref_frame][0].buf, yv12->y_stride, |
720 ref_frame, bsize); | 734 ref_frame, bsize); |
721 } else { | 735 } else { |
722 ref_frame_skip_mask |= (1 << ref_frame); | 736 ref_frame_skip_mask |= (1 << ref_frame); |
723 } | 737 } |
724 } | 738 } |
725 | 739 |
| 740 if (cpi->rc.frames_since_golden == 0) |
| 741 ref_frame_skip_mask |= (1 << GOLDEN_FRAME); |
| 742 |
726 for (ref_frame = LAST_FRAME; ref_frame <= GOLDEN_FRAME; ++ref_frame) { | 743 for (ref_frame = LAST_FRAME; ref_frame <= GOLDEN_FRAME; ++ref_frame) { |
727 PREDICTION_MODE this_mode; | 744 PREDICTION_MODE this_mode; |
728 int i = (ref_frame == LAST_FRAME) ? GOLDEN_FRAME : LAST_FRAME; | 745 int i = (ref_frame == LAST_FRAME) ? GOLDEN_FRAME : LAST_FRAME; |
729 | 746 |
730 if (!(cpi->ref_frame_flags & flag_list[ref_frame])) | 747 if (!(cpi->ref_frame_flags & flag_list[ref_frame])) |
731 continue; | 748 continue; |
732 | 749 |
733 if (cpi->ref_frame_flags & flag_list[i]) | 750 if (cpi->ref_frame_flags & flag_list[i]) |
734 if (x->pred_mv_sad[ref_frame] > (x->pred_mv_sad[i] << 1)) | 751 if (x->pred_mv_sad[ref_frame] > (x->pred_mv_sad[i] << 1)) |
735 ref_frame_skip_mask |= (1 << ref_frame); | 752 ref_frame_skip_mask |= (1 << ref_frame); |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1306 xd->mi[0].bmi[block + 2] = bsi[best_ref_frame][block]; | 1323 xd->mi[0].bmi[block + 2] = bsi[best_ref_frame][block]; |
1307 } | 1324 } |
1308 } | 1325 } |
1309 mbmi->mode = xd->mi[0].bmi[3].as_mode; | 1326 mbmi->mode = xd->mi[0].bmi[3].as_mode; |
1310 ctx->mic = *(xd->mi[0].src_mi); | 1327 ctx->mic = *(xd->mi[0].src_mi); |
1311 ctx->skip_txfm[0] = 0; | 1328 ctx->skip_txfm[0] = 0; |
1312 ctx->skip = 0; | 1329 ctx->skip = 0; |
1313 // Dummy assignment for speed -5. No effect in speed -6. | 1330 // Dummy assignment for speed -5. No effect in speed -6. |
1314 rd_cost->rdcost = best_rd; | 1331 rd_cost->rdcost = best_rd; |
1315 } | 1332 } |
OLD | NEW |