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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 enum mv_precision mv_precision_uv; | 49 enum mv_precision mv_precision_uv; |
50 int uv_stride; | 50 int uv_stride; |
51 if (uv_block_width == 8) { | 51 if (uv_block_width == 8) { |
52 uv_stride = (stride + 1) >> 1; | 52 uv_stride = (stride + 1) >> 1; |
53 mv_precision_uv = MV_PRECISION_Q4; | 53 mv_precision_uv = MV_PRECISION_Q4; |
54 } else { | 54 } else { |
55 uv_stride = stride; | 55 uv_stride = stride; |
56 mv_precision_uv = MV_PRECISION_Q3; | 56 mv_precision_uv = MV_PRECISION_Q3; |
57 } | 57 } |
58 | 58 |
| 59 #if CONFIG_VP9_HIGHBITDEPTH |
| 60 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { |
| 61 vp9_highbd_build_inter_predictor(y_mb_ptr, stride, |
| 62 &pred[0], 16, |
| 63 &mv, |
| 64 scale, |
| 65 16, 16, |
| 66 which_mv, |
| 67 kernel, MV_PRECISION_Q3, x, y, xd->bd); |
| 68 |
| 69 vp9_highbd_build_inter_predictor(u_mb_ptr, uv_stride, |
| 70 &pred[256], uv_block_width, |
| 71 &mv, |
| 72 scale, |
| 73 uv_block_width, uv_block_height, |
| 74 which_mv, |
| 75 kernel, mv_precision_uv, x, y, xd->bd); |
| 76 |
| 77 vp9_highbd_build_inter_predictor(v_mb_ptr, uv_stride, |
| 78 &pred[512], uv_block_width, |
| 79 &mv, |
| 80 scale, |
| 81 uv_block_width, uv_block_height, |
| 82 which_mv, |
| 83 kernel, mv_precision_uv, x, y, xd->bd); |
| 84 return; |
| 85 } |
| 86 #endif // CONFIG_VP9_HIGHBITDEPTH |
59 vp9_build_inter_predictor(y_mb_ptr, stride, | 87 vp9_build_inter_predictor(y_mb_ptr, stride, |
60 &pred[0], 16, | 88 &pred[0], 16, |
61 &mv, | 89 &mv, |
62 scale, | 90 scale, |
63 16, 16, | 91 16, 16, |
64 which_mv, | 92 which_mv, |
65 kernel, MV_PRECISION_Q3, x, y); | 93 kernel, MV_PRECISION_Q3, x, y); |
66 | 94 |
67 vp9_build_inter_predictor(u_mb_ptr, uv_stride, | 95 vp9_build_inter_predictor(u_mb_ptr, uv_stride, |
68 &pred[256], uv_block_width, | 96 &pred[256], uv_block_width, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 count[k] += modifier; | 154 count[k] += modifier; |
127 accumulator[k] += modifier * pixel_value; | 155 accumulator[k] += modifier * pixel_value; |
128 | 156 |
129 byte++; | 157 byte++; |
130 } | 158 } |
131 | 159 |
132 byte += stride - block_width; | 160 byte += stride - block_width; |
133 } | 161 } |
134 } | 162 } |
135 | 163 |
| 164 #if CONFIG_VP9_HIGHBITDEPTH |
| 165 void vp9_highbd_temporal_filter_apply_c(uint8_t *frame1_8, |
| 166 unsigned int stride, |
| 167 uint8_t *frame2_8, |
| 168 unsigned int block_width, |
| 169 unsigned int block_height, |
| 170 int strength, |
| 171 int filter_weight, |
| 172 unsigned int *accumulator, |
| 173 uint16_t *count) { |
| 174 uint16_t *frame1 = CONVERT_TO_SHORTPTR(frame1_8); |
| 175 uint16_t *frame2 = CONVERT_TO_SHORTPTR(frame2_8); |
| 176 unsigned int i, j, k; |
| 177 int modifier; |
| 178 int byte = 0; |
| 179 const int rounding = strength > 0 ? 1 << (strength - 1) : 0; |
| 180 |
| 181 for (i = 0, k = 0; i < block_height; i++) { |
| 182 for (j = 0; j < block_width; j++, k++) { |
| 183 int src_byte = frame1[byte]; |
| 184 int pixel_value = *frame2++; |
| 185 |
| 186 modifier = src_byte - pixel_value; |
| 187 // This is an integer approximation of: |
| 188 // float coeff = (3.0 * modifer * modifier) / pow(2, strength); |
| 189 // modifier = (int)roundf(coeff > 16 ? 0 : 16-coeff); |
| 190 modifier *= modifier; |
| 191 modifier *= 3; |
| 192 modifier += rounding; |
| 193 modifier >>= strength; |
| 194 |
| 195 if (modifier > 16) |
| 196 modifier = 16; |
| 197 |
| 198 modifier = 16 - modifier; |
| 199 modifier *= filter_weight; |
| 200 |
| 201 count[k] += modifier; |
| 202 accumulator[k] += modifier * pixel_value; |
| 203 |
| 204 byte++; |
| 205 } |
| 206 |
| 207 byte += stride - block_width; |
| 208 } |
| 209 } |
| 210 #endif // CONFIG_VP9_HIGHBITDEPTH |
| 211 |
136 static int temporal_filter_find_matching_mb_c(VP9_COMP *cpi, | 212 static int temporal_filter_find_matching_mb_c(VP9_COMP *cpi, |
137 uint8_t *arf_frame_buf, | 213 uint8_t *arf_frame_buf, |
138 uint8_t *frame_ptr_buf, | 214 uint8_t *frame_ptr_buf, |
139 int stride) { | 215 int stride) { |
140 MACROBLOCK *const x = &cpi->mb; | 216 MACROBLOCK *const x = &cpi->mb; |
141 MACROBLOCKD *const xd = &x->e_mbd; | 217 MACROBLOCKD *const xd = &x->e_mbd; |
142 const MV_SPEED_FEATURES *const mv_sf = &cpi->sf.mv; | 218 const MV_SPEED_FEATURES *const mv_sf = &cpi->sf.mv; |
143 int step_param; | 219 int step_param; |
144 int sadpb = x->sadperbit16; | 220 int sadpb = x->sadperbit16; |
145 int bestsme = INT_MAX; | 221 int bestsme = INT_MAX; |
146 int distortion; | 222 int distortion; |
147 unsigned int sse; | 223 unsigned int sse; |
148 int sad_list[5]; | 224 int cost_list[5]; |
149 | 225 |
150 MV best_ref_mv1 = {0, 0}; | 226 MV best_ref_mv1 = {0, 0}; |
151 MV best_ref_mv1_full; /* full-pixel value of best_ref_mv1 */ | 227 MV best_ref_mv1_full; /* full-pixel value of best_ref_mv1 */ |
152 MV *ref_mv = &x->e_mbd.mi[0].src_mi->bmi[0].as_mv[0].as_mv; | 228 MV *ref_mv = &x->e_mbd.mi[0].src_mi->bmi[0].as_mv[0].as_mv; |
153 | 229 |
154 // Save input state | 230 // Save input state |
155 struct buf_2d src = x->plane[0].src; | 231 struct buf_2d src = x->plane[0].src; |
156 struct buf_2d pre = xd->plane[0].pre[0]; | 232 struct buf_2d pre = xd->plane[0].pre[0]; |
157 | 233 |
158 best_ref_mv1_full.col = best_ref_mv1.col >> 3; | 234 best_ref_mv1_full.col = best_ref_mv1.col >> 3; |
159 best_ref_mv1_full.row = best_ref_mv1.row >> 3; | 235 best_ref_mv1_full.row = best_ref_mv1.row >> 3; |
160 | 236 |
161 // Setup frame pointers | 237 // Setup frame pointers |
162 x->plane[0].src.buf = arf_frame_buf; | 238 x->plane[0].src.buf = arf_frame_buf; |
163 x->plane[0].src.stride = stride; | 239 x->plane[0].src.stride = stride; |
164 xd->plane[0].pre[0].buf = frame_ptr_buf; | 240 xd->plane[0].pre[0].buf = frame_ptr_buf; |
165 xd->plane[0].pre[0].stride = stride; | 241 xd->plane[0].pre[0].stride = stride; |
166 | 242 |
167 step_param = mv_sf->reduce_first_step_size; | 243 step_param = mv_sf->reduce_first_step_size; |
168 step_param = MIN(step_param, MAX_MVSEARCH_STEPS - 2); | 244 step_param = MIN(step_param, MAX_MVSEARCH_STEPS - 2); |
169 | 245 |
170 // Ignore mv costing by sending NULL pointer instead of cost arrays | 246 // Ignore mv costing by sending NULL pointer instead of cost arrays |
171 vp9_hex_search(x, &best_ref_mv1_full, step_param, sadpb, 1, | 247 vp9_hex_search(x, &best_ref_mv1_full, step_param, sadpb, 1, |
172 cond_sad_list(cpi, sad_list), | 248 cond_cost_list(cpi, cost_list), |
173 &cpi->fn_ptr[BLOCK_16X16], 0, &best_ref_mv1, ref_mv); | 249 &cpi->fn_ptr[BLOCK_16X16], 0, &best_ref_mv1, ref_mv); |
174 | 250 |
175 // Ignore mv costing by sending NULL pointer instead of cost array | 251 // Ignore mv costing by sending NULL pointer instead of cost array |
176 bestsme = cpi->find_fractional_mv_step(x, ref_mv, | 252 bestsme = cpi->find_fractional_mv_step(x, ref_mv, |
177 &best_ref_mv1, | 253 &best_ref_mv1, |
178 cpi->common.allow_high_precision_mv, | 254 cpi->common.allow_high_precision_mv, |
179 x->errorperbit, | 255 x->errorperbit, |
180 &cpi->fn_ptr[BLOCK_16X16], | 256 &cpi->fn_ptr[BLOCK_16X16], |
181 0, mv_sf->subpel_iters_per_step, | 257 0, mv_sf->subpel_iters_per_step, |
182 cond_sad_list(cpi, sad_list), | 258 cond_cost_list(cpi, cost_list), |
183 NULL, NULL, | 259 NULL, NULL, |
184 &distortion, &sse, NULL, 0, 0); | 260 &distortion, &sse, NULL, 0, 0); |
185 | 261 |
186 // Restore input state | 262 // Restore input state |
187 x->plane[0].src = src; | 263 x->plane[0].src = src; |
188 xd->plane[0].pre[0] = pre; | 264 xd->plane[0].pre[0] = pre; |
189 | 265 |
190 return bestsme; | 266 return bestsme; |
191 } | 267 } |
192 | 268 |
193 static void temporal_filter_iterate_c(VP9_COMP *cpi, | 269 static void temporal_filter_iterate_c(VP9_COMP *cpi, |
194 YV12_BUFFER_CONFIG **frames, | 270 YV12_BUFFER_CONFIG **frames, |
195 int frame_count, | 271 int frame_count, |
196 int alt_ref_index, | 272 int alt_ref_index, |
197 int strength, | 273 int strength, |
198 struct scale_factors *scale) { | 274 struct scale_factors *scale) { |
199 int byte; | 275 int byte; |
200 int frame; | 276 int frame; |
201 int mb_col, mb_row; | 277 int mb_col, mb_row; |
202 unsigned int filter_weight; | 278 unsigned int filter_weight; |
203 int mb_cols = (frames[alt_ref_index]->y_crop_width + 15) >> 4; | 279 int mb_cols = (frames[alt_ref_index]->y_crop_width + 15) >> 4; |
204 int mb_rows = (frames[alt_ref_index]->y_crop_height + 15) >> 4; | 280 int mb_rows = (frames[alt_ref_index]->y_crop_height + 15) >> 4; |
205 int mb_y_offset = 0; | 281 int mb_y_offset = 0; |
206 int mb_uv_offset = 0; | 282 int mb_uv_offset = 0; |
207 DECLARE_ALIGNED_ARRAY(16, unsigned int, accumulator, 16 * 16 * 3); | 283 DECLARE_ALIGNED_ARRAY(16, unsigned int, accumulator, 16 * 16 * 3); |
208 DECLARE_ALIGNED_ARRAY(16, uint16_t, count, 16 * 16 * 3); | 284 DECLARE_ALIGNED_ARRAY(16, uint16_t, count, 16 * 16 * 3); |
209 MACROBLOCKD *mbd = &cpi->mb.e_mbd; | 285 MACROBLOCKD *mbd = &cpi->mb.e_mbd; |
210 YV12_BUFFER_CONFIG *f = frames[alt_ref_index]; | 286 YV12_BUFFER_CONFIG *f = frames[alt_ref_index]; |
211 uint8_t *dst1, *dst2; | 287 uint8_t *dst1, *dst2; |
| 288 #if CONFIG_VP9_HIGHBITDEPTH |
| 289 DECLARE_ALIGNED_ARRAY(16, uint16_t, predictor16, 16 * 16 * 3); |
| 290 DECLARE_ALIGNED_ARRAY(16, uint8_t, predictor8, 16 * 16 * 3); |
| 291 uint8_t *predictor; |
| 292 #else |
212 DECLARE_ALIGNED_ARRAY(16, uint8_t, predictor, 16 * 16 * 3); | 293 DECLARE_ALIGNED_ARRAY(16, uint8_t, predictor, 16 * 16 * 3); |
| 294 #endif |
213 const int mb_uv_height = 16 >> mbd->plane[1].subsampling_y; | 295 const int mb_uv_height = 16 >> mbd->plane[1].subsampling_y; |
214 const int mb_uv_width = 16 >> mbd->plane[1].subsampling_x; | 296 const int mb_uv_width = 16 >> mbd->plane[1].subsampling_x; |
215 | 297 |
216 // Save input state | 298 // Save input state |
217 uint8_t* input_buffer[MAX_MB_PLANE]; | 299 uint8_t* input_buffer[MAX_MB_PLANE]; |
218 int i; | 300 int i; |
| 301 #if CONFIG_VP9_HIGHBITDEPTH |
| 302 if (mbd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { |
| 303 predictor = CONVERT_TO_BYTEPTR(predictor16); |
| 304 } else { |
| 305 predictor = predictor8; |
| 306 } |
| 307 #endif |
219 | 308 |
220 for (i = 0; i < MAX_MB_PLANE; i++) | 309 for (i = 0; i < MAX_MB_PLANE; i++) |
221 input_buffer[i] = mbd->plane[i].pre[0].buf; | 310 input_buffer[i] = mbd->plane[i].pre[0].buf; |
222 | 311 |
223 for (mb_row = 0; mb_row < mb_rows; mb_row++) { | 312 for (mb_row = 0; mb_row < mb_rows; mb_row++) { |
224 // Source frames are extended to 16 pixels. This is different than | 313 // Source frames are extended to 16 pixels. This is different than |
225 // L/A/G reference frames that have a border of 32 (VP9ENCBORDERINPIXELS) | 314 // L/A/G reference frames that have a border of 32 (VP9ENCBORDERINPIXELS) |
226 // A 6/8 tap filter is used for motion search. This requires 2 pixels | 315 // A 6/8 tap filter is used for motion search. This requires 2 pixels |
227 // before and 3 pixels after. So the largest Y mv on a border would | 316 // before and 3 pixels after. So the largest Y mv on a border would |
228 // then be 16 - VP9_INTERP_EXTEND. The UV blocks are half the size of the | 317 // then be 16 - VP9_INTERP_EXTEND. The UV blocks are half the size of the |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 frames[frame]->y_buffer + mb_y_offset, | 368 frames[frame]->y_buffer + mb_y_offset, |
280 frames[frame]->u_buffer + mb_uv_offset, | 369 frames[frame]->u_buffer + mb_uv_offset, |
281 frames[frame]->v_buffer + mb_uv_offset, | 370 frames[frame]->v_buffer + mb_uv_offset, |
282 frames[frame]->y_stride, | 371 frames[frame]->y_stride, |
283 mb_uv_width, mb_uv_height, | 372 mb_uv_width, mb_uv_height, |
284 mbd->mi[0].src_mi->bmi[0].as_mv[0].as_mv.row, | 373 mbd->mi[0].src_mi->bmi[0].as_mv[0].as_mv.row, |
285 mbd->mi[0].src_mi->bmi[0].as_mv[0].as_mv.col, | 374 mbd->mi[0].src_mi->bmi[0].as_mv[0].as_mv.col, |
286 predictor, scale, | 375 predictor, scale, |
287 mb_col * 16, mb_row * 16); | 376 mb_col * 16, mb_row * 16); |
288 | 377 |
| 378 #if CONFIG_VP9_HIGHBITDEPTH |
| 379 if (mbd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { |
| 380 int adj_strength = strength + 2 * (mbd->bd - 8); |
| 381 // Apply the filter (YUV) |
| 382 vp9_highbd_temporal_filter_apply(f->y_buffer + mb_y_offset, |
| 383 f->y_stride, |
| 384 predictor, 16, 16, adj_strength, |
| 385 filter_weight, |
| 386 accumulator, count); |
| 387 vp9_highbd_temporal_filter_apply(f->u_buffer + mb_uv_offset, |
| 388 f->uv_stride, predictor + 256, |
| 389 mb_uv_width, mb_uv_height, |
| 390 adj_strength, |
| 391 filter_weight, accumulator + 256, |
| 392 count + 256); |
| 393 vp9_highbd_temporal_filter_apply(f->v_buffer + mb_uv_offset, |
| 394 f->uv_stride, predictor + 512, |
| 395 mb_uv_width, mb_uv_height, |
| 396 adj_strength, filter_weight, |
| 397 accumulator + 512, count + 512); |
| 398 } else { |
| 399 // Apply the filter (YUV) |
| 400 vp9_temporal_filter_apply(f->y_buffer + mb_y_offset, f->y_stride, |
| 401 predictor, 16, 16, |
| 402 strength, filter_weight, |
| 403 accumulator, count); |
| 404 vp9_temporal_filter_apply(f->u_buffer + mb_uv_offset, f->uv_stride, |
| 405 predictor + 256, |
| 406 mb_uv_width, mb_uv_height, strength, |
| 407 filter_weight, accumulator + 256, |
| 408 count + 256); |
| 409 vp9_temporal_filter_apply(f->v_buffer + mb_uv_offset, f->uv_stride, |
| 410 predictor + 512, |
| 411 mb_uv_width, mb_uv_height, strength, |
| 412 filter_weight, accumulator + 512, |
| 413 count + 512); |
| 414 } |
| 415 #else |
289 // Apply the filter (YUV) | 416 // Apply the filter (YUV) |
290 vp9_temporal_filter_apply(f->y_buffer + mb_y_offset, f->y_stride, | 417 vp9_temporal_filter_apply(f->y_buffer + mb_y_offset, f->y_stride, |
291 predictor, 16, 16, | 418 predictor, 16, 16, |
292 strength, filter_weight, | 419 strength, filter_weight, |
293 accumulator, count); | 420 accumulator, count); |
294 vp9_temporal_filter_apply(f->u_buffer + mb_uv_offset, f->uv_stride, | 421 vp9_temporal_filter_apply(f->u_buffer + mb_uv_offset, f->uv_stride, |
295 predictor + 256, | 422 predictor + 256, |
296 mb_uv_width, mb_uv_height, strength, | 423 mb_uv_width, mb_uv_height, strength, |
297 filter_weight, accumulator + 256, | 424 filter_weight, accumulator + 256, |
298 count + 256); | 425 count + 256); |
299 vp9_temporal_filter_apply(f->v_buffer + mb_uv_offset, f->uv_stride, | 426 vp9_temporal_filter_apply(f->v_buffer + mb_uv_offset, f->uv_stride, |
300 predictor + 512, | 427 predictor + 512, |
301 mb_uv_width, mb_uv_height, strength, | 428 mb_uv_width, mb_uv_height, strength, |
302 filter_weight, accumulator + 512, | 429 filter_weight, accumulator + 512, |
303 count + 512); | 430 count + 512); |
| 431 #endif // CONFIG_VP9_HIGHBITDEPTH |
304 } | 432 } |
305 } | 433 } |
306 | 434 |
| 435 #if CONFIG_VP9_HIGHBITDEPTH |
| 436 if (mbd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { |
| 437 uint16_t *dst1_16; |
| 438 uint16_t *dst2_16; |
| 439 // Normalize filter output to produce AltRef frame |
| 440 dst1 = cpi->alt_ref_buffer.y_buffer; |
| 441 dst1_16 = CONVERT_TO_SHORTPTR(dst1); |
| 442 stride = cpi->alt_ref_buffer.y_stride; |
| 443 byte = mb_y_offset; |
| 444 for (i = 0, k = 0; i < 16; i++) { |
| 445 for (j = 0; j < 16; j++, k++) { |
| 446 unsigned int pval = accumulator[k] + (count[k] >> 1); |
| 447 pval *= fixed_divide[count[k]]; |
| 448 pval >>= 19; |
| 449 |
| 450 dst1_16[byte] = (uint16_t)pval; |
| 451 |
| 452 // move to next pixel |
| 453 byte++; |
| 454 } |
| 455 |
| 456 byte += stride - 16; |
| 457 } |
| 458 |
| 459 dst1 = cpi->alt_ref_buffer.u_buffer; |
| 460 dst2 = cpi->alt_ref_buffer.v_buffer; |
| 461 dst1_16 = CONVERT_TO_SHORTPTR(dst1); |
| 462 dst2_16 = CONVERT_TO_SHORTPTR(dst2); |
| 463 stride = cpi->alt_ref_buffer.uv_stride; |
| 464 byte = mb_uv_offset; |
| 465 for (i = 0, k = 256; i < mb_uv_height; i++) { |
| 466 for (j = 0; j < mb_uv_width; j++, k++) { |
| 467 int m = k + 256; |
| 468 |
| 469 // U |
| 470 unsigned int pval = accumulator[k] + (count[k] >> 1); |
| 471 pval *= fixed_divide[count[k]]; |
| 472 pval >>= 19; |
| 473 dst1_16[byte] = (uint16_t)pval; |
| 474 |
| 475 // V |
| 476 pval = accumulator[m] + (count[m] >> 1); |
| 477 pval *= fixed_divide[count[m]]; |
| 478 pval >>= 19; |
| 479 dst2_16[byte] = (uint16_t)pval; |
| 480 |
| 481 // move to next pixel |
| 482 byte++; |
| 483 } |
| 484 |
| 485 byte += stride - mb_uv_width; |
| 486 } |
| 487 } else { |
| 488 // Normalize filter output to produce AltRef frame |
| 489 dst1 = cpi->alt_ref_buffer.y_buffer; |
| 490 stride = cpi->alt_ref_buffer.y_stride; |
| 491 byte = mb_y_offset; |
| 492 for (i = 0, k = 0; i < 16; i++) { |
| 493 for (j = 0; j < 16; j++, k++) { |
| 494 unsigned int pval = accumulator[k] + (count[k] >> 1); |
| 495 pval *= fixed_divide[count[k]]; |
| 496 pval >>= 19; |
| 497 |
| 498 dst1[byte] = (uint8_t)pval; |
| 499 |
| 500 // move to next pixel |
| 501 byte++; |
| 502 } |
| 503 byte += stride - 16; |
| 504 } |
| 505 |
| 506 dst1 = cpi->alt_ref_buffer.u_buffer; |
| 507 dst2 = cpi->alt_ref_buffer.v_buffer; |
| 508 stride = cpi->alt_ref_buffer.uv_stride; |
| 509 byte = mb_uv_offset; |
| 510 for (i = 0, k = 256; i < mb_uv_height; i++) { |
| 511 for (j = 0; j < mb_uv_width; j++, k++) { |
| 512 int m = k + 256; |
| 513 |
| 514 // U |
| 515 unsigned int pval = accumulator[k] + (count[k] >> 1); |
| 516 pval *= fixed_divide[count[k]]; |
| 517 pval >>= 19; |
| 518 dst1[byte] = (uint8_t)pval; |
| 519 |
| 520 // V |
| 521 pval = accumulator[m] + (count[m] >> 1); |
| 522 pval *= fixed_divide[count[m]]; |
| 523 pval >>= 19; |
| 524 dst2[byte] = (uint8_t)pval; |
| 525 |
| 526 // move to next pixel |
| 527 byte++; |
| 528 } |
| 529 byte += stride - mb_uv_width; |
| 530 } |
| 531 } |
| 532 #else |
307 // Normalize filter output to produce AltRef frame | 533 // Normalize filter output to produce AltRef frame |
308 dst1 = cpi->alt_ref_buffer.y_buffer; | 534 dst1 = cpi->alt_ref_buffer.y_buffer; |
309 stride = cpi->alt_ref_buffer.y_stride; | 535 stride = cpi->alt_ref_buffer.y_stride; |
310 byte = mb_y_offset; | 536 byte = mb_y_offset; |
311 for (i = 0, k = 0; i < 16; i++) { | 537 for (i = 0, k = 0; i < 16; i++) { |
312 for (j = 0; j < 16; j++, k++) { | 538 for (j = 0; j < 16; j++, k++) { |
313 unsigned int pval = accumulator[k] + (count[k] >> 1); | 539 unsigned int pval = accumulator[k] + (count[k] >> 1); |
314 pval *= fixed_divide[count[k]]; | 540 pval *= fixed_divide[count[k]]; |
315 pval >>= 19; | 541 pval >>= 19; |
316 | 542 |
(...skipping 23 matching lines...) Expand all Loading... |
340 pval = accumulator[m] + (count[m] >> 1); | 566 pval = accumulator[m] + (count[m] >> 1); |
341 pval *= fixed_divide[count[m]]; | 567 pval *= fixed_divide[count[m]]; |
342 pval >>= 19; | 568 pval >>= 19; |
343 dst2[byte] = (uint8_t)pval; | 569 dst2[byte] = (uint8_t)pval; |
344 | 570 |
345 // move to next pixel | 571 // move to next pixel |
346 byte++; | 572 byte++; |
347 } | 573 } |
348 byte += stride - mb_uv_width; | 574 byte += stride - mb_uv_width; |
349 } | 575 } |
| 576 #endif // CONFIG_VP9_HIGHBITDEPTH |
350 mb_y_offset += 16; | 577 mb_y_offset += 16; |
351 mb_uv_offset += mb_uv_width; | 578 mb_uv_offset += mb_uv_width; |
352 } | 579 } |
353 mb_y_offset += 16 * (f->y_stride - mb_cols); | 580 mb_y_offset += 16 * (f->y_stride - mb_cols); |
354 mb_uv_offset += mb_uv_height * f->uv_stride - mb_uv_width * mb_cols; | 581 mb_uv_offset += mb_uv_height * f->uv_stride - mb_uv_width * mb_cols; |
355 } | 582 } |
356 | 583 |
357 // Restore input state | 584 // Restore input state |
358 for (i = 0; i < MAX_MB_PLANE; i++) | 585 for (i = 0; i < MAX_MB_PLANE; i++) |
359 mbd->plane[i].pre[0].buf = input_buffer[i]; | 586 mbd->plane[i].pre[0].buf = input_buffer[i]; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 start_frame = distance + frames_to_blur_forward; | 669 start_frame = distance + frames_to_blur_forward; |
443 | 670 |
444 // Setup frame pointers, NULL indicates frame not included in filter. | 671 // Setup frame pointers, NULL indicates frame not included in filter. |
445 for (frame = 0; frame < frames_to_blur; ++frame) { | 672 for (frame = 0; frame < frames_to_blur; ++frame) { |
446 const int which_buffer = start_frame - frame; | 673 const int which_buffer = start_frame - frame; |
447 struct lookahead_entry *buf = vp9_lookahead_peek(cpi->lookahead, | 674 struct lookahead_entry *buf = vp9_lookahead_peek(cpi->lookahead, |
448 which_buffer); | 675 which_buffer); |
449 frames[frames_to_blur - 1 - frame] = &buf->img; | 676 frames[frames_to_blur - 1 - frame] = &buf->img; |
450 } | 677 } |
451 | 678 |
452 // Setup scaling factors. Scaling on each of the arnr frames is not supported | 679 if (frames_to_blur > 0) { |
453 if (is_two_pass_svc(cpi)) { | 680 // Setup scaling factors. Scaling on each of the arnr frames is not |
454 // In spatial svc the scaling factors might be less then 1/2. So we will use | 681 // supported. |
455 // non-normative scaling. | 682 if (is_two_pass_svc(cpi)) { |
456 int frame_used = 0; | 683 // In spatial svc the scaling factors might be less then 1/2. |
| 684 // So we will use non-normative scaling. |
| 685 int frame_used = 0; |
457 #if CONFIG_VP9_HIGHBITDEPTH | 686 #if CONFIG_VP9_HIGHBITDEPTH |
458 vp9_setup_scale_factors_for_frame(&sf, | 687 vp9_setup_scale_factors_for_frame( |
459 get_frame_new_buffer(cm)->y_crop_width, | 688 &sf, |
460 get_frame_new_buffer(cm)->y_crop_height, | 689 get_frame_new_buffer(cm)->y_crop_width, |
461 get_frame_new_buffer(cm)->y_crop_width, | 690 get_frame_new_buffer(cm)->y_crop_height, |
462 get_frame_new_buffer(cm)->y_crop_height, | 691 get_frame_new_buffer(cm)->y_crop_width, |
463 cm->use_highbitdepth); | 692 get_frame_new_buffer(cm)->y_crop_height, |
| 693 cm->use_highbitdepth); |
464 #else | 694 #else |
465 vp9_setup_scale_factors_for_frame(&sf, | 695 vp9_setup_scale_factors_for_frame( |
466 get_frame_new_buffer(cm)->y_crop_width, | 696 &sf, |
467 get_frame_new_buffer(cm)->y_crop_height, | 697 get_frame_new_buffer(cm)->y_crop_width, |
468 get_frame_new_buffer(cm)->y_crop_width, | 698 get_frame_new_buffer(cm)->y_crop_height, |
469 get_frame_new_buffer(cm)->y_crop_height); | 699 get_frame_new_buffer(cm)->y_crop_width, |
| 700 get_frame_new_buffer(cm)->y_crop_height); |
| 701 #endif // CONFIG_VP9_HIGHBITDEPTH |
| 702 |
| 703 for (frame = 0; frame < frames_to_blur; ++frame) { |
| 704 if (cm->mi_cols * MI_SIZE != frames[frame]->y_width || |
| 705 cm->mi_rows * MI_SIZE != frames[frame]->y_height) { |
| 706 if (vp9_realloc_frame_buffer(&cpi->svc.scaled_frames[frame_used], |
| 707 cm->width, cm->height, |
| 708 cm->subsampling_x, cm->subsampling_y, |
| 709 #if CONFIG_VP9_HIGHBITDEPTH |
| 710 cm->use_highbitdepth, |
470 #endif | 711 #endif |
471 for (frame = 0; frame < frames_to_blur; ++frame) { | 712 VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, |
472 if (cm->mi_cols * MI_SIZE != frames[frame]->y_width || | 713 NULL)) { |
473 cm->mi_rows * MI_SIZE != frames[frame]->y_height) { | 714 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, |
474 if (vp9_realloc_frame_buffer(&cpi->svc.scaled_frames[frame_used], | 715 "Failed to reallocate alt_ref_buffer"); |
475 cm->width, cm->height, | 716 } |
476 cm->subsampling_x, cm->subsampling_y, | 717 frames[frame] = vp9_scale_if_required( |
| 718 cm, frames[frame], &cpi->svc.scaled_frames[frame_used]); |
| 719 ++frame_used; |
| 720 } |
| 721 } |
| 722 cm->mi = cm->mip + cm->mi_stride + 1; |
| 723 cpi->mb.e_mbd.mi = cm->mi; |
| 724 cpi->mb.e_mbd.mi[0].src_mi = &cpi->mb.e_mbd.mi[0]; |
| 725 } else { |
| 726 // ARF is produced at the native frame size and resized when coded. |
477 #if CONFIG_VP9_HIGHBITDEPTH | 727 #if CONFIG_VP9_HIGHBITDEPTH |
478 cm->use_highbitdepth, | 728 vp9_setup_scale_factors_for_frame(&sf, |
479 #endif | 729 frames[0]->y_crop_width, |
480 VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, | 730 frames[0]->y_crop_height, |
481 NULL)) | 731 frames[0]->y_crop_width, |
482 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, | 732 frames[0]->y_crop_height, |
483 "Failed to reallocate alt_ref_buffer"); | 733 cm->use_highbitdepth); |
484 | 734 #else |
485 frames[frame] = vp9_scale_if_required(cm, frames[frame], | 735 vp9_setup_scale_factors_for_frame(&sf, |
486 &cpi->svc.scaled_frames[frame_used]); | 736 frames[0]->y_crop_width, |
487 ++frame_used; | 737 frames[0]->y_crop_height, |
488 } | 738 frames[0]->y_crop_width, |
| 739 frames[0]->y_crop_height); |
| 740 #endif // CONFIG_VP9_HIGHBITDEPTH |
489 } | 741 } |
490 } else { | |
491 // ARF is produced at the native frame size and resized when coded. | |
492 #if CONFIG_VP9_HIGHBITDEPTH | |
493 vp9_setup_scale_factors_for_frame(&sf, | |
494 frames[0]->y_crop_width, | |
495 frames[0]->y_crop_height, | |
496 frames[0]->y_crop_width, | |
497 frames[0]->y_crop_height, | |
498 cm->use_highbitdepth); | |
499 #else | |
500 vp9_setup_scale_factors_for_frame(&sf, | |
501 frames[0]->y_crop_width, | |
502 frames[0]->y_crop_height, | |
503 frames[0]->y_crop_width, | |
504 frames[0]->y_crop_height); | |
505 #endif | |
506 } | 742 } |
507 | 743 |
508 temporal_filter_iterate_c(cpi, frames, frames_to_blur, | 744 temporal_filter_iterate_c(cpi, frames, frames_to_blur, |
509 frames_to_blur_backward, strength, &sf); | 745 frames_to_blur_backward, strength, &sf); |
510 } | 746 } |
OLD | NEW |