michael@0: /* michael@0: * Copyright (c) 2011 The WebM project authors. All Rights Reserved. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license michael@0: * that can be found in the LICENSE file in the root of the source michael@0: * tree. An additional intellectual property rights grant can be found michael@0: * in the file PATENTS. All contributing project authors may michael@0: * be found in the AUTHORS file in the root of the source tree. michael@0: */ michael@0: michael@0: #include michael@0: michael@0: #include "error_concealment.h" michael@0: #include "onyxd_int.h" michael@0: #include "decodemv.h" michael@0: #include "vpx_mem/vpx_mem.h" michael@0: #include "vp8/common/findnearmv.h" michael@0: michael@0: #define MIN(x,y) (((x)<(y))?(x):(y)) michael@0: #define MAX(x,y) (((x)>(y))?(x):(y)) michael@0: michael@0: #define FLOOR(x,q) ((x) & -(1 << (q))) michael@0: michael@0: #define NUM_NEIGHBORS 20 michael@0: michael@0: typedef struct ec_position michael@0: { michael@0: int row; michael@0: int col; michael@0: } EC_POS; michael@0: michael@0: /* michael@0: * Regenerate the table in Matlab with: michael@0: * x = meshgrid((1:4), (1:4)); michael@0: * y = meshgrid((1:4), (1:4))'; michael@0: * W = round((1./(sqrt(x.^2 + y.^2))*2^7)); michael@0: * W(1,1) = 0; michael@0: */ michael@0: static const int weights_q7[5][5] = { michael@0: { 0, 128, 64, 43, 32 }, michael@0: {128, 91, 57, 40, 31 }, michael@0: { 64, 57, 45, 36, 29 }, michael@0: { 43, 40, 36, 30, 26 }, michael@0: { 32, 31, 29, 26, 23 } michael@0: }; michael@0: michael@0: int vp8_alloc_overlap_lists(VP8D_COMP *pbi) michael@0: { michael@0: if (pbi->overlaps != NULL) michael@0: { michael@0: vpx_free(pbi->overlaps); michael@0: pbi->overlaps = NULL; michael@0: } michael@0: michael@0: pbi->overlaps = vpx_calloc(pbi->common.mb_rows * pbi->common.mb_cols, michael@0: sizeof(MB_OVERLAP)); michael@0: michael@0: if (pbi->overlaps == NULL) michael@0: return -1; michael@0: michael@0: return 0; michael@0: } michael@0: michael@0: void vp8_de_alloc_overlap_lists(VP8D_COMP *pbi) michael@0: { michael@0: vpx_free(pbi->overlaps); michael@0: pbi->overlaps = NULL; michael@0: } michael@0: michael@0: /* Inserts a new overlap area value to the list of overlaps of a block */ michael@0: static void assign_overlap(OVERLAP_NODE* overlaps, michael@0: union b_mode_info *bmi, michael@0: int overlap) michael@0: { michael@0: int i; michael@0: if (overlap <= 0) michael@0: return; michael@0: /* Find and assign to the next empty overlap node in the list of overlaps. michael@0: * Empty is defined as bmi == NULL */ michael@0: for (i = 0; i < MAX_OVERLAPS; i++) michael@0: { michael@0: if (overlaps[i].bmi == NULL) michael@0: { michael@0: overlaps[i].bmi = bmi; michael@0: overlaps[i].overlap = overlap; michael@0: break; michael@0: } michael@0: } michael@0: } michael@0: michael@0: /* Calculates the overlap area between two 4x4 squares, where the first michael@0: * square has its upper-left corner at (b1_row, b1_col) and the second michael@0: * square has its upper-left corner at (b2_row, b2_col). Doesn't michael@0: * properly handle squares which do not overlap. michael@0: */ michael@0: static int block_overlap(int b1_row, int b1_col, int b2_row, int b2_col) michael@0: { michael@0: const int int_top = MAX(b1_row, b2_row); // top michael@0: const int int_left = MAX(b1_col, b2_col); // left michael@0: /* Since each block is 4x4 pixels, adding 4 (Q3) to the left/top edge michael@0: * gives us the right/bottom edge. michael@0: */ michael@0: const int int_right = MIN(b1_col + (4<<3), b2_col + (4<<3)); // right michael@0: const int int_bottom = MIN(b1_row + (4<<3), b2_row + (4<<3)); // bottom michael@0: return (int_bottom - int_top) * (int_right - int_left); michael@0: } michael@0: michael@0: /* Calculates the overlap area for all blocks in a macroblock at position michael@0: * (mb_row, mb_col) in macroblocks, which are being overlapped by a given michael@0: * overlapping block at position (new_row, new_col) (in pixels, Q3). The michael@0: * first block being overlapped in the macroblock has position (first_blk_row, michael@0: * first_blk_col) in blocks relative the upper-left corner of the image. michael@0: */ michael@0: static void calculate_overlaps_mb(B_OVERLAP *b_overlaps, union b_mode_info *bmi, michael@0: int new_row, int new_col, michael@0: int mb_row, int mb_col, michael@0: int first_blk_row, int first_blk_col) michael@0: { michael@0: /* Find the blocks within this MB (defined by mb_row, mb_col) which are michael@0: * overlapped by bmi and calculate and assign overlap for each of those michael@0: * blocks. */ michael@0: michael@0: /* Block coordinates relative the upper-left block */ michael@0: const int rel_ol_blk_row = first_blk_row - mb_row * 4; michael@0: const int rel_ol_blk_col = first_blk_col - mb_col * 4; michael@0: /* If the block partly overlaps any previous MB, these coordinates michael@0: * can be < 0. We don't want to access blocks in previous MBs. michael@0: */ michael@0: const int blk_idx = MAX(rel_ol_blk_row,0) * 4 + MAX(rel_ol_blk_col,0); michael@0: /* Upper left overlapping block */ michael@0: B_OVERLAP *b_ol_ul = &(b_overlaps[blk_idx]); michael@0: michael@0: /* Calculate and assign overlaps for all blocks in this MB michael@0: * which the motion compensated block overlaps michael@0: */ michael@0: /* Avoid calculating overlaps for blocks in later MBs */ michael@0: int end_row = MIN(4 + mb_row * 4 - first_blk_row, 2); michael@0: int end_col = MIN(4 + mb_col * 4 - first_blk_col, 2); michael@0: int row, col; michael@0: michael@0: /* Check if new_row and new_col are evenly divisible by 4 (Q3), michael@0: * and if so we shouldn't check neighboring blocks michael@0: */ michael@0: if (new_row >= 0 && (new_row & 0x1F) == 0) michael@0: end_row = 1; michael@0: if (new_col >= 0 && (new_col & 0x1F) == 0) michael@0: end_col = 1; michael@0: michael@0: /* Check if the overlapping block partly overlaps a previous MB michael@0: * and if so, we're overlapping fewer blocks in this MB. michael@0: */ michael@0: if (new_row < (mb_row*16)<<3) michael@0: end_row = 1; michael@0: if (new_col < (mb_col*16)<<3) michael@0: end_col = 1; michael@0: michael@0: for (row = 0; row < end_row; ++row) michael@0: { michael@0: for (col = 0; col < end_col; ++col) michael@0: { michael@0: /* input in Q3, result in Q6 */ michael@0: const int overlap = block_overlap(new_row, new_col, michael@0: (((first_blk_row + row) * michael@0: 4) << 3), michael@0: (((first_blk_col + col) * michael@0: 4) << 3)); michael@0: assign_overlap(b_ol_ul[row * 4 + col].overlaps, bmi, overlap); michael@0: } michael@0: } michael@0: } michael@0: michael@0: void vp8_calculate_overlaps(MB_OVERLAP *overlap_ul, michael@0: int mb_rows, int mb_cols, michael@0: union b_mode_info *bmi, michael@0: int b_row, int b_col) michael@0: { michael@0: MB_OVERLAP *mb_overlap; michael@0: int row, col, rel_row, rel_col; michael@0: int new_row, new_col; michael@0: int end_row, end_col; michael@0: int overlap_b_row, overlap_b_col; michael@0: int overlap_mb_row, overlap_mb_col; michael@0: michael@0: /* mb subpixel position */ michael@0: row = (4 * b_row) << 3; /* Q3 */ michael@0: col = (4 * b_col) << 3; /* Q3 */ michael@0: michael@0: /* reverse compensate for motion */ michael@0: new_row = row - bmi->mv.as_mv.row; michael@0: new_col = col - bmi->mv.as_mv.col; michael@0: michael@0: if (new_row >= ((16*mb_rows) << 3) || new_col >= ((16*mb_cols) << 3)) michael@0: { michael@0: /* the new block ended up outside the frame */ michael@0: return; michael@0: } michael@0: michael@0: if (new_row <= (-4 << 3) || new_col <= (-4 << 3)) michael@0: { michael@0: /* outside the frame */ michael@0: return; michael@0: } michael@0: /* overlapping block's position in blocks */ michael@0: overlap_b_row = FLOOR(new_row / 4, 3) >> 3; michael@0: overlap_b_col = FLOOR(new_col / 4, 3) >> 3; michael@0: michael@0: /* overlapping block's MB position in MBs michael@0: * operations are done in Q3 michael@0: */ michael@0: overlap_mb_row = FLOOR((overlap_b_row << 3) / 4, 3) >> 3; michael@0: overlap_mb_col = FLOOR((overlap_b_col << 3) / 4, 3) >> 3; michael@0: michael@0: end_row = MIN(mb_rows - overlap_mb_row, 2); michael@0: end_col = MIN(mb_cols - overlap_mb_col, 2); michael@0: michael@0: /* Don't calculate overlap for MBs we don't overlap */ michael@0: /* Check if the new block row starts at the last block row of the MB */ michael@0: if (abs(new_row - ((16*overlap_mb_row) << 3)) < ((3*4) << 3)) michael@0: end_row = 1; michael@0: /* Check if the new block col starts at the last block col of the MB */ michael@0: if (abs(new_col - ((16*overlap_mb_col) << 3)) < ((3*4) << 3)) michael@0: end_col = 1; michael@0: michael@0: /* find the MB(s) this block is overlapping */ michael@0: for (rel_row = 0; rel_row < end_row; ++rel_row) michael@0: { michael@0: for (rel_col = 0; rel_col < end_col; ++rel_col) michael@0: { michael@0: if (overlap_mb_row + rel_row < 0 || michael@0: overlap_mb_col + rel_col < 0) michael@0: continue; michael@0: mb_overlap = overlap_ul + (overlap_mb_row + rel_row) * mb_cols + michael@0: overlap_mb_col + rel_col; michael@0: michael@0: calculate_overlaps_mb(mb_overlap->overlaps, bmi, michael@0: new_row, new_col, michael@0: overlap_mb_row + rel_row, michael@0: overlap_mb_col + rel_col, michael@0: overlap_b_row + rel_row, michael@0: overlap_b_col + rel_col); michael@0: } michael@0: } michael@0: } michael@0: michael@0: /* Estimates a motion vector given the overlapping blocks' motion vectors. michael@0: * Filters out all overlapping blocks which do not refer to the correct michael@0: * reference frame type. michael@0: */ michael@0: static void estimate_mv(const OVERLAP_NODE *overlaps, union b_mode_info *bmi) michael@0: { michael@0: int i; michael@0: int overlap_sum = 0; michael@0: int row_acc = 0; michael@0: int col_acc = 0; michael@0: michael@0: bmi->mv.as_int = 0; michael@0: for (i=0; i < MAX_OVERLAPS; ++i) michael@0: { michael@0: if (overlaps[i].bmi == NULL) michael@0: break; michael@0: col_acc += overlaps[i].overlap * overlaps[i].bmi->mv.as_mv.col; michael@0: row_acc += overlaps[i].overlap * overlaps[i].bmi->mv.as_mv.row; michael@0: overlap_sum += overlaps[i].overlap; michael@0: } michael@0: if (overlap_sum > 0) michael@0: { michael@0: /* Q9 / Q6 = Q3 */ michael@0: bmi->mv.as_mv.col = col_acc / overlap_sum; michael@0: bmi->mv.as_mv.row = row_acc / overlap_sum; michael@0: } michael@0: else michael@0: { michael@0: bmi->mv.as_mv.col = 0; michael@0: bmi->mv.as_mv.row = 0; michael@0: } michael@0: } michael@0: michael@0: /* Estimates all motion vectors for a macroblock given the lists of michael@0: * overlaps for each block. Decides whether or not the MVs must be clamped. michael@0: */ michael@0: static void estimate_mb_mvs(const B_OVERLAP *block_overlaps, michael@0: MODE_INFO *mi, michael@0: int mb_to_left_edge, michael@0: int mb_to_right_edge, michael@0: int mb_to_top_edge, michael@0: int mb_to_bottom_edge) michael@0: { michael@0: int row, col; michael@0: int non_zero_count = 0; michael@0: MV * const filtered_mv = &(mi->mbmi.mv.as_mv); michael@0: union b_mode_info * const bmi = mi->bmi; michael@0: filtered_mv->col = 0; michael@0: filtered_mv->row = 0; michael@0: mi->mbmi.need_to_clamp_mvs = 0; michael@0: for (row = 0; row < 4; ++row) michael@0: { michael@0: int this_b_to_top_edge = mb_to_top_edge + ((row*4)<<3); michael@0: int this_b_to_bottom_edge = mb_to_bottom_edge - ((row*4)<<3); michael@0: for (col = 0; col < 4; ++col) michael@0: { michael@0: int i = row * 4 + col; michael@0: int this_b_to_left_edge = mb_to_left_edge + ((col*4)<<3); michael@0: int this_b_to_right_edge = mb_to_right_edge - ((col*4)<<3); michael@0: /* Estimate vectors for all blocks which are overlapped by this */ michael@0: /* type. Interpolate/extrapolate the rest of the block's MVs */ michael@0: estimate_mv(block_overlaps[i].overlaps, &(bmi[i])); michael@0: mi->mbmi.need_to_clamp_mvs |= vp8_check_mv_bounds( michael@0: &bmi[i].mv, michael@0: this_b_to_left_edge, michael@0: this_b_to_right_edge, michael@0: this_b_to_top_edge, michael@0: this_b_to_bottom_edge); michael@0: if (bmi[i].mv.as_int != 0) michael@0: { michael@0: ++non_zero_count; michael@0: filtered_mv->col += bmi[i].mv.as_mv.col; michael@0: filtered_mv->row += bmi[i].mv.as_mv.row; michael@0: } michael@0: } michael@0: } michael@0: if (non_zero_count > 0) michael@0: { michael@0: filtered_mv->col /= non_zero_count; michael@0: filtered_mv->row /= non_zero_count; michael@0: } michael@0: } michael@0: michael@0: static void calc_prev_mb_overlaps(MB_OVERLAP *overlaps, MODE_INFO *prev_mi, michael@0: int mb_row, int mb_col, michael@0: int mb_rows, int mb_cols) michael@0: { michael@0: int sub_row; michael@0: int sub_col; michael@0: for (sub_row = 0; sub_row < 4; ++sub_row) michael@0: { michael@0: for (sub_col = 0; sub_col < 4; ++sub_col) michael@0: { michael@0: vp8_calculate_overlaps( michael@0: overlaps, mb_rows, mb_cols, michael@0: &(prev_mi->bmi[sub_row * 4 + sub_col]), michael@0: 4 * mb_row + sub_row, michael@0: 4 * mb_col + sub_col); michael@0: } michael@0: } michael@0: } michael@0: michael@0: /* Estimate all missing motion vectors. This function does the same as the one michael@0: * above, but has different input arguments. */ michael@0: static void estimate_missing_mvs(MB_OVERLAP *overlaps, michael@0: MODE_INFO *mi, MODE_INFO *prev_mi, michael@0: int mb_rows, int mb_cols, michael@0: unsigned int first_corrupt) michael@0: { michael@0: int mb_row, mb_col; michael@0: vpx_memset(overlaps, 0, sizeof(MB_OVERLAP) * mb_rows * mb_cols); michael@0: /* First calculate the overlaps for all blocks */ michael@0: for (mb_row = 0; mb_row < mb_rows; ++mb_row) michael@0: { michael@0: for (mb_col = 0; mb_col < mb_cols; ++mb_col) michael@0: { michael@0: /* We're only able to use blocks referring to the last frame michael@0: * when extrapolating new vectors. michael@0: */ michael@0: if (prev_mi->mbmi.ref_frame == LAST_FRAME) michael@0: { michael@0: calc_prev_mb_overlaps(overlaps, prev_mi, michael@0: mb_row, mb_col, michael@0: mb_rows, mb_cols); michael@0: } michael@0: ++prev_mi; michael@0: } michael@0: ++prev_mi; michael@0: } michael@0: michael@0: mb_row = first_corrupt / mb_cols; michael@0: mb_col = first_corrupt - mb_row * mb_cols; michael@0: mi += mb_row*(mb_cols + 1) + mb_col; michael@0: /* Go through all macroblocks in the current image with missing MVs michael@0: * and calculate new MVs using the overlaps. michael@0: */ michael@0: for (; mb_row < mb_rows; ++mb_row) michael@0: { michael@0: int mb_to_top_edge = -((mb_row * 16)) << 3; michael@0: int mb_to_bottom_edge = ((mb_rows - 1 - mb_row) * 16) << 3; michael@0: for (; mb_col < mb_cols; ++mb_col) michael@0: { michael@0: int mb_to_left_edge = -((mb_col * 16) << 3); michael@0: int mb_to_right_edge = ((mb_cols - 1 - mb_col) * 16) << 3; michael@0: const B_OVERLAP *block_overlaps = michael@0: overlaps[mb_row*mb_cols + mb_col].overlaps; michael@0: mi->mbmi.ref_frame = LAST_FRAME; michael@0: mi->mbmi.mode = SPLITMV; michael@0: mi->mbmi.uv_mode = DC_PRED; michael@0: mi->mbmi.partitioning = 3; michael@0: mi->mbmi.segment_id = 0; michael@0: estimate_mb_mvs(block_overlaps, michael@0: mi, michael@0: mb_to_left_edge, michael@0: mb_to_right_edge, michael@0: mb_to_top_edge, michael@0: mb_to_bottom_edge); michael@0: ++mi; michael@0: } michael@0: mb_col = 0; michael@0: ++mi; michael@0: } michael@0: } michael@0: michael@0: void vp8_estimate_missing_mvs(VP8D_COMP *pbi) michael@0: { michael@0: VP8_COMMON * const pc = &pbi->common; michael@0: estimate_missing_mvs(pbi->overlaps, michael@0: pc->mi, pc->prev_mi, michael@0: pc->mb_rows, pc->mb_cols, michael@0: pbi->mvs_corrupt_from_mb); michael@0: } michael@0: michael@0: static void assign_neighbor(EC_BLOCK *neighbor, MODE_INFO *mi, int block_idx) michael@0: { michael@0: assert(mi->mbmi.ref_frame < MAX_REF_FRAMES); michael@0: neighbor->ref_frame = mi->mbmi.ref_frame; michael@0: neighbor->mv = mi->bmi[block_idx].mv.as_mv; michael@0: } michael@0: michael@0: /* Finds the neighboring blocks of a macroblocks. In the general case michael@0: * 20 blocks are found. If a fewer number of blocks are found due to michael@0: * image boundaries, those positions in the EC_BLOCK array are left "empty". michael@0: * The neighbors are enumerated with the upper-left neighbor as the first michael@0: * element, the second element refers to the neighbor to right of the previous michael@0: * neighbor, and so on. The last element refers to the neighbor below the first michael@0: * neighbor. michael@0: */ michael@0: static void find_neighboring_blocks(MODE_INFO *mi, michael@0: EC_BLOCK *neighbors, michael@0: int mb_row, int mb_col, michael@0: int mb_rows, int mb_cols, michael@0: int mi_stride) michael@0: { michael@0: int i = 0; michael@0: int j; michael@0: if (mb_row > 0) michael@0: { michael@0: /* upper left */ michael@0: if (mb_col > 0) michael@0: assign_neighbor(&neighbors[i], mi - mi_stride - 1, 15); michael@0: ++i; michael@0: /* above */ michael@0: for (j = 12; j < 16; ++j, ++i) michael@0: assign_neighbor(&neighbors[i], mi - mi_stride, j); michael@0: } michael@0: else michael@0: i += 5; michael@0: if (mb_col < mb_cols - 1) michael@0: { michael@0: /* upper right */ michael@0: if (mb_row > 0) michael@0: assign_neighbor(&neighbors[i], mi - mi_stride + 1, 12); michael@0: ++i; michael@0: /* right */ michael@0: for (j = 0; j <= 12; j += 4, ++i) michael@0: assign_neighbor(&neighbors[i], mi + 1, j); michael@0: } michael@0: else michael@0: i += 5; michael@0: if (mb_row < mb_rows - 1) michael@0: { michael@0: /* lower right */ michael@0: if (mb_col < mb_cols - 1) michael@0: assign_neighbor(&neighbors[i], mi + mi_stride + 1, 0); michael@0: ++i; michael@0: /* below */ michael@0: for (j = 0; j < 4; ++j, ++i) michael@0: assign_neighbor(&neighbors[i], mi + mi_stride, j); michael@0: } michael@0: else michael@0: i += 5; michael@0: if (mb_col > 0) michael@0: { michael@0: /* lower left */ michael@0: if (mb_row < mb_rows - 1) michael@0: assign_neighbor(&neighbors[i], mi + mi_stride - 1, 4); michael@0: ++i; michael@0: /* left */ michael@0: for (j = 3; j < 16; j += 4, ++i) michael@0: { michael@0: assign_neighbor(&neighbors[i], mi - 1, j); michael@0: } michael@0: } michael@0: else michael@0: i += 5; michael@0: assert(i == 20); michael@0: } michael@0: michael@0: /* Interpolates all motion vectors for a macroblock from the neighboring blocks' michael@0: * motion vectors. michael@0: */ michael@0: static void interpolate_mvs(MACROBLOCKD *mb, michael@0: EC_BLOCK *neighbors, michael@0: MV_REFERENCE_FRAME dom_ref_frame) michael@0: { michael@0: int row, col, i; michael@0: MODE_INFO * const mi = mb->mode_info_context; michael@0: /* Table with the position of the neighboring blocks relative the position michael@0: * of the upper left block of the current MB. Starting with the upper left michael@0: * neighbor and going to the right. michael@0: */ michael@0: const EC_POS neigh_pos[NUM_NEIGHBORS] = { michael@0: {-1,-1}, {-1,0}, {-1,1}, {-1,2}, {-1,3}, michael@0: {-1,4}, {0,4}, {1,4}, {2,4}, {3,4}, michael@0: {4,4}, {4,3}, {4,2}, {4,1}, {4,0}, michael@0: {4,-1}, {3,-1}, {2,-1}, {1,-1}, {0,-1} michael@0: }; michael@0: mi->mbmi.need_to_clamp_mvs = 0; michael@0: for (row = 0; row < 4; ++row) michael@0: { michael@0: int mb_to_top_edge = mb->mb_to_top_edge + ((row*4)<<3); michael@0: int mb_to_bottom_edge = mb->mb_to_bottom_edge - ((row*4)<<3); michael@0: for (col = 0; col < 4; ++col) michael@0: { michael@0: int mb_to_left_edge = mb->mb_to_left_edge + ((col*4)<<3); michael@0: int mb_to_right_edge = mb->mb_to_right_edge - ((col*4)<<3); michael@0: int w_sum = 0; michael@0: int mv_row_sum = 0; michael@0: int mv_col_sum = 0; michael@0: int_mv * const mv = &(mi->bmi[row*4 + col].mv); michael@0: mv->as_int = 0; michael@0: for (i = 0; i < NUM_NEIGHBORS; ++i) michael@0: { michael@0: /* Calculate the weighted sum of neighboring MVs referring michael@0: * to the dominant frame type. michael@0: */ michael@0: const int w = weights_q7[abs(row - neigh_pos[i].row)] michael@0: [abs(col - neigh_pos[i].col)]; michael@0: if (neighbors[i].ref_frame != dom_ref_frame) michael@0: continue; michael@0: w_sum += w; michael@0: /* Q7 * Q3 = Q10 */ michael@0: mv_row_sum += w*neighbors[i].mv.row; michael@0: mv_col_sum += w*neighbors[i].mv.col; michael@0: } michael@0: if (w_sum > 0) michael@0: { michael@0: /* Avoid division by zero. michael@0: * Normalize with the sum of the coefficients michael@0: * Q3 = Q10 / Q7 michael@0: */ michael@0: mv->as_mv.row = mv_row_sum / w_sum; michael@0: mv->as_mv.col = mv_col_sum / w_sum; michael@0: mi->mbmi.need_to_clamp_mvs |= vp8_check_mv_bounds( michael@0: mv, michael@0: mb_to_left_edge, michael@0: mb_to_right_edge, michael@0: mb_to_top_edge, michael@0: mb_to_bottom_edge); michael@0: } michael@0: } michael@0: } michael@0: } michael@0: michael@0: void vp8_interpolate_motion(MACROBLOCKD *mb, michael@0: int mb_row, int mb_col, michael@0: int mb_rows, int mb_cols, michael@0: int mi_stride) michael@0: { michael@0: /* Find relevant neighboring blocks */ michael@0: EC_BLOCK neighbors[NUM_NEIGHBORS]; michael@0: int i; michael@0: /* Initialize the array. MAX_REF_FRAMES is interpreted as "doesn't exist" */ michael@0: for (i = 0; i < NUM_NEIGHBORS; ++i) michael@0: { michael@0: neighbors[i].ref_frame = MAX_REF_FRAMES; michael@0: neighbors[i].mv.row = neighbors[i].mv.col = 0; michael@0: } michael@0: find_neighboring_blocks(mb->mode_info_context, michael@0: neighbors, michael@0: mb_row, mb_col, michael@0: mb_rows, mb_cols, michael@0: mb->mode_info_stride); michael@0: /* Interpolate MVs for the missing blocks from the surrounding michael@0: * blocks which refer to the last frame. */ michael@0: interpolate_mvs(mb, neighbors, LAST_FRAME); michael@0: michael@0: mb->mode_info_context->mbmi.ref_frame = LAST_FRAME; michael@0: mb->mode_info_context->mbmi.mode = SPLITMV; michael@0: mb->mode_info_context->mbmi.uv_mode = DC_PRED; michael@0: mb->mode_info_context->mbmi.partitioning = 3; michael@0: mb->mode_info_context->mbmi.segment_id = 0; michael@0: } michael@0: michael@0: void vp8_conceal_corrupt_mb(MACROBLOCKD *xd) michael@0: { michael@0: /* This macroblock has corrupt residual, use the motion compensated michael@0: image (predictor) for concealment */ michael@0: michael@0: /* The build predictor functions now output directly into the dst buffer, michael@0: * so the copies are no longer necessary */ michael@0: michael@0: }