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

Unified Diff: source/libvpx/vp9/common/vp9_findnearmv.c

Issue 11974002: libvpx: Pull from upstream (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/libvpx/vp9/common/vp9_findnearmv.h ('k') | source/libvpx/vp9/common/vp9_header.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/libvpx/vp9/common/vp9_findnearmv.c
===================================================================
--- source/libvpx/vp9/common/vp9_findnearmv.c (revision 177019)
+++ source/libvpx/vp9/common/vp9_findnearmv.c (working copy)
@@ -14,7 +14,7 @@
#include "vp9/common/vp9_subpelvar.h"
#include <limits.h>
-const unsigned char vp9_mbsplit_offset[4][16] = {
+const uint8_t vp9_mbsplit_offset[4][16] = {
{ 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 2, 8, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
@@ -42,23 +42,23 @@
}
#define SP(x) (((x) & 7) << 1)
-unsigned int vp9_sad3x16_c(const unsigned char *src_ptr,
+unsigned int vp9_sad3x16_c(const uint8_t *src_ptr,
int src_stride,
- const unsigned char *ref_ptr,
+ const uint8_t *ref_ptr,
int ref_stride) {
return sad_mx_n_c(src_ptr, src_stride, ref_ptr, ref_stride, 3, 16);
}
-unsigned int vp9_sad16x3_c(const unsigned char *src_ptr,
+unsigned int vp9_sad16x3_c(const uint8_t *src_ptr,
int src_stride,
- const unsigned char *ref_ptr,
+ const uint8_t *ref_ptr,
int ref_stride) {
return sad_mx_n_c(src_ptr, src_stride, ref_ptr, ref_stride, 16, 3);
}
-#if CONFIG_SUBPELREFMV
-unsigned int vp9_variance2x16_c(const unsigned char *src_ptr,
+
+unsigned int vp9_variance2x16_c(const uint8_t *src_ptr,
const int source_stride,
- const unsigned char *ref_ptr,
+ const uint8_t *ref_ptr,
const int recon_stride,
unsigned int *sse) {
int sum;
@@ -66,9 +66,9 @@
return (*sse - (((unsigned int)sum * sum) >> 5));
}
-unsigned int vp9_variance16x2_c(const unsigned char *src_ptr,
+unsigned int vp9_variance16x2_c(const uint8_t *src_ptr,
const int source_stride,
- const unsigned char *ref_ptr,
+ const uint8_t *ref_ptr,
const int recon_stride,
unsigned int *sse) {
int sum;
@@ -76,16 +76,16 @@
return (*sse - (((unsigned int)sum * sum) >> 5));
}
-unsigned int vp9_sub_pixel_variance16x2_c(const unsigned char *src_ptr,
+unsigned int vp9_sub_pixel_variance16x2_c(const uint8_t *src_ptr,
const int src_pixels_per_line,
const int xoffset,
const int yoffset,
- const unsigned char *dst_ptr,
+ const uint8_t *dst_ptr,
const int dst_pixels_per_line,
unsigned int *sse) {
- unsigned short FData3[16 * 3]; // Temp data buffer used in filtering
- unsigned char temp2[2 * 16];
- const short *HFilter, *VFilter;
+ uint16_t FData3[16 * 3]; // Temp data buffer used in filtering
+ uint8_t temp2[2 * 16];
+ const int16_t *HFilter, *VFilter;
HFilter = vp9_bilinear_filters[xoffset];
VFilter = vp9_bilinear_filters[yoffset];
@@ -97,16 +97,16 @@
return vp9_variance16x2_c(temp2, 16, dst_ptr, dst_pixels_per_line, sse);
}
-unsigned int vp9_sub_pixel_variance2x16_c(const unsigned char *src_ptr,
+unsigned int vp9_sub_pixel_variance2x16_c(const uint8_t *src_ptr,
const int src_pixels_per_line,
const int xoffset,
const int yoffset,
- const unsigned char *dst_ptr,
+ const uint8_t *dst_ptr,
const int dst_pixels_per_line,
unsigned int *sse) {
- unsigned short FData3[2 * 17]; // Temp data buffer used in filtering
- unsigned char temp2[2 * 16];
- const short *HFilter, *VFilter;
+ uint16_t FData3[2 * 17]; // Temp data buffer used in filtering
+ uint8_t temp2[2 * 16];
+ const int16_t *HFilter, *VFilter;
HFilter = vp9_bilinear_filters[xoffset];
VFilter = vp9_bilinear_filters[yoffset];
@@ -117,51 +117,46 @@
return vp9_variance2x16_c(temp2, 2, dst_ptr, dst_pixels_per_line, sse);
}
-#endif
/* check a list of motion vectors by sad score using a number rows of pixels
* above and a number cols of pixels in the left to select the one with best
* score to use as ref motion vector
*/
void vp9_find_best_ref_mvs(MACROBLOCKD *xd,
- unsigned char *ref_y_buffer,
+ uint8_t *ref_y_buffer,
int ref_y_stride,
int_mv *mvlist,
- int_mv *best_mv,
int_mv *nearest,
int_mv *near) {
int i, j;
- unsigned char *above_src;
- unsigned char *left_src;
- unsigned char *above_ref;
- unsigned char *left_ref;
+ uint8_t *above_src;
+ uint8_t *above_ref;
+#if !CONFIG_ABOVESPREFMV
+ uint8_t *left_src;
+ uint8_t *left_ref;
+#endif
unsigned int score;
-#if CONFIG_SUBPELREFMV
unsigned int sse;
-#endif
- unsigned int ref_scores[MAX_MV_REFS] = {0};
- int_mv sorted_mvs[MAX_MV_REFS];
+ unsigned int ref_scores[MAX_MV_REF_CANDIDATES] = {0};
+ int_mv sorted_mvs[MAX_MV_REF_CANDIDATES];
int zero_seen = FALSE;
// Default all to 0,0 if nothing else available
- best_mv->as_int = nearest->as_int = near->as_int = 0;
+ nearest->as_int = near->as_int = 0;
vpx_memset(sorted_mvs, 0, sizeof(sorted_mvs));
-#if CONFIG_SUBPELREFMV
above_src = xd->dst.y_buffer - xd->dst.y_stride * 2;
- left_src = xd->dst.y_buffer - 2;
above_ref = ref_y_buffer - ref_y_stride * 2;
- left_ref = ref_y_buffer - 2;
+#if CONFIG_ABOVESPREFMV
+ above_src -= 4;
+ above_ref -= 4;
#else
- above_src = xd->dst.y_buffer - xd->dst.y_stride * 3;
- left_src = xd->dst.y_buffer - 3;
- above_ref = ref_y_buffer - ref_y_stride * 3;
- left_ref = ref_y_buffer - 3;
+ left_src = xd->dst.y_buffer - 2;
+ left_ref = ref_y_buffer - 2;
#endif
- //for(i = 0; i < MAX_MV_REFS; ++i) {
- // Limit search to the predicted best 4
- for(i = 0; i < 4; ++i) {
+ // Limit search to the predicted best few candidates
+ for(i = 0; i < MAX_MV_REF_CANDIDATES; ++i) {
int_mv this_mv;
int offset = 0;
int row_offset, col_offset;
@@ -175,42 +170,61 @@
zero_seen = zero_seen || !this_mv.as_int;
+#if !CONFIG_ABOVESPREFMV
clamp_mv(&this_mv,
xd->mb_to_left_edge - LEFT_TOP_MARGIN + 24,
xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN,
xd->mb_to_top_edge - LEFT_TOP_MARGIN + 24,
xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN);
+#else
+ clamp_mv(&this_mv,
+ xd->mb_to_left_edge - LEFT_TOP_MARGIN + 32,
+ xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN,
+ xd->mb_to_top_edge - LEFT_TOP_MARGIN + 24,
+ xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN);
+#endif
-#if CONFIG_SUBPELREFMV
row_offset = this_mv.as_mv.row >> 3;
col_offset = this_mv.as_mv.col >> 3;
offset = ref_y_stride * row_offset + col_offset;
score = 0;
if (xd->up_available) {
- vp9_sub_pixel_variance16x2_c(above_ref + offset, ref_y_stride,
+ vp9_sub_pixel_variance16x2(above_ref + offset, ref_y_stride,
+ SP(this_mv.as_mv.col),
+ SP(this_mv.as_mv.row),
+ above_src, xd->dst.y_stride, &sse);
+ score += sse;
+ if (xd->mode_info_context->mbmi.sb_type >= BLOCK_SIZE_SB32X32) {
+ vp9_sub_pixel_variance16x2(above_ref + offset + 16,
+ ref_y_stride,
SP(this_mv.as_mv.col),
SP(this_mv.as_mv.row),
- above_src, xd->dst.y_stride, &sse);
- score += sse;
-#if CONFIG_SUPERBLOCKS
- if (xd->mode_info_context->mbmi.encoded_as_sb) {
- vp9_sub_pixel_variance16x2_c(above_ref + offset + 16,
- ref_y_stride,
- SP(this_mv.as_mv.col),
- SP(this_mv.as_mv.row),
- above_src + 16, xd->dst.y_stride, &sse);
+ above_src + 16, xd->dst.y_stride, &sse);
score += sse;
}
-#endif
+ if (xd->mode_info_context->mbmi.sb_type >= BLOCK_SIZE_SB64X64) {
+ vp9_sub_pixel_variance16x2(above_ref + offset + 32,
+ ref_y_stride,
+ SP(this_mv.as_mv.col),
+ SP(this_mv.as_mv.row),
+ above_src + 32, xd->dst.y_stride, &sse);
+ score += sse;
+ vp9_sub_pixel_variance16x2(above_ref + offset + 48,
+ ref_y_stride,
+ SP(this_mv.as_mv.col),
+ SP(this_mv.as_mv.row),
+ above_src + 48, xd->dst.y_stride, &sse);
+ score += sse;
+ }
}
+#if !CONFIG_ABOVESPREFMV
if (xd->left_available) {
vp9_sub_pixel_variance2x16_c(left_ref + offset, ref_y_stride,
SP(this_mv.as_mv.col),
SP(this_mv.as_mv.row),
left_src, xd->dst.y_stride, &sse);
score += sse;
-#if CONFIG_SUPERBLOCKS
- if (xd->mode_info_context->mbmi.encoded_as_sb) {
+ if (xd->mode_info_context->mbmi.sb_type >= BLOCK_SIZE_SB32X32) {
vp9_sub_pixel_variance2x16_c(left_ref + offset + ref_y_stride * 16,
ref_y_stride,
SP(this_mv.as_mv.col),
@@ -219,38 +233,24 @@
xd->dst.y_stride, &sse);
score += sse;
}
-#endif
- }
-#else
- row_offset = (this_mv.as_mv.row > 0) ?
- ((this_mv.as_mv.row + 3) >> 3):((this_mv.as_mv.row + 4) >> 3);
- col_offset = (this_mv.as_mv.col > 0) ?
- ((this_mv.as_mv.col + 3) >> 3):((this_mv.as_mv.col + 4) >> 3);
- offset = ref_y_stride * row_offset + col_offset;
- score = 0;
- if (xd->up_available) {
- score += vp9_sad16x3(above_src, xd->dst.y_stride,
- above_ref + offset, ref_y_stride);
-#if CONFIG_SUPERBLOCKS
- if (xd->mode_info_context->mbmi.encoded_as_sb) {
- score += vp9_sad16x3(above_src + 16, xd->dst.y_stride,
- above_ref + offset + 16, ref_y_stride);
+ if (xd->mode_info_context->mbmi.sb_type >= BLOCK_SIZE_SB64X64) {
+ vp9_sub_pixel_variance2x16_c(left_ref + offset + ref_y_stride * 32,
+ ref_y_stride,
+ SP(this_mv.as_mv.col),
+ SP(this_mv.as_mv.row),
+ left_src + xd->dst.y_stride * 32,
+ xd->dst.y_stride, &sse);
+ score += sse;
+ vp9_sub_pixel_variance2x16_c(left_ref + offset + ref_y_stride * 48,
+ ref_y_stride,
+ SP(this_mv.as_mv.col),
+ SP(this_mv.as_mv.row),
+ left_src + xd->dst.y_stride * 48,
+ xd->dst.y_stride, &sse);
+ score += sse;
}
-#endif
}
- if (xd->left_available) {
- score += vp9_sad3x16(left_src, xd->dst.y_stride,
- left_ref + offset, ref_y_stride);
-#if CONFIG_SUPERBLOCKS
- if (xd->mode_info_context->mbmi.encoded_as_sb) {
- score += vp9_sad3x16(left_src + xd->dst.y_stride * 16,
- xd->dst.y_stride,
- left_ref + offset + ref_y_stride * 16,
- ref_y_stride);
- }
#endif
- }
-#endif
// Add the entry to our list and then resort the list on score.
ref_scores[i] = score;
sorted_mvs[i].as_int = this_mv.as_int;
@@ -268,14 +268,11 @@
}
// Make sure all the candidates are properly clamped etc
- for (i = 0; i < 4; ++i) {
+ for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) {
lower_mv_precision(&sorted_mvs[i], xd->allow_high_precision_mv);
clamp_mv2(&sorted_mvs[i], xd);
}
- // Set the best mv to the first entry in the sorted list
- best_mv->as_int = sorted_mvs[0].as_int;
-
// Provided that there are non zero vectors available there will not
// be more than one 0,0 entry in the sorted list.
// The best ref mv is always set to the first entry (which gave the best
« no previous file with comments | « source/libvpx/vp9/common/vp9_findnearmv.h ('k') | source/libvpx/vp9/common/vp9_header.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698