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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 *eob_ptr = eob + 1; | 115 *eob_ptr = eob + 1; |
116 } | 116 } |
117 #endif | 117 #endif |
118 | 118 |
119 void vp9_quantize_fp_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, | 119 void vp9_quantize_fp_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, |
120 int skip_block, | 120 int skip_block, |
121 const int16_t *zbin_ptr, const int16_t *round_ptr, | 121 const int16_t *zbin_ptr, const int16_t *round_ptr, |
122 const int16_t *quant_ptr, const int16_t *quant_shift_ptr, | 122 const int16_t *quant_ptr, const int16_t *quant_shift_ptr, |
123 tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, | 123 tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, |
124 const int16_t *dequant_ptr, | 124 const int16_t *dequant_ptr, |
125 int zbin_oq_value, uint16_t *eob_ptr, | 125 uint16_t *eob_ptr, |
126 const int16_t *scan, const int16_t *iscan) { | 126 const int16_t *scan, const int16_t *iscan) { |
127 int i, eob = -1; | 127 int i, eob = -1; |
128 // TODO(jingning) Decide the need of these arguments after the | 128 // TODO(jingning) Decide the need of these arguments after the |
129 // quantization process is completed. | 129 // quantization process is completed. |
130 (void)zbin_ptr; | 130 (void)zbin_ptr; |
131 (void)quant_shift_ptr; | 131 (void)quant_shift_ptr; |
132 (void)zbin_oq_value; | |
133 (void)iscan; | 132 (void)iscan; |
134 | 133 |
135 vpx_memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); | 134 vpx_memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); |
136 vpx_memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); | 135 vpx_memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); |
137 | 136 |
138 if (!skip_block) { | 137 if (!skip_block) { |
139 // Quantization pass: All coefficients with index >= zero_flag are | 138 // Quantization pass: All coefficients with index >= zero_flag are |
140 // skippable. Note: zero_flag can be zero. | 139 // skippable. Note: zero_flag can be zero. |
141 for (i = 0; i < n_coeffs; i++) { | 140 for (i = 0; i < n_coeffs; i++) { |
142 const int rc = scan[i]; | 141 const int rc = scan[i]; |
(...skipping 18 matching lines...) Expand all Loading... |
161 void vp9_highbd_quantize_fp_c(const tran_low_t *coeff_ptr, | 160 void vp9_highbd_quantize_fp_c(const tran_low_t *coeff_ptr, |
162 intptr_t count, | 161 intptr_t count, |
163 int skip_block, | 162 int skip_block, |
164 const int16_t *zbin_ptr, | 163 const int16_t *zbin_ptr, |
165 const int16_t *round_ptr, | 164 const int16_t *round_ptr, |
166 const int16_t *quant_ptr, | 165 const int16_t *quant_ptr, |
167 const int16_t *quant_shift_ptr, | 166 const int16_t *quant_shift_ptr, |
168 tran_low_t *qcoeff_ptr, | 167 tran_low_t *qcoeff_ptr, |
169 tran_low_t *dqcoeff_ptr, | 168 tran_low_t *dqcoeff_ptr, |
170 const int16_t *dequant_ptr, | 169 const int16_t *dequant_ptr, |
171 int zbin_oq_value, | |
172 uint16_t *eob_ptr, | 170 uint16_t *eob_ptr, |
173 const int16_t *scan, | 171 const int16_t *scan, |
174 const int16_t *iscan) { | 172 const int16_t *iscan) { |
175 int i; | 173 int i; |
176 int eob = -1; | 174 int eob = -1; |
177 // TODO(jingning) Decide the need of these arguments after the | 175 // TODO(jingning) Decide the need of these arguments after the |
178 // quantization process is completed. | 176 // quantization process is completed. |
179 (void)zbin_ptr; | 177 (void)zbin_ptr; |
180 (void)quant_shift_ptr; | 178 (void)quant_shift_ptr; |
181 (void)zbin_oq_value; | |
182 (void)iscan; | 179 (void)iscan; |
183 | 180 |
184 vpx_memset(qcoeff_ptr, 0, count * sizeof(*qcoeff_ptr)); | 181 vpx_memset(qcoeff_ptr, 0, count * sizeof(*qcoeff_ptr)); |
185 vpx_memset(dqcoeff_ptr, 0, count * sizeof(*dqcoeff_ptr)); | 182 vpx_memset(dqcoeff_ptr, 0, count * sizeof(*dqcoeff_ptr)); |
186 | 183 |
187 if (!skip_block) { | 184 if (!skip_block) { |
188 // Quantization pass: All coefficients with index >= zero_flag are | 185 // Quantization pass: All coefficients with index >= zero_flag are |
189 // skippable. Note: zero_flag can be zero. | 186 // skippable. Note: zero_flag can be zero. |
190 for (i = 0; i < count; i++) { | 187 for (i = 0; i < count; i++) { |
191 const int rc = scan[i]; | 188 const int rc = scan[i]; |
(...skipping 18 matching lines...) Expand all Loading... |
210 | 207 |
211 // TODO(jingning) Refactor this file and combine functions with similar | 208 // TODO(jingning) Refactor this file and combine functions with similar |
212 // operations. | 209 // operations. |
213 void vp9_quantize_fp_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, | 210 void vp9_quantize_fp_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, |
214 int skip_block, | 211 int skip_block, |
215 const int16_t *zbin_ptr, const int16_t *round_ptr, | 212 const int16_t *zbin_ptr, const int16_t *round_ptr, |
216 const int16_t *quant_ptr, | 213 const int16_t *quant_ptr, |
217 const int16_t *quant_shift_ptr, | 214 const int16_t *quant_shift_ptr, |
218 tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, | 215 tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, |
219 const int16_t *dequant_ptr, | 216 const int16_t *dequant_ptr, |
220 int zbin_oq_value, uint16_t *eob_ptr, | 217 uint16_t *eob_ptr, |
221 const int16_t *scan, const int16_t *iscan) { | 218 const int16_t *scan, const int16_t *iscan) { |
222 int i, eob = -1; | 219 int i, eob = -1; |
223 (void)zbin_ptr; | 220 (void)zbin_ptr; |
224 (void)quant_shift_ptr; | 221 (void)quant_shift_ptr; |
225 (void)zbin_oq_value; | |
226 (void)iscan; | 222 (void)iscan; |
227 | 223 |
228 vpx_memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); | 224 vpx_memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); |
229 vpx_memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); | 225 vpx_memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); |
230 | 226 |
231 if (!skip_block) { | 227 if (!skip_block) { |
232 for (i = 0; i < n_coeffs; i++) { | 228 for (i = 0; i < n_coeffs; i++) { |
233 const int rc = scan[i]; | 229 const int rc = scan[i]; |
234 const int coeff = coeff_ptr[rc]; | 230 const int coeff = coeff_ptr[rc]; |
235 const int coeff_sign = (coeff >> 31); | 231 const int coeff_sign = (coeff >> 31); |
(...skipping 18 matching lines...) Expand all Loading... |
254 #if CONFIG_VP9_HIGHBITDEPTH | 250 #if CONFIG_VP9_HIGHBITDEPTH |
255 void vp9_highbd_quantize_fp_32x32_c(const tran_low_t *coeff_ptr, | 251 void vp9_highbd_quantize_fp_32x32_c(const tran_low_t *coeff_ptr, |
256 intptr_t n_coeffs, int skip_block, | 252 intptr_t n_coeffs, int skip_block, |
257 const int16_t *zbin_ptr, | 253 const int16_t *zbin_ptr, |
258 const int16_t *round_ptr, | 254 const int16_t *round_ptr, |
259 const int16_t *quant_ptr, | 255 const int16_t *quant_ptr, |
260 const int16_t *quant_shift_ptr, | 256 const int16_t *quant_shift_ptr, |
261 tran_low_t *qcoeff_ptr, | 257 tran_low_t *qcoeff_ptr, |
262 tran_low_t *dqcoeff_ptr, | 258 tran_low_t *dqcoeff_ptr, |
263 const int16_t *dequant_ptr, | 259 const int16_t *dequant_ptr, |
264 int zbin_oq_value, uint16_t *eob_ptr, | 260 uint16_t *eob_ptr, |
265 const int16_t *scan, const int16_t *iscan) { | 261 const int16_t *scan, const int16_t *iscan) { |
266 int i, eob = -1; | 262 int i, eob = -1; |
267 (void)zbin_ptr; | 263 (void)zbin_ptr; |
268 (void)quant_shift_ptr; | 264 (void)quant_shift_ptr; |
269 (void)zbin_oq_value; | |
270 (void)iscan; | 265 (void)iscan; |
271 | 266 |
272 vpx_memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); | 267 vpx_memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); |
273 vpx_memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); | 268 vpx_memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); |
274 | 269 |
275 if (!skip_block) { | 270 if (!skip_block) { |
276 for (i = 0; i < n_coeffs; i++) { | 271 for (i = 0; i < n_coeffs; i++) { |
277 const int rc = scan[i]; | 272 const int rc = scan[i]; |
278 const int coeff = coeff_ptr[rc]; | 273 const int coeff = coeff_ptr[rc]; |
279 const int coeff_sign = (coeff >> 31); | 274 const int coeff_sign = (coeff >> 31); |
(...skipping 15 matching lines...) Expand all Loading... |
295 *eob_ptr = eob + 1; | 290 *eob_ptr = eob + 1; |
296 } | 291 } |
297 #endif | 292 #endif |
298 | 293 |
299 void vp9_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, | 294 void vp9_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, |
300 int skip_block, | 295 int skip_block, |
301 const int16_t *zbin_ptr, const int16_t *round_ptr, | 296 const int16_t *zbin_ptr, const int16_t *round_ptr, |
302 const int16_t *quant_ptr, const int16_t *quant_shift_ptr, | 297 const int16_t *quant_ptr, const int16_t *quant_shift_ptr, |
303 tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, | 298 tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, |
304 const int16_t *dequant_ptr, | 299 const int16_t *dequant_ptr, |
305 int zbin_oq_value, uint16_t *eob_ptr, | 300 uint16_t *eob_ptr, |
306 const int16_t *scan, const int16_t *iscan) { | 301 const int16_t *scan, const int16_t *iscan) { |
307 int i, non_zero_count = (int)n_coeffs, eob = -1; | 302 int i, non_zero_count = (int)n_coeffs, eob = -1; |
308 const int zbins[2] = { zbin_ptr[0] + zbin_oq_value, | 303 const int zbins[2] = {zbin_ptr[0], zbin_ptr[1]}; |
309 zbin_ptr[1] + zbin_oq_value }; | 304 const int nzbins[2] = {zbins[0] * -1, zbins[1] * -1}; |
310 const int nzbins[2] = { zbins[0] * -1, | |
311 zbins[1] * -1 }; | |
312 (void)iscan; | 305 (void)iscan; |
313 | 306 |
314 vpx_memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); | 307 vpx_memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); |
315 vpx_memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); | 308 vpx_memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); |
316 | 309 |
317 if (!skip_block) { | 310 if (!skip_block) { |
318 // Pre-scan pass | 311 // Pre-scan pass |
319 for (i = (int)n_coeffs - 1; i >= 0; i--) { | 312 for (i = (int)n_coeffs - 1; i >= 0; i--) { |
320 const int rc = scan[i]; | 313 const int rc = scan[i]; |
321 const int coeff = coeff_ptr[rc]; | 314 const int coeff = coeff_ptr[rc]; |
(...skipping 26 matching lines...) Expand all Loading... |
348 } | 341 } |
349 *eob_ptr = eob + 1; | 342 *eob_ptr = eob + 1; |
350 } | 343 } |
351 | 344 |
352 #if CONFIG_VP9_HIGHBITDEPTH | 345 #if CONFIG_VP9_HIGHBITDEPTH |
353 void vp9_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, | 346 void vp9_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, |
354 int skip_block, const int16_t *zbin_ptr, | 347 int skip_block, const int16_t *zbin_ptr, |
355 const int16_t *round_ptr, const int16_t *quant_ptr, | 348 const int16_t *round_ptr, const int16_t *quant_ptr, |
356 const int16_t *quant_shift_ptr, | 349 const int16_t *quant_shift_ptr, |
357 tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, | 350 tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, |
358 const int16_t *dequant_ptr, int zbin_oq_value, | 351 const int16_t *dequant_ptr, |
359 uint16_t *eob_ptr, const int16_t *scan, | 352 uint16_t *eob_ptr, const int16_t *scan, |
360 const int16_t *iscan) { | 353 const int16_t *iscan) { |
361 int i, non_zero_count = (int)n_coeffs, eob = -1; | 354 int i, non_zero_count = (int)n_coeffs, eob = -1; |
362 const int zbins[2] = { zbin_ptr[0] + zbin_oq_value, | 355 const int zbins[2] = {zbin_ptr[0], zbin_ptr[1]}; |
363 zbin_ptr[1] + zbin_oq_value }; | 356 const int nzbins[2] = {zbins[0] * -1, zbins[1] * -1}; |
364 const int nzbins[2] = { zbins[0] * -1, | |
365 zbins[1] * -1 }; | |
366 (void)iscan; | 357 (void)iscan; |
367 | 358 |
368 vpx_memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); | 359 vpx_memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); |
369 vpx_memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); | 360 vpx_memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); |
370 | 361 |
371 if (!skip_block) { | 362 if (!skip_block) { |
372 // Pre-scan pass | 363 // Pre-scan pass |
373 for (i = (int)n_coeffs - 1; i >= 0; i--) { | 364 for (i = (int)n_coeffs - 1; i >= 0; i--) { |
374 const int rc = scan[i]; | 365 const int rc = scan[i]; |
375 const int coeff = coeff_ptr[rc]; | 366 const int coeff = coeff_ptr[rc]; |
(...skipping 29 matching lines...) Expand all Loading... |
405 } | 396 } |
406 #endif | 397 #endif |
407 | 398 |
408 void vp9_quantize_b_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, | 399 void vp9_quantize_b_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, |
409 int skip_block, | 400 int skip_block, |
410 const int16_t *zbin_ptr, const int16_t *round_ptr, | 401 const int16_t *zbin_ptr, const int16_t *round_ptr, |
411 const int16_t *quant_ptr, | 402 const int16_t *quant_ptr, |
412 const int16_t *quant_shift_ptr, | 403 const int16_t *quant_shift_ptr, |
413 tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, | 404 tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, |
414 const int16_t *dequant_ptr, | 405 const int16_t *dequant_ptr, |
415 int zbin_oq_value, uint16_t *eob_ptr, | 406 uint16_t *eob_ptr, |
416 const int16_t *scan, const int16_t *iscan) { | 407 const int16_t *scan, const int16_t *iscan) { |
417 const int zbins[2] = { ROUND_POWER_OF_TWO(zbin_ptr[0] + zbin_oq_value, 1), | 408 const int zbins[2] = {ROUND_POWER_OF_TWO(zbin_ptr[0], 1), |
418 ROUND_POWER_OF_TWO(zbin_ptr[1] + zbin_oq_value, 1) }; | 409 ROUND_POWER_OF_TWO(zbin_ptr[1], 1)}; |
419 const int nzbins[2] = {zbins[0] * -1, zbins[1] * -1}; | 410 const int nzbins[2] = {zbins[0] * -1, zbins[1] * -1}; |
420 | 411 |
421 int idx = 0; | 412 int idx = 0; |
422 int idx_arr[1024]; | 413 int idx_arr[1024]; |
423 int i, eob = -1; | 414 int i, eob = -1; |
424 (void)iscan; | 415 (void)iscan; |
425 | 416 |
426 vpx_memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); | 417 vpx_memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); |
427 vpx_memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); | 418 vpx_memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); |
428 | 419 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 #if CONFIG_VP9_HIGHBITDEPTH | 455 #if CONFIG_VP9_HIGHBITDEPTH |
465 void vp9_highbd_quantize_b_32x32_c(const tran_low_t *coeff_ptr, | 456 void vp9_highbd_quantize_b_32x32_c(const tran_low_t *coeff_ptr, |
466 intptr_t n_coeffs, int skip_block, | 457 intptr_t n_coeffs, int skip_block, |
467 const int16_t *zbin_ptr, | 458 const int16_t *zbin_ptr, |
468 const int16_t *round_ptr, | 459 const int16_t *round_ptr, |
469 const int16_t *quant_ptr, | 460 const int16_t *quant_ptr, |
470 const int16_t *quant_shift_ptr, | 461 const int16_t *quant_shift_ptr, |
471 tran_low_t *qcoeff_ptr, | 462 tran_low_t *qcoeff_ptr, |
472 tran_low_t *dqcoeff_ptr, | 463 tran_low_t *dqcoeff_ptr, |
473 const int16_t *dequant_ptr, | 464 const int16_t *dequant_ptr, |
474 int zbin_oq_value, uint16_t *eob_ptr, | 465 uint16_t *eob_ptr, |
475 const int16_t *scan, const int16_t *iscan) { | 466 const int16_t *scan, const int16_t *iscan) { |
476 const int zbins[2] = { ROUND_POWER_OF_TWO(zbin_ptr[0] + zbin_oq_value, 1), | 467 const int zbins[2] = {ROUND_POWER_OF_TWO(zbin_ptr[0], 1), |
477 ROUND_POWER_OF_TWO(zbin_ptr[1] + zbin_oq_value, 1) }; | 468 ROUND_POWER_OF_TWO(zbin_ptr[1], 1)}; |
478 const int nzbins[2] = { zbins[0] * -1, zbins[1] * -1 }; | 469 const int nzbins[2] = {zbins[0] * -1, zbins[1] * -1}; |
479 | 470 |
480 int idx = 0; | 471 int idx = 0; |
481 int idx_arr[1024]; | 472 int idx_arr[1024]; |
482 int i, eob = -1; | 473 int i, eob = -1; |
483 (void)iscan; | 474 (void)iscan; |
484 | 475 |
485 vpx_memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); | 476 vpx_memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr)); |
486 vpx_memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); | 477 vpx_memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr)); |
487 | 478 |
488 if (!skip_block) { | 479 if (!skip_block) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 struct macroblock_plane *p = &x->plane[plane]; | 518 struct macroblock_plane *p = &x->plane[plane]; |
528 struct macroblockd_plane *pd = &xd->plane[plane]; | 519 struct macroblockd_plane *pd = &xd->plane[plane]; |
529 | 520 |
530 #if CONFIG_VP9_HIGHBITDEPTH | 521 #if CONFIG_VP9_HIGHBITDEPTH |
531 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { | 522 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { |
532 vp9_highbd_quantize_b(BLOCK_OFFSET(p->coeff, block), | 523 vp9_highbd_quantize_b(BLOCK_OFFSET(p->coeff, block), |
533 16, x->skip_block, | 524 16, x->skip_block, |
534 p->zbin, p->round, p->quant, p->quant_shift, | 525 p->zbin, p->round, p->quant, p->quant_shift, |
535 BLOCK_OFFSET(p->qcoeff, block), | 526 BLOCK_OFFSET(p->qcoeff, block), |
536 BLOCK_OFFSET(pd->dqcoeff, block), | 527 BLOCK_OFFSET(pd->dqcoeff, block), |
537 pd->dequant, p->zbin_extra, &p->eobs[block], | 528 pd->dequant, &p->eobs[block], |
538 scan, iscan); | 529 scan, iscan); |
539 return; | 530 return; |
540 } | 531 } |
541 #endif | 532 #endif |
542 vp9_quantize_b(BLOCK_OFFSET(p->coeff, block), | 533 vp9_quantize_b(BLOCK_OFFSET(p->coeff, block), |
543 16, x->skip_block, | 534 16, x->skip_block, |
544 p->zbin, p->round, p->quant, p->quant_shift, | 535 p->zbin, p->round, p->quant, p->quant_shift, |
545 BLOCK_OFFSET(p->qcoeff, block), | 536 BLOCK_OFFSET(p->qcoeff, block), |
546 BLOCK_OFFSET(pd->dqcoeff, block), | 537 BLOCK_OFFSET(pd->dqcoeff, block), |
547 pd->dequant, p->zbin_extra, &p->eobs[block], scan, iscan); | 538 pd->dequant, &p->eobs[block], scan, iscan); |
548 } | 539 } |
549 | 540 |
550 static void invert_quant(int16_t *quant, int16_t *shift, int d) { | 541 static void invert_quant(int16_t *quant, int16_t *shift, int d) { |
551 unsigned t; | 542 unsigned t; |
552 int l; | 543 int l; |
553 t = d; | 544 t = d; |
554 for (l = 0; t > 1; l++) | 545 for (l = 0; t > 1; l++) |
555 t >>= 1; | 546 t >>= 1; |
556 t = 1 + (1 << (16 + l)) / d; | 547 t = 1 + (1 << (16 + l)) / d; |
557 *quant = (int16_t)(t - (1 << 16)); | 548 *quant = (int16_t)(t - (1 << 16)); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 } | 625 } |
635 } | 626 } |
636 | 627 |
637 void vp9_init_plane_quantizers(VP9_COMP *cpi, MACROBLOCK *x) { | 628 void vp9_init_plane_quantizers(VP9_COMP *cpi, MACROBLOCK *x) { |
638 const VP9_COMMON *const cm = &cpi->common; | 629 const VP9_COMMON *const cm = &cpi->common; |
639 MACROBLOCKD *const xd = &x->e_mbd; | 630 MACROBLOCKD *const xd = &x->e_mbd; |
640 QUANTS *const quants = &cpi->quants; | 631 QUANTS *const quants = &cpi->quants; |
641 const int segment_id = xd->mi[0].src_mi->mbmi.segment_id; | 632 const int segment_id = xd->mi[0].src_mi->mbmi.segment_id; |
642 const int qindex = vp9_get_qindex(&cm->seg, segment_id, cm->base_qindex); | 633 const int qindex = vp9_get_qindex(&cm->seg, segment_id, cm->base_qindex); |
643 const int rdmult = vp9_compute_rd_mult(cpi, qindex + cm->y_dc_delta_q); | 634 const int rdmult = vp9_compute_rd_mult(cpi, qindex + cm->y_dc_delta_q); |
644 const int zbin = cpi->zbin_mode_boost; | |
645 int i; | 635 int i; |
646 | 636 |
647 // Y | 637 // Y |
648 x->plane[0].quant = quants->y_quant[qindex]; | 638 x->plane[0].quant = quants->y_quant[qindex]; |
649 x->plane[0].quant_fp = quants->y_quant_fp[qindex]; | 639 x->plane[0].quant_fp = quants->y_quant_fp[qindex]; |
650 x->plane[0].round_fp = quants->y_round_fp[qindex]; | 640 x->plane[0].round_fp = quants->y_round_fp[qindex]; |
651 x->plane[0].quant_shift = quants->y_quant_shift[qindex]; | 641 x->plane[0].quant_shift = quants->y_quant_shift[qindex]; |
652 x->plane[0].zbin = quants->y_zbin[qindex]; | 642 x->plane[0].zbin = quants->y_zbin[qindex]; |
653 x->plane[0].round = quants->y_round[qindex]; | 643 x->plane[0].round = quants->y_round[qindex]; |
654 x->plane[0].zbin_extra = (int16_t)((cm->y_dequant[qindex][1] * zbin) >> 7); | |
655 xd->plane[0].dequant = cm->y_dequant[qindex]; | 644 xd->plane[0].dequant = cm->y_dequant[qindex]; |
656 | 645 |
657 x->plane[0].quant_thred[0] = (x->plane[0].zbin[0] + x->plane[0].zbin_extra) * | 646 x->plane[0].quant_thred[0] = x->plane[0].zbin[0] * x->plane[0].zbin[0]; |
658 (x->plane[0].zbin[0] + x->plane[0].zbin_extra); | 647 x->plane[0].quant_thred[1] = x->plane[0].zbin[1] * x->plane[0].zbin[1]; |
659 x->plane[0].quant_thred[1] = (x->plane[0].zbin[1] + x->plane[0].zbin_extra) * | |
660 (x->plane[0].zbin[1] + x->plane[0].zbin_extra); | |
661 | 648 |
662 // UV | 649 // UV |
663 for (i = 1; i < 3; i++) { | 650 for (i = 1; i < 3; i++) { |
664 x->plane[i].quant = quants->uv_quant[qindex]; | 651 x->plane[i].quant = quants->uv_quant[qindex]; |
665 x->plane[i].quant_fp = quants->uv_quant_fp[qindex]; | 652 x->plane[i].quant_fp = quants->uv_quant_fp[qindex]; |
666 x->plane[i].round_fp = quants->uv_round_fp[qindex]; | 653 x->plane[i].round_fp = quants->uv_round_fp[qindex]; |
667 x->plane[i].quant_shift = quants->uv_quant_shift[qindex]; | 654 x->plane[i].quant_shift = quants->uv_quant_shift[qindex]; |
668 x->plane[i].zbin = quants->uv_zbin[qindex]; | 655 x->plane[i].zbin = quants->uv_zbin[qindex]; |
669 x->plane[i].round = quants->uv_round[qindex]; | 656 x->plane[i].round = quants->uv_round[qindex]; |
670 x->plane[i].zbin_extra = (int16_t)((cm->uv_dequant[qindex][1] * zbin) >> 7); | |
671 xd->plane[i].dequant = cm->uv_dequant[qindex]; | 657 xd->plane[i].dequant = cm->uv_dequant[qindex]; |
672 | 658 |
673 x->plane[i].quant_thred[0] = | 659 x->plane[i].quant_thred[0] = x->plane[i].zbin[0] * x->plane[i].zbin[0]; |
674 (x->plane[i].zbin[0] + x->plane[i].zbin_extra) * | 660 x->plane[i].quant_thred[1] = x->plane[i].zbin[1] * x->plane[i].zbin[1]; |
675 (x->plane[i].zbin[0] + x->plane[i].zbin_extra); | |
676 x->plane[i].quant_thred[1] = | |
677 (x->plane[i].zbin[1] + x->plane[i].zbin_extra) * | |
678 (x->plane[i].zbin[1] + x->plane[i].zbin_extra); | |
679 } | 661 } |
680 | 662 |
681 x->skip_block = vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP); | 663 x->skip_block = vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP); |
682 x->q_index = qindex; | 664 x->q_index = qindex; |
683 | 665 |
684 x->errorperbit = rdmult >> 6; | 666 x->errorperbit = rdmult >> 6; |
685 x->errorperbit += (x->errorperbit == 0); | 667 x->errorperbit += (x->errorperbit == 0); |
686 | 668 |
687 vp9_initialize_me_consts(cpi, x->q_index); | 669 vp9_initialize_me_consts(cpi, x->q_index); |
688 } | 670 } |
689 | 671 |
690 void vp9_update_zbin_extra(VP9_COMP *cpi, MACROBLOCK *x) { | |
691 const int qindex = x->q_index; | |
692 const int y_zbin_extra = (cpi->common.y_dequant[qindex][1] * | |
693 cpi->zbin_mode_boost) >> 7; | |
694 const int uv_zbin_extra = (cpi->common.uv_dequant[qindex][1] * | |
695 cpi->zbin_mode_boost) >> 7; | |
696 | |
697 x->plane[0].zbin_extra = (int16_t)y_zbin_extra; | |
698 x->plane[1].zbin_extra = (int16_t)uv_zbin_extra; | |
699 x->plane[2].zbin_extra = (int16_t)uv_zbin_extra; | |
700 } | |
701 | |
702 void vp9_frame_init_quantizer(VP9_COMP *cpi) { | 672 void vp9_frame_init_quantizer(VP9_COMP *cpi) { |
703 cpi->zbin_mode_boost = 0; | |
704 vp9_init_plane_quantizers(cpi, &cpi->td.mb); | 673 vp9_init_plane_quantizers(cpi, &cpi->td.mb); |
705 } | 674 } |
706 | 675 |
707 void vp9_set_quantizer(VP9_COMMON *cm, int q) { | 676 void vp9_set_quantizer(VP9_COMMON *cm, int q) { |
708 // quantizer has to be reinitialized with vp9_init_quantizer() if any | 677 // quantizer has to be reinitialized with vp9_init_quantizer() if any |
709 // delta_q changes. | 678 // delta_q changes. |
710 cm->base_qindex = q; | 679 cm->base_qindex = q; |
711 cm->y_dc_delta_q = 0; | 680 cm->y_dc_delta_q = 0; |
712 cm->uv_dc_delta_q = 0; | 681 cm->uv_dc_delta_q = 0; |
713 cm->uv_ac_delta_q = 0; | 682 cm->uv_ac_delta_q = 0; |
(...skipping 18 matching lines...) Expand all Loading... |
732 | 701 |
733 int vp9_qindex_to_quantizer(int qindex) { | 702 int vp9_qindex_to_quantizer(int qindex) { |
734 int quantizer; | 703 int quantizer; |
735 | 704 |
736 for (quantizer = 0; quantizer < 64; ++quantizer) | 705 for (quantizer = 0; quantizer < 64; ++quantizer) |
737 if (quantizer_to_qindex[quantizer] >= qindex) | 706 if (quantizer_to_qindex[quantizer] >= qindex) |
738 return quantizer; | 707 return quantizer; |
739 | 708 |
740 return 63; | 709 return 63; |
741 } | 710 } |
OLD | NEW |