| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 |
| 11 #include <assert.h> | 11 #include <assert.h> |
| 12 | 12 |
| 13 #include "error_concealment.h" | 13 #include "error_concealment.h" |
| 14 #include "onyxd_int.h" | 14 #include "onyxd_int.h" |
| 15 #include "decodemv.h" | 15 #include "decodemv.h" |
| 16 #include "vpx_mem/vpx_mem.h" | 16 #include "vpx_mem/vpx_mem.h" |
| 17 #include "vp8/common/findnearmv.h" | 17 #include "vp8/common/findnearmv.h" |
| 18 #include "vp8/common/common.h" | 18 #include "vp8/common/common.h" |
| 19 #include "vpx_dsp/vpx_dsp_common.h" |
| 19 | 20 |
| 20 #define FLOOR(x,q) ((x) & -(1 << (q))) | 21 #define FLOOR(x,q) ((x) & -(1 << (q))) |
| 21 | 22 |
| 22 #define NUM_NEIGHBORS 20 | 23 #define NUM_NEIGHBORS 20 |
| 23 | 24 |
| 24 typedef struct ec_position | 25 typedef struct ec_position |
| 25 { | 26 { |
| 26 int row; | 27 int row; |
| 27 int col; | 28 int col; |
| 28 } EC_POS; | 29 } EC_POS; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 } | 87 } |
| 87 } | 88 } |
| 88 | 89 |
| 89 /* Calculates the overlap area between two 4x4 squares, where the first | 90 /* Calculates the overlap area between two 4x4 squares, where the first |
| 90 * square has its upper-left corner at (b1_row, b1_col) and the second | 91 * square has its upper-left corner at (b1_row, b1_col) and the second |
| 91 * square has its upper-left corner at (b2_row, b2_col). Doesn't | 92 * square has its upper-left corner at (b2_row, b2_col). Doesn't |
| 92 * properly handle squares which do not overlap. | 93 * properly handle squares which do not overlap. |
| 93 */ | 94 */ |
| 94 static int block_overlap(int b1_row, int b1_col, int b2_row, int b2_col) | 95 static int block_overlap(int b1_row, int b1_col, int b2_row, int b2_col) |
| 95 { | 96 { |
| 96 const int int_top = MAX(b1_row, b2_row); // top | 97 const int int_top = VPXMAX(b1_row, b2_row); // top |
| 97 const int int_left = MAX(b1_col, b2_col); // left | 98 const int int_left = VPXMAX(b1_col, b2_col); // left |
| 98 /* Since each block is 4x4 pixels, adding 4 (Q3) to the left/top edge | 99 /* Since each block is 4x4 pixels, adding 4 (Q3) to the left/top edge |
| 99 * gives us the right/bottom edge. | 100 * gives us the right/bottom edge. |
| 100 */ | 101 */ |
| 101 const int int_right = MIN(b1_col + (4<<3), b2_col + (4<<3)); // right | 102 const int int_right = VPXMIN(b1_col + (4<<3), b2_col + (4<<3)); // right |
| 102 const int int_bottom = MIN(b1_row + (4<<3), b2_row + (4<<3)); // bottom | 103 const int int_bottom = VPXMIN(b1_row + (4<<3), b2_row + (4<<3)); // bottom |
| 103 return (int_bottom - int_top) * (int_right - int_left); | 104 return (int_bottom - int_top) * (int_right - int_left); |
| 104 } | 105 } |
| 105 | 106 |
| 106 /* Calculates the overlap area for all blocks in a macroblock at position | 107 /* Calculates the overlap area for all blocks in a macroblock at position |
| 107 * (mb_row, mb_col) in macroblocks, which are being overlapped by a given | 108 * (mb_row, mb_col) in macroblocks, which are being overlapped by a given |
| 108 * overlapping block at position (new_row, new_col) (in pixels, Q3). The | 109 * overlapping block at position (new_row, new_col) (in pixels, Q3). The |
| 109 * first block being overlapped in the macroblock has position (first_blk_row, | 110 * first block being overlapped in the macroblock has position (first_blk_row, |
| 110 * first_blk_col) in blocks relative the upper-left corner of the image. | 111 * first_blk_col) in blocks relative the upper-left corner of the image. |
| 111 */ | 112 */ |
| 112 static void calculate_overlaps_mb(B_OVERLAP *b_overlaps, union b_mode_info *bmi, | 113 static void calculate_overlaps_mb(B_OVERLAP *b_overlaps, union b_mode_info *bmi, |
| 113 int new_row, int new_col, | 114 int new_row, int new_col, |
| 114 int mb_row, int mb_col, | 115 int mb_row, int mb_col, |
| 115 int first_blk_row, int first_blk_col) | 116 int first_blk_row, int first_blk_col) |
| 116 { | 117 { |
| 117 /* Find the blocks within this MB (defined by mb_row, mb_col) which are | 118 /* Find the blocks within this MB (defined by mb_row, mb_col) which are |
| 118 * overlapped by bmi and calculate and assign overlap for each of those | 119 * overlapped by bmi and calculate and assign overlap for each of those |
| 119 * blocks. */ | 120 * blocks. */ |
| 120 | 121 |
| 121 /* Block coordinates relative the upper-left block */ | 122 /* Block coordinates relative the upper-left block */ |
| 122 const int rel_ol_blk_row = first_blk_row - mb_row * 4; | 123 const int rel_ol_blk_row = first_blk_row - mb_row * 4; |
| 123 const int rel_ol_blk_col = first_blk_col - mb_col * 4; | 124 const int rel_ol_blk_col = first_blk_col - mb_col * 4; |
| 124 /* If the block partly overlaps any previous MB, these coordinates | 125 /* If the block partly overlaps any previous MB, these coordinates |
| 125 * can be < 0. We don't want to access blocks in previous MBs. | 126 * can be < 0. We don't want to access blocks in previous MBs. |
| 126 */ | 127 */ |
| 127 const int blk_idx = MAX(rel_ol_blk_row,0) * 4 + MAX(rel_ol_blk_col,0); | 128 const int blk_idx = VPXMAX(rel_ol_blk_row,0) * 4 + VPXMAX(rel_ol_blk_col,0); |
| 128 /* Upper left overlapping block */ | 129 /* Upper left overlapping block */ |
| 129 B_OVERLAP *b_ol_ul = &(b_overlaps[blk_idx]); | 130 B_OVERLAP *b_ol_ul = &(b_overlaps[blk_idx]); |
| 130 | 131 |
| 131 /* Calculate and assign overlaps for all blocks in this MB | 132 /* Calculate and assign overlaps for all blocks in this MB |
| 132 * which the motion compensated block overlaps | 133 * which the motion compensated block overlaps |
| 133 */ | 134 */ |
| 134 /* Avoid calculating overlaps for blocks in later MBs */ | 135 /* Avoid calculating overlaps for blocks in later MBs */ |
| 135 int end_row = MIN(4 + mb_row * 4 - first_blk_row, 2); | 136 int end_row = VPXMIN(4 + mb_row * 4 - first_blk_row, 2); |
| 136 int end_col = MIN(4 + mb_col * 4 - first_blk_col, 2); | 137 int end_col = VPXMIN(4 + mb_col * 4 - first_blk_col, 2); |
| 137 int row, col; | 138 int row, col; |
| 138 | 139 |
| 139 /* Check if new_row and new_col are evenly divisible by 4 (Q3), | 140 /* Check if new_row and new_col are evenly divisible by 4 (Q3), |
| 140 * and if so we shouldn't check neighboring blocks | 141 * and if so we shouldn't check neighboring blocks |
| 141 */ | 142 */ |
| 142 if (new_row >= 0 && (new_row & 0x1F) == 0) | 143 if (new_row >= 0 && (new_row & 0x1F) == 0) |
| 143 end_row = 1; | 144 end_row = 1; |
| 144 if (new_col >= 0 && (new_col & 0x1F) == 0) | 145 if (new_col >= 0 && (new_col & 0x1F) == 0) |
| 145 end_col = 1; | 146 end_col = 1; |
| 146 | 147 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 /* overlapping block's position in blocks */ | 202 /* overlapping block's position in blocks */ |
| 202 overlap_b_row = FLOOR(new_row / 4, 3) >> 3; | 203 overlap_b_row = FLOOR(new_row / 4, 3) >> 3; |
| 203 overlap_b_col = FLOOR(new_col / 4, 3) >> 3; | 204 overlap_b_col = FLOOR(new_col / 4, 3) >> 3; |
| 204 | 205 |
| 205 /* overlapping block's MB position in MBs | 206 /* overlapping block's MB position in MBs |
| 206 * operations are done in Q3 | 207 * operations are done in Q3 |
| 207 */ | 208 */ |
| 208 overlap_mb_row = FLOOR((overlap_b_row << 3) / 4, 3) >> 3; | 209 overlap_mb_row = FLOOR((overlap_b_row << 3) / 4, 3) >> 3; |
| 209 overlap_mb_col = FLOOR((overlap_b_col << 3) / 4, 3) >> 3; | 210 overlap_mb_col = FLOOR((overlap_b_col << 3) / 4, 3) >> 3; |
| 210 | 211 |
| 211 end_row = MIN(mb_rows - overlap_mb_row, 2); | 212 end_row = VPXMIN(mb_rows - overlap_mb_row, 2); |
| 212 end_col = MIN(mb_cols - overlap_mb_col, 2); | 213 end_col = VPXMIN(mb_cols - overlap_mb_col, 2); |
| 213 | 214 |
| 214 /* Don't calculate overlap for MBs we don't overlap */ | 215 /* Don't calculate overlap for MBs we don't overlap */ |
| 215 /* Check if the new block row starts at the last block row of the MB */ | 216 /* Check if the new block row starts at the last block row of the MB */ |
| 216 if (abs(new_row - ((16*overlap_mb_row) << 3)) < ((3*4) << 3)) | 217 if (abs(new_row - ((16*overlap_mb_row) << 3)) < ((3*4) << 3)) |
| 217 end_row = 1; | 218 end_row = 1; |
| 218 /* Check if the new block col starts at the last block col of the MB */ | 219 /* Check if the new block col starts at the last block col of the MB */ |
| 219 if (abs(new_col - ((16*overlap_mb_col) << 3)) < ((3*4) << 3)) | 220 if (abs(new_col - ((16*overlap_mb_col) << 3)) < ((3*4) << 3)) |
| 220 end_col = 1; | 221 end_col = 1; |
| 221 | 222 |
| 222 /* find the MB(s) this block is overlapping */ | 223 /* find the MB(s) this block is overlapping */ |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 | 588 |
| 588 void vp8_conceal_corrupt_mb(MACROBLOCKD *xd) | 589 void vp8_conceal_corrupt_mb(MACROBLOCKD *xd) |
| 589 { | 590 { |
| 590 /* This macroblock has corrupt residual, use the motion compensated | 591 /* This macroblock has corrupt residual, use the motion compensated |
| 591 image (predictor) for concealment */ | 592 image (predictor) for concealment */ |
| 592 | 593 |
| 593 /* The build predictor functions now output directly into the dst buffer, | 594 /* The build predictor functions now output directly into the dst buffer, |
| 594 * so the copies are no longer necessary */ | 595 * so the copies are no longer necessary */ |
| 595 | 596 |
| 596 } | 597 } |
| OLD | NEW |