| OLD | NEW |
| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // FIXME should really use something like near/nearest MV and/or MV prediction | 125 // FIXME should really use something like near/nearest MV and/or MV prediction |
| 126 err = vp9_sad16x16(x->plane[0].src.buf, x->plane[0].src.stride, | 126 err = vp9_sad16x16(x->plane[0].src.buf, x->plane[0].src.stride, |
| 127 xd->plane[0].pre[0].buf, xd->plane[0].pre[0].stride, | 127 xd->plane[0].pre[0].buf, xd->plane[0].pre[0].stride, |
| 128 INT_MAX); | 128 INT_MAX); |
| 129 | 129 |
| 130 dst_mv->as_int = 0; | 130 dst_mv->as_int = 0; |
| 131 | 131 |
| 132 return err; | 132 return err; |
| 133 } | 133 } |
| 134 static int find_best_16x16_intra(VP9_COMP *cpi, | 134 static int find_best_16x16_intra(VP9_COMP *cpi, |
| 135 int mb_y_offset, | |
| 136 MB_PREDICTION_MODE *pbest_mode) { | 135 MB_PREDICTION_MODE *pbest_mode) { |
| 137 MACROBLOCK *const x = &cpi->mb; | 136 MACROBLOCK *const x = &cpi->mb; |
| 138 MACROBLOCKD *const xd = &x->e_mbd; | 137 MACROBLOCKD *const xd = &x->e_mbd; |
| 139 MB_PREDICTION_MODE best_mode = -1, mode; | 138 MB_PREDICTION_MODE best_mode = -1, mode; |
| 140 unsigned int best_err = INT_MAX; | 139 unsigned int best_err = INT_MAX; |
| 141 | 140 |
| 142 // calculate SATD for each intra prediction mode; | 141 // calculate SATD for each intra prediction mode; |
| 143 // we're intentionally not doing 4x4, we just want a rough estimate | 142 // we're intentionally not doing 4x4, we just want a rough estimate |
| 144 for (mode = DC_PRED; mode <= TM_PRED; mode++) { | 143 for (mode = DC_PRED; mode <= TM_PRED; mode++) { |
| 145 unsigned int err; | 144 unsigned int err; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 166 } | 165 } |
| 167 | 166 |
| 168 static void update_mbgraph_mb_stats | 167 static void update_mbgraph_mb_stats |
| 169 ( | 168 ( |
| 170 VP9_COMP *cpi, | 169 VP9_COMP *cpi, |
| 171 MBGRAPH_MB_STATS *stats, | 170 MBGRAPH_MB_STATS *stats, |
| 172 YV12_BUFFER_CONFIG *buf, | 171 YV12_BUFFER_CONFIG *buf, |
| 173 int mb_y_offset, | 172 int mb_y_offset, |
| 174 YV12_BUFFER_CONFIG *golden_ref, | 173 YV12_BUFFER_CONFIG *golden_ref, |
| 175 int_mv *prev_golden_ref_mv, | 174 int_mv *prev_golden_ref_mv, |
| 176 int gld_y_offset, | |
| 177 YV12_BUFFER_CONFIG *alt_ref, | 175 YV12_BUFFER_CONFIG *alt_ref, |
| 178 int_mv *prev_alt_ref_mv, | |
| 179 int arf_y_offset, | |
| 180 int mb_row, | 176 int mb_row, |
| 181 int mb_col | 177 int mb_col |
| 182 ) { | 178 ) { |
| 183 MACROBLOCK *const x = &cpi->mb; | 179 MACROBLOCK *const x = &cpi->mb; |
| 184 MACROBLOCKD *const xd = &x->e_mbd; | 180 MACROBLOCKD *const xd = &x->e_mbd; |
| 185 int intra_error; | 181 int intra_error; |
| 186 VP9_COMMON *cm = &cpi->common; | 182 VP9_COMMON *cm = &cpi->common; |
| 187 | 183 |
| 188 // FIXME in practice we're completely ignoring chroma here | 184 // FIXME in practice we're completely ignoring chroma here |
| 189 x->plane[0].src.buf = buf->y_buffer + mb_y_offset; | 185 x->plane[0].src.buf = buf->y_buffer + mb_y_offset; |
| 190 x->plane[0].src.stride = buf->y_stride; | 186 x->plane[0].src.stride = buf->y_stride; |
| 191 | 187 |
| 192 xd->plane[0].dst.buf = get_frame_new_buffer(cm)->y_buffer + mb_y_offset; | 188 xd->plane[0].dst.buf = get_frame_new_buffer(cm)->y_buffer + mb_y_offset; |
| 193 xd->plane[0].dst.stride = get_frame_new_buffer(cm)->y_stride; | 189 xd->plane[0].dst.stride = get_frame_new_buffer(cm)->y_stride; |
| 194 | 190 |
| 195 // do intra 16x16 prediction | 191 // do intra 16x16 prediction |
| 196 intra_error = find_best_16x16_intra(cpi, mb_y_offset, | 192 intra_error = find_best_16x16_intra(cpi, |
| 197 &stats->ref[INTRA_FRAME].m.mode); | 193 &stats->ref[INTRA_FRAME].m.mode); |
| 198 if (intra_error <= 0) | 194 if (intra_error <= 0) |
| 199 intra_error = 1; | 195 intra_error = 1; |
| 200 stats->ref[INTRA_FRAME].err = intra_error; | 196 stats->ref[INTRA_FRAME].err = intra_error; |
| 201 | 197 |
| 202 // Golden frame MV search, if it exists and is different than last frame | 198 // Golden frame MV search, if it exists and is different than last frame |
| 203 if (golden_ref) { | 199 if (golden_ref) { |
| 204 int g_motion_error; | 200 int g_motion_error; |
| 205 xd->plane[0].pre[0].buf = golden_ref->y_buffer + mb_y_offset; | 201 xd->plane[0].pre[0].buf = golden_ref->y_buffer + mb_y_offset; |
| 206 xd->plane[0].pre[0].stride = golden_ref->y_stride; | 202 xd->plane[0].pre[0].stride = golden_ref->y_stride; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 arf_left_mv.as_int = arf_top_mv.as_int; | 266 arf_left_mv.as_int = arf_top_mv.as_int; |
| 271 gld_left_mv.as_int = gld_top_mv.as_int; | 267 gld_left_mv.as_int = gld_top_mv.as_int; |
| 272 x->mv_col_min = -BORDER_MV_PIXELS_B16; | 268 x->mv_col_min = -BORDER_MV_PIXELS_B16; |
| 273 x->mv_col_max = (cm->mb_cols - 1) * 8 + BORDER_MV_PIXELS_B16; | 269 x->mv_col_max = (cm->mb_cols - 1) * 8 + BORDER_MV_PIXELS_B16; |
| 274 xd->left_available = 0; | 270 xd->left_available = 0; |
| 275 | 271 |
| 276 for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) { | 272 for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) { |
| 277 MBGRAPH_MB_STATS *mb_stats = &stats->mb_stats[offset + mb_col]; | 273 MBGRAPH_MB_STATS *mb_stats = &stats->mb_stats[offset + mb_col]; |
| 278 | 274 |
| 279 update_mbgraph_mb_stats(cpi, mb_stats, buf, mb_y_in_offset, | 275 update_mbgraph_mb_stats(cpi, mb_stats, buf, mb_y_in_offset, |
| 280 golden_ref, &gld_left_mv, gld_y_in_offset, | 276 golden_ref, &gld_left_mv, alt_ref, |
| 281 alt_ref, &arf_left_mv, arf_y_in_offset, | |
| 282 mb_row, mb_col); | 277 mb_row, mb_col); |
| 283 arf_left_mv.as_int = mb_stats->ref[ALTREF_FRAME].m.mv.as_int; | 278 arf_left_mv.as_int = mb_stats->ref[ALTREF_FRAME].m.mv.as_int; |
| 284 gld_left_mv.as_int = mb_stats->ref[GOLDEN_FRAME].m.mv.as_int; | 279 gld_left_mv.as_int = mb_stats->ref[GOLDEN_FRAME].m.mv.as_int; |
| 285 if (mb_col == 0) { | 280 if (mb_col == 0) { |
| 286 arf_top_mv.as_int = arf_left_mv.as_int; | 281 arf_top_mv.as_int = arf_left_mv.as_int; |
| 287 gld_top_mv.as_int = gld_left_mv.as_int; | 282 gld_top_mv.as_int = gld_left_mv.as_int; |
| 288 } | 283 } |
| 289 xd->left_available = 1; | 284 xd->left_available = 1; |
| 290 mb_y_in_offset += 16; | 285 mb_y_in_offset += 16; |
| 291 gld_y_in_offset += 16; | 286 gld_y_in_offset += 16; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 // Note % of blocks that are marked as static | 362 // Note % of blocks that are marked as static |
| 368 if (cm->MBs) | 363 if (cm->MBs) |
| 369 cpi->static_mb_pct = (ncnt[1] * 100) / (cm->mi_rows * cm->mi_cols); | 364 cpi->static_mb_pct = (ncnt[1] * 100) / (cm->mi_rows * cm->mi_cols); |
| 370 | 365 |
| 371 // This error case should not be reachable as this function should | 366 // This error case should not be reachable as this function should |
| 372 // never be called with the common data structure uninitialized. | 367 // never be called with the common data structure uninitialized. |
| 373 else | 368 else |
| 374 cpi->static_mb_pct = 0; | 369 cpi->static_mb_pct = 0; |
| 375 | 370 |
| 376 cpi->seg0_cnt = ncnt[0]; | 371 cpi->seg0_cnt = ncnt[0]; |
| 377 vp9_enable_segmentation((VP9_PTR)cpi); | 372 vp9_enable_segmentation(&cm->seg); |
| 378 } else { | 373 } else { |
| 379 cpi->static_mb_pct = 0; | 374 cpi->static_mb_pct = 0; |
| 380 vp9_disable_segmentation((VP9_PTR)cpi); | 375 vp9_disable_segmentation(&cm->seg); |
| 381 } | 376 } |
| 382 | 377 |
| 383 // Free localy allocated storage | 378 // Free localy allocated storage |
| 384 vpx_free(arf_not_zz); | 379 vpx_free(arf_not_zz); |
| 385 } | 380 } |
| 386 | 381 |
| 387 void vp9_update_mbgraph_stats(VP9_COMP *cpi) { | 382 void vp9_update_mbgraph_stats(VP9_COMP *cpi) { |
| 388 VP9_COMMON *const cm = &cpi->common; | 383 VP9_COMMON *const cm = &cpi->common; |
| 389 int i, n_frames = vp9_lookahead_depth(cpi->lookahead); | 384 int i, n_frames = vp9_lookahead_depth(cpi->lookahead); |
| 390 YV12_BUFFER_CONFIG *golden_ref = get_ref_frame_buffer(cpi, GOLDEN_FRAME); | 385 YV12_BUFFER_CONFIG *golden_ref = get_ref_frame_buffer(cpi, GOLDEN_FRAME); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 412 for (i = 0; i < n_frames; i++) { | 407 for (i = 0; i < n_frames; i++) { |
| 413 MBGRAPH_FRAME_STATS *frame_stats = &cpi->mbgraph_stats[i]; | 408 MBGRAPH_FRAME_STATS *frame_stats = &cpi->mbgraph_stats[i]; |
| 414 struct lookahead_entry *q_cur = vp9_lookahead_peek(cpi->lookahead, i); | 409 struct lookahead_entry *q_cur = vp9_lookahead_peek(cpi->lookahead, i); |
| 415 | 410 |
| 416 assert(q_cur != NULL); | 411 assert(q_cur != NULL); |
| 417 | 412 |
| 418 update_mbgraph_frame_stats(cpi, frame_stats, &q_cur->img, | 413 update_mbgraph_frame_stats(cpi, frame_stats, &q_cur->img, |
| 419 golden_ref, cpi->Source); | 414 golden_ref, cpi->Source); |
| 420 } | 415 } |
| 421 | 416 |
| 422 vp9_clear_system_state(); // __asm emms; | 417 vp9_clear_system_state(); |
| 423 | 418 |
| 424 separate_arf_mbs(cpi); | 419 separate_arf_mbs(cpi); |
| 425 } | 420 } |
| OLD | NEW |