Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: source/libvpx/vp9/encoder/vp9_rdopt.c

Issue 996503002: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_rd.c ('k') | source/libvpx/vp9/encoder/vp9_svc_layercontext.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2010 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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 * decide whether to include cost of a trailing EOB node or not (i.e. we 321 * decide whether to include cost of a trailing EOB node or not (i.e. we
322 * can skip this if the last coefficient in this transform block, e.g. the 322 * can skip this if the last coefficient in this transform block, e.g. the
323 * 16th coefficient in a 4x4 block or the 64th coefficient in a 8x8 block, 323 * 16th coefficient in a 4x4 block or the 64th coefficient in a 8x8 block,
324 * were non-zero). */ 324 * were non-zero). */
325 static const int16_t band_counts[TX_SIZES][8] = { 325 static const int16_t band_counts[TX_SIZES][8] = {
326 { 1, 2, 3, 4, 3, 16 - 13, 0 }, 326 { 1, 2, 3, 4, 3, 16 - 13, 0 },
327 { 1, 2, 3, 4, 11, 64 - 21, 0 }, 327 { 1, 2, 3, 4, 11, 64 - 21, 0 },
328 { 1, 2, 3, 4, 11, 256 - 21, 0 }, 328 { 1, 2, 3, 4, 11, 256 - 21, 0 },
329 { 1, 2, 3, 4, 11, 1024 - 21, 0 }, 329 { 1, 2, 3, 4, 11, 1024 - 21, 0 },
330 }; 330 };
331 static INLINE int cost_coeffs(MACROBLOCK *x, 331 static int cost_coeffs(MACROBLOCK *x,
332 int plane, int block, 332 int plane, int block,
333 ENTROPY_CONTEXT *A, ENTROPY_CONTEXT *L, 333 ENTROPY_CONTEXT *A, ENTROPY_CONTEXT *L,
334 TX_SIZE tx_size, 334 TX_SIZE tx_size,
335 const int16_t *scan, const int16_t *nb, 335 const int16_t *scan, const int16_t *nb,
336 int use_fast_coef_costing) { 336 int use_fast_coef_costing) {
337 MACROBLOCKD *const xd = &x->e_mbd; 337 MACROBLOCKD *const xd = &x->e_mbd;
338 MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi; 338 MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi;
339 const struct macroblock_plane *p = &x->plane[plane]; 339 const struct macroblock_plane *p = &x->plane[plane];
340 const struct macroblockd_plane *pd = &xd->plane[plane]; 340 const struct macroblockd_plane *pd = &xd->plane[plane];
341 const PLANE_TYPE type = pd->plane_type; 341 const PLANE_TYPE type = pd->plane_type;
342 const int16_t *band_count = &band_counts[tx_size][1]; 342 const int16_t *band_count = &band_counts[tx_size][1];
343 const int eob = p->eobs[block]; 343 const int eob = p->eobs[block];
344 const tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block); 344 const tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
345 unsigned int (*token_costs)[2][COEFF_CONTEXTS][ENTROPY_TOKENS] = 345 unsigned int (*token_costs)[2][COEFF_CONTEXTS][ENTROPY_TOKENS] =
346 x->token_costs[tx_size][type][is_inter_block(mbmi)]; 346 x->token_costs[tx_size][type][is_inter_block(mbmi)];
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 } 1309 }
1310 1310
1311 mic->bmi[i].as_mv[0].as_int = this_mv[0].as_int; 1311 mic->bmi[i].as_mv[0].as_int = this_mv[0].as_int;
1312 if (is_compound) 1312 if (is_compound)
1313 mic->bmi[i].as_mv[1].as_int = this_mv[1].as_int; 1313 mic->bmi[i].as_mv[1].as_int = this_mv[1].as_int;
1314 1314
1315 mic->bmi[i].as_mode = mode; 1315 mic->bmi[i].as_mode = mode;
1316 1316
1317 for (idy = 0; idy < num_4x4_blocks_high; ++idy) 1317 for (idy = 0; idy < num_4x4_blocks_high; ++idy)
1318 for (idx = 0; idx < num_4x4_blocks_wide; ++idx) 1318 for (idx = 0; idx < num_4x4_blocks_wide; ++idx)
1319 vpx_memcpy(&mic->bmi[i + idy * 2 + idx], 1319 vpx_memmove(&mic->bmi[i + idy * 2 + idx],
1320 &mic->bmi[i], sizeof(mic->bmi[i])); 1320 &mic->bmi[i], sizeof(mic->bmi[i]));
1321 1321
1322 return cost_mv_ref(cpi, mode, mbmi->mode_context[mbmi->ref_frame[0]]) + 1322 return cost_mv_ref(cpi, mode, mbmi->mode_context[mbmi->ref_frame[0]]) +
1323 thismvcost; 1323 thismvcost;
1324 } 1324 }
1325 1325
1326 static int64_t encode_inter_mb_segment(VP9_COMP *cpi, 1326 static int64_t encode_inter_mb_segment(VP9_COMP *cpi,
1327 MACROBLOCK *x, 1327 MACROBLOCK *x,
1328 int64_t best_yrd, 1328 int64_t best_yrd,
1329 int i, 1329 int i,
1330 int *labelyrate, 1330 int *labelyrate,
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 int_mv frame_nearest_mv[MAX_REF_FRAMES], 2015 int_mv frame_nearest_mv[MAX_REF_FRAMES],
2016 int_mv frame_near_mv[MAX_REF_FRAMES], 2016 int_mv frame_near_mv[MAX_REF_FRAMES],
2017 struct buf_2d yv12_mb[4][MAX_MB_PLANE]) { 2017 struct buf_2d yv12_mb[4][MAX_MB_PLANE]) {
2018 const VP9_COMMON *cm = &cpi->common; 2018 const VP9_COMMON *cm = &cpi->common;
2019 const YV12_BUFFER_CONFIG *yv12 = get_ref_frame_buffer(cpi, ref_frame); 2019 const YV12_BUFFER_CONFIG *yv12 = get_ref_frame_buffer(cpi, ref_frame);
2020 MACROBLOCKD *const xd = &x->e_mbd; 2020 MACROBLOCKD *const xd = &x->e_mbd;
2021 MODE_INFO *const mi = xd->mi[0].src_mi; 2021 MODE_INFO *const mi = xd->mi[0].src_mi;
2022 int_mv *const candidates = mi->mbmi.ref_mvs[ref_frame]; 2022 int_mv *const candidates = mi->mbmi.ref_mvs[ref_frame];
2023 const struct scale_factors *const sf = &cm->frame_refs[ref_frame - 1].sf; 2023 const struct scale_factors *const sf = &cm->frame_refs[ref_frame - 1].sf;
2024 2024
2025 assert(yv12 != NULL);
2026
2025 // TODO(jkoleszar): Is the UV buffer ever used here? If so, need to make this 2027 // TODO(jkoleszar): Is the UV buffer ever used here? If so, need to make this
2026 // use the UV scaling factors. 2028 // use the UV scaling factors.
2027 vp9_setup_pred_block(xd, yv12_mb[ref_frame], yv12, mi_row, mi_col, sf, sf); 2029 vp9_setup_pred_block(xd, yv12_mb[ref_frame], yv12, mi_row, mi_col, sf, sf);
2028 2030
2029 // Gets an initial list of candidate vectors from neighbours and orders them 2031 // Gets an initial list of candidate vectors from neighbours and orders them
2030 vp9_find_mv_refs(cm, xd, tile, mi, ref_frame, candidates, mi_row, mi_col, 2032 vp9_find_mv_refs(cm, xd, tile, mi, ref_frame, candidates, mi_row, mi_col,
2031 NULL, NULL); 2033 NULL, NULL);
2032 2034
2033 // Candidate refinement carried out at encoder and decoder 2035 // Candidate refinement carried out at encoder and decoder
2034 vp9_find_best_ref_mvs(xd, cm->allow_high_precision_mv, candidates, 2036 vp9_find_best_ref_mvs(xd, cm->allow_high_precision_mv, candidates,
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
2905 single_inter_filter[i][k] = SWITCHABLE; 2907 single_inter_filter[i][k] = SWITCHABLE;
2906 single_skippable[i][k] = 0; 2908 single_skippable[i][k] = 0;
2907 } 2909 }
2908 } 2910 }
2909 2911
2910 rd_cost->rate = INT_MAX; 2912 rd_cost->rate = INT_MAX;
2911 2913
2912 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) { 2914 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
2913 x->pred_mv_sad[ref_frame] = INT_MAX; 2915 x->pred_mv_sad[ref_frame] = INT_MAX;
2914 if (cpi->ref_frame_flags & flag_list[ref_frame]) { 2916 if (cpi->ref_frame_flags & flag_list[ref_frame]) {
2917 assert(get_ref_frame_buffer(cpi, ref_frame) != NULL);
2915 setup_buffer_inter(cpi, x, tile_info, ref_frame, bsize, mi_row, mi_col, 2918 setup_buffer_inter(cpi, x, tile_info, ref_frame, bsize, mi_row, mi_col,
2916 frame_mv[NEARESTMV], frame_mv[NEARMV], yv12_mb); 2919 frame_mv[NEARESTMV], frame_mv[NEARMV], yv12_mb);
2917 } 2920 }
2918 frame_mv[NEWMV][ref_frame].as_int = INVALID_MV; 2921 frame_mv[NEWMV][ref_frame].as_int = INVALID_MV;
2919 frame_mv[ZEROMV][ref_frame].as_int = 0; 2922 frame_mv[ZEROMV][ref_frame].as_int = 0;
2920 } 2923 }
2921 2924
2922 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) { 2925 for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
2923 if (!(cpi->ref_frame_flags & flag_list[ref_frame])) { 2926 if (!(cpi->ref_frame_flags & flag_list[ref_frame])) {
2924 // Skip checking missing references in both single and compound reference 2927 // Skip checking missing references in both single and compound reference
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after
4231 } 4234 }
4232 if (cm->interp_filter == SWITCHABLE) 4235 if (cm->interp_filter == SWITCHABLE)
4233 assert(best_filter_diff[SWITCHABLE_FILTERS] == 0); 4236 assert(best_filter_diff[SWITCHABLE_FILTERS] == 0);
4234 } else { 4237 } else {
4235 vp9_zero(best_filter_diff); 4238 vp9_zero(best_filter_diff);
4236 } 4239 }
4237 4240
4238 store_coding_context(x, ctx, best_ref_index, 4241 store_coding_context(x, ctx, best_ref_index,
4239 best_pred_diff, best_tx_diff, best_filter_diff, 0); 4242 best_pred_diff, best_tx_diff, best_filter_diff, 0);
4240 } 4243 }
4241
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_rd.c ('k') | source/libvpx/vp9/encoder/vp9_svc_layercontext.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698