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 |
11 | 11 |
12 #include <limits.h> | 12 #include <limits.h> |
13 #include "vpx_config.h" | 13 #include "vpx_config.h" |
| 14 #include "./vpx_dsp_rtcd.h" |
14 #include "onyx_int.h" | 15 #include "onyx_int.h" |
15 #include "modecosts.h" | 16 #include "modecosts.h" |
16 #include "encodeintra.h" | 17 #include "encodeintra.h" |
17 #include "vp8/common/common.h" | 18 #include "vp8/common/common.h" |
18 #include "vp8/common/entropymode.h" | 19 #include "vp8/common/entropymode.h" |
19 #include "pickinter.h" | 20 #include "pickinter.h" |
20 #include "vp8/common/findnearmv.h" | 21 #include "vp8/common/findnearmv.h" |
21 #include "encodemb.h" | 22 #include "encodemb.h" |
22 #include "vp8/common/reconinter.h" | 23 #include "vp8/common/reconinter.h" |
23 #include "vp8/common/reconintra4x4.h" | 24 #include "vp8/common/reconintra4x4.h" |
24 #include "vp8/common/variance.h" | 25 #include "vp8/common/variance.h" |
25 #include "mcomp.h" | 26 #include "mcomp.h" |
26 #include "rdopt.h" | 27 #include "rdopt.h" |
27 #include "vpx_mem/vpx_mem.h" | 28 #include "vpx_mem/vpx_mem.h" |
28 #if CONFIG_TEMPORAL_DENOISING | 29 #if CONFIG_TEMPORAL_DENOISING |
29 #include "denoising.h" | 30 #include "denoising.h" |
30 #endif | 31 #endif |
31 | 32 |
32 extern int VP8_UVSSE(MACROBLOCK *x); | |
33 | |
34 #ifdef SPEEDSTATS | 33 #ifdef SPEEDSTATS |
35 extern unsigned int cnt_pm; | 34 extern unsigned int cnt_pm; |
36 #endif | 35 #endif |
37 | 36 |
38 extern const int vp8_ref_frame_order[MAX_MODES]; | 37 extern const int vp8_ref_frame_order[MAX_MODES]; |
39 extern const MB_PREDICTION_MODE vp8_mode_order[MAX_MODES]; | 38 extern const MB_PREDICTION_MODE vp8_mode_order[MAX_MODES]; |
40 | 39 |
41 extern int vp8_cost_mv_ref(MB_PREDICTION_MODE m, const int near_mv_ref_ct[4]); | |
42 | |
43 // Fixed point implementation of a skin color classifier. Skin color | 40 // Fixed point implementation of a skin color classifier. Skin color |
44 // is model by a Gaussian distribution in the CbCr color space. | 41 // is model by a Gaussian distribution in the CbCr color space. |
45 // See ../../test/skin_color_detector_test.cc where the reference | 42 // See ../../test/skin_color_detector_test.cc where the reference |
46 // skin color classifier is defined. | 43 // skin color classifier is defined. |
47 | 44 |
48 // Fixed-point skin color model parameters. | 45 // Fixed-point skin color model parameters. |
49 static const int skin_mean[2] = {7463, 9614}; // q6 | 46 static const int skin_mean[2] = {7463, 9614}; // q6 |
50 static const int skin_inv_cov[4] = {4107, 1663, 1663, 2157}; // q16 | 47 static const int skin_inv_cov[4] = {4107, 1663, 1663, 2157}; // q16 |
51 static const int skin_threshold = 1570636; // q18 | 48 static const int skin_threshold = 1570636; // q18 |
52 | 49 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 { | 209 { |
213 return vfp->svf(in_what, in_what_stride, xoffset, yoffset, what, what_st
ride, sse); | 210 return vfp->svf(in_what, in_what_stride, xoffset, yoffset, what, what_st
ride, sse); |
214 } | 211 } |
215 else | 212 else |
216 { | 213 { |
217 return vfp->vf(what, what_stride, in_what, in_what_stride, sse); | 214 return vfp->vf(what, what_stride, in_what, in_what_stride, sse); |
218 } | 215 } |
219 | 216 |
220 } | 217 } |
221 | 218 |
222 | |
223 unsigned int vp8_get4x4sse_cs_c | |
224 ( | |
225 const unsigned char *src_ptr, | |
226 int source_stride, | |
227 const unsigned char *ref_ptr, | |
228 int recon_stride | |
229 ) | |
230 { | |
231 int distortion = 0; | |
232 int r, c; | |
233 | |
234 for (r = 0; r < 4; r++) | |
235 { | |
236 for (c = 0; c < 4; c++) | |
237 { | |
238 int diff = src_ptr[c] - ref_ptr[c]; | |
239 distortion += diff * diff; | |
240 } | |
241 | |
242 src_ptr += source_stride; | |
243 ref_ptr += recon_stride; | |
244 } | |
245 | |
246 return distortion; | |
247 } | |
248 | |
249 static int get_prediction_error(BLOCK *be, BLOCKD *b) | 219 static int get_prediction_error(BLOCK *be, BLOCKD *b) |
250 { | 220 { |
251 unsigned char *sptr; | 221 unsigned char *sptr; |
252 unsigned char *dptr; | 222 unsigned char *dptr; |
253 sptr = (*(be->base_src) + be->src); | 223 sptr = (*(be->base_src) + be->src); |
254 dptr = b->predictor; | 224 dptr = b->predictor; |
255 | 225 |
256 return vp8_get4x4sse_cs(sptr, be->src_stride, dptr, 16); | 226 return vpx_get4x4sse_cs(sptr, be->src_stride, dptr, 16); |
257 | 227 |
258 } | 228 } |
259 | 229 |
260 static int pick_intra4x4block( | 230 static int pick_intra4x4block( |
261 MACROBLOCK *x, | 231 MACROBLOCK *x, |
262 int ib, | 232 int ib, |
263 B_PREDICTION_MODE *best_mode, | 233 B_PREDICTION_MODE *best_mode, |
264 const int *mode_costs, | 234 const int *mode_costs, |
265 | 235 |
266 int *bestrate, | 236 int *bestrate, |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 distortion2 = best_rd_sse; | 1004 distortion2 = best_rd_sse; |
1035 pick_intra4x4mby_modes(x, &rate, &distortion2); | 1005 pick_intra4x4mby_modes(x, &rate, &distortion2); |
1036 | 1006 |
1037 if (distortion2 == INT_MAX) | 1007 if (distortion2 == INT_MAX) |
1038 { | 1008 { |
1039 this_rd = INT_MAX; | 1009 this_rd = INT_MAX; |
1040 } | 1010 } |
1041 else | 1011 else |
1042 { | 1012 { |
1043 rate2 += rate; | 1013 rate2 += rate; |
1044 distortion2 = vp8_variance16x16( | 1014 distortion2 = vpx_variance16x16( |
1045 *(b->base_src), b->src_stride, | 1015 *(b->base_src), b->src_stride, |
1046 x->e_mbd.predictor, 16, &sse); | 1016 x->e_mbd.predictor, 16, &sse); |
1047 this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2); | 1017 this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2); |
1048 | 1018 |
1049 if (this_rd < best_intra_rd) | 1019 if (this_rd < best_intra_rd) |
1050 { | 1020 { |
1051 best_intra_rd = this_rd; | 1021 best_intra_rd = this_rd; |
1052 *returnintra = distortion2; | 1022 *returnintra = distortion2; |
1053 } | 1023 } |
1054 } | 1024 } |
1055 | 1025 |
1056 break; | 1026 break; |
1057 | 1027 |
1058 case SPLITMV: | 1028 case SPLITMV: |
1059 | 1029 |
1060 /* Split MV modes currently not supported when RD is not enabled. */ | 1030 /* Split MV modes currently not supported when RD is not enabled. */ |
1061 break; | 1031 break; |
1062 | 1032 |
1063 case DC_PRED: | 1033 case DC_PRED: |
1064 case V_PRED: | 1034 case V_PRED: |
1065 case H_PRED: | 1035 case H_PRED: |
1066 case TM_PRED: | 1036 case TM_PRED: |
1067 vp8_build_intra_predictors_mby_s(xd, | 1037 vp8_build_intra_predictors_mby_s(xd, |
1068 xd->dst.y_buffer - xd->dst.y_stride
, | 1038 xd->dst.y_buffer - xd->dst.y_stride
, |
1069 xd->dst.y_buffer - 1, | 1039 xd->dst.y_buffer - 1, |
1070 xd->dst.y_stride, | 1040 xd->dst.y_stride, |
1071 xd->predictor, | 1041 xd->predictor, |
1072 16); | 1042 16); |
1073 distortion2 = vp8_variance16x16 | 1043 distortion2 = vpx_variance16x16 |
1074 (*(b->base_src), b->src_stride, | 1044 (*(b->base_src), b->src_stride, |
1075 x->e_mbd.predictor, 16, &sse); | 1045 x->e_mbd.predictor, 16, &sse); |
1076 rate2 += x->mbmode_cost[x->e_mbd.frame_type][x->e_mbd.mode_info_cont
ext->mbmi.mode]; | 1046 rate2 += x->mbmode_cost[x->e_mbd.frame_type][x->e_mbd.mode_info_cont
ext->mbmi.mode]; |
1077 this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2); | 1047 this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2); |
1078 | 1048 |
1079 if (this_rd < best_intra_rd) | 1049 if (this_rd < best_intra_rd) |
1080 { | 1050 { |
1081 best_intra_rd = this_rd; | 1051 best_intra_rd = this_rd; |
1082 *returnintra = distortion2; | 1052 *returnintra = distortion2; |
1083 } | 1053 } |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1544 | 1514 |
1545 for (mode = DC_PRED; mode <= TM_PRED; mode ++) | 1515 for (mode = DC_PRED; mode <= TM_PRED; mode ++) |
1546 { | 1516 { |
1547 xd->mode_info_context->mbmi.mode = mode; | 1517 xd->mode_info_context->mbmi.mode = mode; |
1548 vp8_build_intra_predictors_mby_s(xd, | 1518 vp8_build_intra_predictors_mby_s(xd, |
1549 xd->dst.y_buffer - xd->dst.y_stride, | 1519 xd->dst.y_buffer - xd->dst.y_stride, |
1550 xd->dst.y_buffer - 1, | 1520 xd->dst.y_buffer - 1, |
1551 xd->dst.y_stride, | 1521 xd->dst.y_stride, |
1552 xd->predictor, | 1522 xd->predictor, |
1553 16); | 1523 16); |
1554 distortion = vp8_variance16x16 | 1524 distortion = vpx_variance16x16 |
1555 (*(b->base_src), b->src_stride, xd->predictor, 16, &sse); | 1525 (*(b->base_src), b->src_stride, xd->predictor, 16, &sse); |
1556 rate = x->mbmode_cost[xd->frame_type][mode]; | 1526 rate = x->mbmode_cost[xd->frame_type][mode]; |
1557 this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion); | 1527 this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion); |
1558 | 1528 |
1559 if (error16x16 > this_rd) | 1529 if (error16x16 > this_rd) |
1560 { | 1530 { |
1561 error16x16 = this_rd; | 1531 error16x16 = this_rd; |
1562 best_mode = mode; | 1532 best_mode = mode; |
1563 best_sse = sse; | 1533 best_sse = sse; |
1564 best_rate = rate; | 1534 best_rate = rate; |
1565 } | 1535 } |
1566 } | 1536 } |
1567 xd->mode_info_context->mbmi.mode = best_mode; | 1537 xd->mode_info_context->mbmi.mode = best_mode; |
1568 | 1538 |
1569 error4x4 = pick_intra4x4mby_modes(x, &rate, | 1539 error4x4 = pick_intra4x4mby_modes(x, &rate, |
1570 &best_sse); | 1540 &best_sse); |
1571 if (error4x4 < error16x16) | 1541 if (error4x4 < error16x16) |
1572 { | 1542 { |
1573 xd->mode_info_context->mbmi.mode = B_PRED; | 1543 xd->mode_info_context->mbmi.mode = B_PRED; |
1574 best_rate = rate; | 1544 best_rate = rate; |
1575 } | 1545 } |
1576 | 1546 |
1577 *rate_ = best_rate; | 1547 *rate_ = best_rate; |
1578 } | 1548 } |
OLD | NEW |