Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
michael@0 | 3 | * |
michael@0 | 4 | * Use of this source code is governed by a BSD-style license |
michael@0 | 5 | * that can be found in the LICENSE file in the root of the source |
michael@0 | 6 | * tree. An additional intellectual property rights grant can be found |
michael@0 | 7 | * in the file PATENTS. All contributing project authors may |
michael@0 | 8 | * be found in the AUTHORS file in the root of the source tree. |
michael@0 | 9 | */ |
michael@0 | 10 | |
michael@0 | 11 | |
michael@0 | 12 | #include "vpx_config.h" |
michael@0 | 13 | #include "vp8_rtcd.h" |
michael@0 | 14 | #include "vpx_mem/vpx_mem.h" |
michael@0 | 15 | #include "blockd.h" |
michael@0 | 16 | |
michael@0 | 17 | void vp8_build_intra_predictors_mby_s_c(MACROBLOCKD *x, |
michael@0 | 18 | unsigned char * yabove_row, |
michael@0 | 19 | unsigned char * yleft, |
michael@0 | 20 | int left_stride, |
michael@0 | 21 | unsigned char * ypred_ptr, |
michael@0 | 22 | int y_stride) |
michael@0 | 23 | { |
michael@0 | 24 | unsigned char yleft_col[16]; |
michael@0 | 25 | unsigned char ytop_left = yabove_row[-1]; |
michael@0 | 26 | int r, c, i; |
michael@0 | 27 | |
michael@0 | 28 | for (i = 0; i < 16; i++) |
michael@0 | 29 | { |
michael@0 | 30 | yleft_col[i] = yleft[i* left_stride]; |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | /* for Y */ |
michael@0 | 34 | switch (x->mode_info_context->mbmi.mode) |
michael@0 | 35 | { |
michael@0 | 36 | case DC_PRED: |
michael@0 | 37 | { |
michael@0 | 38 | int expected_dc; |
michael@0 | 39 | int shift; |
michael@0 | 40 | int average = 0; |
michael@0 | 41 | |
michael@0 | 42 | |
michael@0 | 43 | if (x->up_available || x->left_available) |
michael@0 | 44 | { |
michael@0 | 45 | if (x->up_available) |
michael@0 | 46 | { |
michael@0 | 47 | for (i = 0; i < 16; i++) |
michael@0 | 48 | { |
michael@0 | 49 | average += yabove_row[i]; |
michael@0 | 50 | } |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | if (x->left_available) |
michael@0 | 54 | { |
michael@0 | 55 | |
michael@0 | 56 | for (i = 0; i < 16; i++) |
michael@0 | 57 | { |
michael@0 | 58 | average += yleft_col[i]; |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | |
michael@0 | 64 | |
michael@0 | 65 | shift = 3 + x->up_available + x->left_available; |
michael@0 | 66 | expected_dc = (average + (1 << (shift - 1))) >> shift; |
michael@0 | 67 | } |
michael@0 | 68 | else |
michael@0 | 69 | { |
michael@0 | 70 | expected_dc = 128; |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | /*vpx_memset(ypred_ptr, expected_dc, 256);*/ |
michael@0 | 74 | for (r = 0; r < 16; r++) |
michael@0 | 75 | { |
michael@0 | 76 | vpx_memset(ypred_ptr, expected_dc, 16); |
michael@0 | 77 | ypred_ptr += y_stride; |
michael@0 | 78 | } |
michael@0 | 79 | } |
michael@0 | 80 | break; |
michael@0 | 81 | case V_PRED: |
michael@0 | 82 | { |
michael@0 | 83 | |
michael@0 | 84 | for (r = 0; r < 16; r++) |
michael@0 | 85 | { |
michael@0 | 86 | |
michael@0 | 87 | ((int *)ypred_ptr)[0] = ((int *)yabove_row)[0]; |
michael@0 | 88 | ((int *)ypred_ptr)[1] = ((int *)yabove_row)[1]; |
michael@0 | 89 | ((int *)ypred_ptr)[2] = ((int *)yabove_row)[2]; |
michael@0 | 90 | ((int *)ypred_ptr)[3] = ((int *)yabove_row)[3]; |
michael@0 | 91 | ypred_ptr += y_stride; |
michael@0 | 92 | } |
michael@0 | 93 | } |
michael@0 | 94 | break; |
michael@0 | 95 | case H_PRED: |
michael@0 | 96 | { |
michael@0 | 97 | |
michael@0 | 98 | for (r = 0; r < 16; r++) |
michael@0 | 99 | { |
michael@0 | 100 | |
michael@0 | 101 | vpx_memset(ypred_ptr, yleft_col[r], 16); |
michael@0 | 102 | ypred_ptr += y_stride; |
michael@0 | 103 | } |
michael@0 | 104 | |
michael@0 | 105 | } |
michael@0 | 106 | break; |
michael@0 | 107 | case TM_PRED: |
michael@0 | 108 | { |
michael@0 | 109 | |
michael@0 | 110 | for (r = 0; r < 16; r++) |
michael@0 | 111 | { |
michael@0 | 112 | for (c = 0; c < 16; c++) |
michael@0 | 113 | { |
michael@0 | 114 | int pred = yleft_col[r] + yabove_row[ c] - ytop_left; |
michael@0 | 115 | |
michael@0 | 116 | if (pred < 0) |
michael@0 | 117 | pred = 0; |
michael@0 | 118 | |
michael@0 | 119 | if (pred > 255) |
michael@0 | 120 | pred = 255; |
michael@0 | 121 | |
michael@0 | 122 | ypred_ptr[c] = pred; |
michael@0 | 123 | } |
michael@0 | 124 | |
michael@0 | 125 | ypred_ptr += y_stride; |
michael@0 | 126 | } |
michael@0 | 127 | |
michael@0 | 128 | } |
michael@0 | 129 | break; |
michael@0 | 130 | case B_PRED: |
michael@0 | 131 | case NEARESTMV: |
michael@0 | 132 | case NEARMV: |
michael@0 | 133 | case ZEROMV: |
michael@0 | 134 | case NEWMV: |
michael@0 | 135 | case SPLITMV: |
michael@0 | 136 | case MB_MODE_COUNT: |
michael@0 | 137 | break; |
michael@0 | 138 | } |
michael@0 | 139 | } |
michael@0 | 140 | |
michael@0 | 141 | void vp8_build_intra_predictors_mbuv_s_c(MACROBLOCKD *x, |
michael@0 | 142 | unsigned char * uabove_row, |
michael@0 | 143 | unsigned char * vabove_row, |
michael@0 | 144 | unsigned char * uleft, |
michael@0 | 145 | unsigned char * vleft, |
michael@0 | 146 | int left_stride, |
michael@0 | 147 | unsigned char * upred_ptr, |
michael@0 | 148 | unsigned char * vpred_ptr, |
michael@0 | 149 | int pred_stride) |
michael@0 | 150 | { |
michael@0 | 151 | unsigned char uleft_col[8]; |
michael@0 | 152 | unsigned char utop_left = uabove_row[-1]; |
michael@0 | 153 | unsigned char vleft_col[8]; |
michael@0 | 154 | unsigned char vtop_left = vabove_row[-1]; |
michael@0 | 155 | |
michael@0 | 156 | int i, j; |
michael@0 | 157 | |
michael@0 | 158 | for (i = 0; i < 8; i++) |
michael@0 | 159 | { |
michael@0 | 160 | uleft_col[i] = uleft [i* left_stride]; |
michael@0 | 161 | vleft_col[i] = vleft [i* left_stride]; |
michael@0 | 162 | } |
michael@0 | 163 | |
michael@0 | 164 | switch (x->mode_info_context->mbmi.uv_mode) |
michael@0 | 165 | { |
michael@0 | 166 | case DC_PRED: |
michael@0 | 167 | { |
michael@0 | 168 | int expected_udc; |
michael@0 | 169 | int expected_vdc; |
michael@0 | 170 | int shift; |
michael@0 | 171 | int Uaverage = 0; |
michael@0 | 172 | int Vaverage = 0; |
michael@0 | 173 | |
michael@0 | 174 | if (x->up_available) |
michael@0 | 175 | { |
michael@0 | 176 | for (i = 0; i < 8; i++) |
michael@0 | 177 | { |
michael@0 | 178 | Uaverage += uabove_row[i]; |
michael@0 | 179 | Vaverage += vabove_row[i]; |
michael@0 | 180 | } |
michael@0 | 181 | } |
michael@0 | 182 | |
michael@0 | 183 | if (x->left_available) |
michael@0 | 184 | { |
michael@0 | 185 | for (i = 0; i < 8; i++) |
michael@0 | 186 | { |
michael@0 | 187 | Uaverage += uleft_col[i]; |
michael@0 | 188 | Vaverage += vleft_col[i]; |
michael@0 | 189 | } |
michael@0 | 190 | } |
michael@0 | 191 | |
michael@0 | 192 | if (!x->up_available && !x->left_available) |
michael@0 | 193 | { |
michael@0 | 194 | expected_udc = 128; |
michael@0 | 195 | expected_vdc = 128; |
michael@0 | 196 | } |
michael@0 | 197 | else |
michael@0 | 198 | { |
michael@0 | 199 | shift = 2 + x->up_available + x->left_available; |
michael@0 | 200 | expected_udc = (Uaverage + (1 << (shift - 1))) >> shift; |
michael@0 | 201 | expected_vdc = (Vaverage + (1 << (shift - 1))) >> shift; |
michael@0 | 202 | } |
michael@0 | 203 | |
michael@0 | 204 | |
michael@0 | 205 | /*vpx_memset(upred_ptr,expected_udc,64);*/ |
michael@0 | 206 | /*vpx_memset(vpred_ptr,expected_vdc,64);*/ |
michael@0 | 207 | for (i = 0; i < 8; i++) |
michael@0 | 208 | { |
michael@0 | 209 | vpx_memset(upred_ptr, expected_udc, 8); |
michael@0 | 210 | vpx_memset(vpred_ptr, expected_vdc, 8); |
michael@0 | 211 | upred_ptr += pred_stride; |
michael@0 | 212 | vpred_ptr += pred_stride; |
michael@0 | 213 | } |
michael@0 | 214 | } |
michael@0 | 215 | break; |
michael@0 | 216 | case V_PRED: |
michael@0 | 217 | { |
michael@0 | 218 | for (i = 0; i < 8; i++) |
michael@0 | 219 | { |
michael@0 | 220 | vpx_memcpy(upred_ptr, uabove_row, 8); |
michael@0 | 221 | vpx_memcpy(vpred_ptr, vabove_row, 8); |
michael@0 | 222 | upred_ptr += pred_stride; |
michael@0 | 223 | vpred_ptr += pred_stride; |
michael@0 | 224 | } |
michael@0 | 225 | |
michael@0 | 226 | } |
michael@0 | 227 | break; |
michael@0 | 228 | case H_PRED: |
michael@0 | 229 | { |
michael@0 | 230 | for (i = 0; i < 8; i++) |
michael@0 | 231 | { |
michael@0 | 232 | vpx_memset(upred_ptr, uleft_col[i], 8); |
michael@0 | 233 | vpx_memset(vpred_ptr, vleft_col[i], 8); |
michael@0 | 234 | upred_ptr += pred_stride; |
michael@0 | 235 | vpred_ptr += pred_stride; |
michael@0 | 236 | } |
michael@0 | 237 | } |
michael@0 | 238 | |
michael@0 | 239 | break; |
michael@0 | 240 | case TM_PRED: |
michael@0 | 241 | { |
michael@0 | 242 | for (i = 0; i < 8; i++) |
michael@0 | 243 | { |
michael@0 | 244 | for (j = 0; j < 8; j++) |
michael@0 | 245 | { |
michael@0 | 246 | int predu = uleft_col[i] + uabove_row[j] - utop_left; |
michael@0 | 247 | int predv = vleft_col[i] + vabove_row[j] - vtop_left; |
michael@0 | 248 | |
michael@0 | 249 | if (predu < 0) |
michael@0 | 250 | predu = 0; |
michael@0 | 251 | |
michael@0 | 252 | if (predu > 255) |
michael@0 | 253 | predu = 255; |
michael@0 | 254 | |
michael@0 | 255 | if (predv < 0) |
michael@0 | 256 | predv = 0; |
michael@0 | 257 | |
michael@0 | 258 | if (predv > 255) |
michael@0 | 259 | predv = 255; |
michael@0 | 260 | |
michael@0 | 261 | upred_ptr[j] = predu; |
michael@0 | 262 | vpred_ptr[j] = predv; |
michael@0 | 263 | } |
michael@0 | 264 | |
michael@0 | 265 | upred_ptr += pred_stride; |
michael@0 | 266 | vpred_ptr += pred_stride; |
michael@0 | 267 | } |
michael@0 | 268 | |
michael@0 | 269 | } |
michael@0 | 270 | break; |
michael@0 | 271 | case B_PRED: |
michael@0 | 272 | case NEARESTMV: |
michael@0 | 273 | case NEARMV: |
michael@0 | 274 | case ZEROMV: |
michael@0 | 275 | case NEWMV: |
michael@0 | 276 | case SPLITMV: |
michael@0 | 277 | case MB_MODE_COUNT: |
michael@0 | 278 | break; |
michael@0 | 279 | } |
michael@0 | 280 | } |