| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 cost += vp8_cost_bit(p [MVPbits + i], (x >> i) & 1); | 127 cost += vp8_cost_bit(p [MVPbits + i], (x >> i) & 1); |
| 128 | 128 |
| 129 while (--i > 3); | 129 while (--i > 3); |
| 130 | 130 |
| 131 if (x & 0xFFF0) | 131 if (x & 0xFFF0) |
| 132 cost += vp8_cost_bit(p [MVPbits + 3], (x >> 3) & 1); | 132 cost += vp8_cost_bit(p [MVPbits + 3], (x >> 3) & 1); |
| 133 } | 133 } |
| 134 | 134 |
| 135 return cost; // + vp8_cost_bit( p [MVPsign], v < 0); | 135 return cost; // + vp8_cost_bit( p [MVPsign], v < 0); |
| 136 } | 136 } |
| 137 //#define M_LOG2_E 0.693147180559945309417 | |
| 138 //#define log2f(x) (log (x) / (float) M_LOG2_E) | |
| 139 | 137 |
| 140 void vp8_build_component_cost_table(int *mvcost[2], int *mvsadcost[2], const MV_
CONTEXT *mvc, int mvc_flag[2]) | 138 void vp8_build_component_cost_table(int *mvcost[2], const MV_CONTEXT *mvc, int m
vc_flag[2]) |
| 141 { | 139 { |
| 142 int i = 1; //-mv_max; | 140 int i = 1; //-mv_max; |
| 143 unsigned int cost0 = 0; | 141 unsigned int cost0 = 0; |
| 144 unsigned int cost1 = 0; | 142 unsigned int cost1 = 0; |
| 145 | 143 |
| 146 vp8_clear_system_state(); | 144 vp8_clear_system_state(); |
| 147 #if 0 | |
| 148 mvsadcost [0] [0] = 300; | |
| 149 mvsadcost [1] [0] = 300; | |
| 150 | |
| 151 do | |
| 152 { | |
| 153 double z = 256 * (2 * (log2f(2 * i) + .6)); | |
| 154 mvsadcost [0][i] = (int) z; | |
| 155 mvsadcost [1][i] = (int) z; | |
| 156 mvsadcost [0][-i] = (int) z; | |
| 157 mvsadcost [1][-i] = (int) z; | |
| 158 } | |
| 159 while (++i <= mv_max); | |
| 160 | |
| 161 #endif | |
| 162 | 145 |
| 163 i = 1; | 146 i = 1; |
| 164 | 147 |
| 165 if (mvc_flag[0]) | 148 if (mvc_flag[0]) |
| 166 { | 149 { |
| 167 mvcost [0] [0] = cost_mvcomponent(0, &mvc[0]); | 150 mvcost [0] [0] = cost_mvcomponent(0, &mvc[0]); |
| 168 | 151 |
| 169 do | 152 do |
| 170 { | 153 { |
| 171 //mvcost [0] [i] = cost_mvcomponent( i, &mvc[0]); | 154 //mvcost [0] [i] = cost_mvcomponent( i, &mvc[0]); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 186 do | 169 do |
| 187 { | 170 { |
| 188 //mvcost [1] [i] = cost_mvcomponent( i, mvc[1]); | 171 //mvcost [1] [i] = cost_mvcomponent( i, mvc[1]); |
| 189 cost1 = cost_mvcomponent(i, &mvc[1]); | 172 cost1 = cost_mvcomponent(i, &mvc[1]); |
| 190 | 173 |
| 191 mvcost [1] [i] = cost1 + vp8_cost_zero(mvc[1].prob[MVPsign]); | 174 mvcost [1] [i] = cost1 + vp8_cost_zero(mvc[1].prob[MVPsign]); |
| 192 mvcost [1] [-i] = cost1 + vp8_cost_one(mvc[1].prob[MVPsign]); | 175 mvcost [1] [-i] = cost1 + vp8_cost_one(mvc[1].prob[MVPsign]); |
| 193 } | 176 } |
| 194 while (++i <= mv_max); | 177 while (++i <= mv_max); |
| 195 } | 178 } |
| 196 | |
| 197 /* | |
| 198 i=-mv_max; | |
| 199 do | |
| 200 { | |
| 201 mvcost [0] [i] = cost_mvcomponent( i, mvc[0]); | |
| 202 mvcost [1] [i] = cost_mvcomponent( i, mvc[1]); | |
| 203 } | |
| 204 while( ++i <= mv_max); | |
| 205 */ | |
| 206 } | 179 } |
| 207 | 180 |
| 208 | 181 |
| 209 // Motion vector probability table update depends on benefit. | 182 // Motion vector probability table update depends on benefit. |
| 210 // Small correction allows for the fact that an update to an MV probability | 183 // Small correction allows for the fact that an update to an MV probability |
| 211 // may have benefit in subsequent frames as well as the current one. | 184 // may have benefit in subsequent frames as well as the current one. |
| 212 | 185 |
| 213 #define MV_PROB_UPDATE_CORRECTION -1 | 186 #define MV_PROB_UPDATE_CORRECTION -1 |
| 214 | 187 |
| 215 | 188 |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 active_section = 4; | 402 active_section = 4; |
| 430 #endif | 403 #endif |
| 431 write_component_probs( | 404 write_component_probs( |
| 432 w, &mvc[0], &vp8_default_mv_context[0], &vp8_mv_update_probs[0], cpi->MV
count[0], 0, &flags[0] | 405 w, &mvc[0], &vp8_default_mv_context[0], &vp8_mv_update_probs[0], cpi->MV
count[0], 0, &flags[0] |
| 433 ); | 406 ); |
| 434 write_component_probs( | 407 write_component_probs( |
| 435 w, &mvc[1], &vp8_default_mv_context[1], &vp8_mv_update_probs[1], cpi->MV
count[1], 1, &flags[1] | 408 w, &mvc[1], &vp8_default_mv_context[1], &vp8_mv_update_probs[1], cpi->MV
count[1], 1, &flags[1] |
| 436 ); | 409 ); |
| 437 | 410 |
| 438 if (flags[0] || flags[1]) | 411 if (flags[0] || flags[1]) |
| 439 vp8_build_component_cost_table(cpi->mb.mvcost, cpi->mb.mvsadcost, (const
MV_CONTEXT *) cpi->common.fc.mvc, flags); | 412 vp8_build_component_cost_table(cpi->mb.mvcost, (const MV_CONTEXT *) cpi-
>common.fc.mvc, flags); |
| 440 | 413 |
| 441 #ifdef ENTROPY_STATS | 414 #ifdef ENTROPY_STATS |
| 442 active_section = 5; | 415 active_section = 5; |
| 443 #endif | 416 #endif |
| 444 } | 417 } |
| OLD | NEW |