Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Side by Side Diff: source/libvpx/vp9/encoder/vp9_quantize.c

Issue 11974002: libvpx: Pull from upstream (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_quantize.h ('k') | source/libvpx/vp9/encoder/vp9_ratectrl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <math.h> 11 #include <math.h>
12 #include "vpx_mem/vpx_mem.h" 12 #include "vpx_mem/vpx_mem.h"
13 13
14 #include "vp9/encoder/vp9_onyx_int.h" 14 #include "vp9/encoder/vp9_onyx_int.h"
15 #include "vp9/encoder/vp9_quantize.h" 15 #include "vp9/encoder/vp9_quantize.h"
16 #include "vp9/common/vp9_quant_common.h" 16 #include "vp9/common/vp9_quant_common.h"
17 17
18 #include "vp9/common/vp9_seg_common.h" 18 #include "vp9/common/vp9_seg_common.h"
19 19
20 #ifdef ENC_DEBUG 20 #ifdef ENC_DEBUG
21 extern int enc_debug; 21 extern int enc_debug;
22 #endif 22 #endif
23 23
24 void vp9_ht_quantize_b_4x4(BLOCK *b, BLOCKD *d, TX_TYPE tx_type) { 24 void vp9_ht_quantize_b_4x4(BLOCK *b, BLOCKD *d, TX_TYPE tx_type) {
25 int i, rc, eob; 25 int i, rc, eob;
26 int zbin; 26 int zbin;
27 int x, y, z, sz; 27 int x, y, z, sz;
28 short *zbin_boost_ptr = b->zrun_zbin_boost; 28 int16_t *zbin_boost_ptr = b->zrun_zbin_boost;
29 short *coeff_ptr = b->coeff; 29 int16_t *coeff_ptr = b->coeff;
30 short *zbin_ptr = b->zbin; 30 int16_t *zbin_ptr = b->zbin;
31 short *round_ptr = b->round; 31 int16_t *round_ptr = b->round;
32 short *quant_ptr = b->quant; 32 int16_t *quant_ptr = b->quant;
33 unsigned char *quant_shift_ptr = b->quant_shift; 33 uint8_t *quant_shift_ptr = b->quant_shift;
34 short *qcoeff_ptr = d->qcoeff; 34 int16_t *qcoeff_ptr = d->qcoeff;
35 short *dqcoeff_ptr = d->dqcoeff; 35 int16_t *dqcoeff_ptr = d->dqcoeff;
36 short *dequant_ptr = d->dequant; 36 int16_t *dequant_ptr = d->dequant;
37 short zbin_oq_value = b->zbin_extra; 37 int zbin_oq_value = b->zbin_extra;
38 38
39 int const *pt_scan ; 39 int const *pt_scan ;
40 40
41 switch (tx_type) { 41 switch (tx_type) {
42 case ADST_DCT : 42 case ADST_DCT:
43 pt_scan = vp9_row_scan; 43 pt_scan = vp9_row_scan_4x4;
44 break; 44 break;
45 45
46 case DCT_ADST : 46 case DCT_ADST:
47 pt_scan = vp9_col_scan; 47 pt_scan = vp9_col_scan_4x4;
48 break; 48 break;
49 49
50 default : 50 default:
51 pt_scan = vp9_default_zig_zag1d; 51 pt_scan = vp9_default_zig_zag1d_4x4;
52 break; 52 break;
53 } 53 }
54 54
55 vpx_memset(qcoeff_ptr, 0, 32); 55 vpx_memset(qcoeff_ptr, 0, 32);
56 vpx_memset(dqcoeff_ptr, 0, 32); 56 vpx_memset(dqcoeff_ptr, 0, 32);
57 57
58 eob = -1; 58 eob = -1;
59 59
60 for (i = 0; i < b->eob_max_offset; i++) { 60 for (i = 0; i < b->eob_max_offset; i++) {
61 rc = pt_scan[i]; 61 rc = pt_scan[i];
(...skipping 20 matching lines...) Expand all
82 } 82 }
83 } 83 }
84 84
85 d->eob = eob + 1; 85 d->eob = eob + 1;
86 } 86 }
87 87
88 void vp9_regular_quantize_b_4x4(BLOCK *b, BLOCKD *d) { 88 void vp9_regular_quantize_b_4x4(BLOCK *b, BLOCKD *d) {
89 int i, rc, eob; 89 int i, rc, eob;
90 int zbin; 90 int zbin;
91 int x, y, z, sz; 91 int x, y, z, sz;
92 short *zbin_boost_ptr = b->zrun_zbin_boost; 92 int16_t *zbin_boost_ptr = b->zrun_zbin_boost;
93 short *coeff_ptr = b->coeff; 93 int16_t *coeff_ptr = b->coeff;
94 short *zbin_ptr = b->zbin; 94 int16_t *zbin_ptr = b->zbin;
95 short *round_ptr = b->round; 95 int16_t *round_ptr = b->round;
96 short *quant_ptr = b->quant; 96 int16_t *quant_ptr = b->quant;
97 unsigned char *quant_shift_ptr = b->quant_shift; 97 uint8_t *quant_shift_ptr = b->quant_shift;
98 short *qcoeff_ptr = d->qcoeff; 98 int16_t *qcoeff_ptr = d->qcoeff;
99 short *dqcoeff_ptr = d->dqcoeff; 99 int16_t *dqcoeff_ptr = d->dqcoeff;
100 short *dequant_ptr = d->dequant; 100 int16_t *dequant_ptr = d->dequant;
101 short zbin_oq_value = b->zbin_extra; 101 int zbin_oq_value = b->zbin_extra;
102 102
103 vpx_memset(qcoeff_ptr, 0, 32); 103 vpx_memset(qcoeff_ptr, 0, 32);
104 vpx_memset(dqcoeff_ptr, 0, 32); 104 vpx_memset(dqcoeff_ptr, 0, 32);
105 105
106 eob = -1; 106 eob = -1;
107 107
108 for (i = 0; i < b->eob_max_offset; i++) { 108 for (i = 0; i < b->eob_max_offset; i++) {
109 rc = vp9_default_zig_zag1d[i]; 109 rc = vp9_default_zig_zag1d_4x4[i];
110 z = coeff_ptr[rc]; 110 z = coeff_ptr[rc];
111 111
112 zbin = zbin_ptr[rc] + *zbin_boost_ptr + zbin_oq_value; 112 zbin = zbin_ptr[rc] + *zbin_boost_ptr + zbin_oq_value;
113 zbin_boost_ptr ++; 113 zbin_boost_ptr ++;
114 114
115 sz = (z >> 31); // sign of z 115 sz = (z >> 31); // sign of z
116 x = (z ^ sz) - sz; // x = abs(z) 116 x = (z ^ sz) - sz; // x = abs(z)
117 117
118 if (x >= zbin) { 118 if (x >= zbin) {
119 x += round_ptr[rc]; 119 x += round_ptr[rc];
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 167
168 void vp9_quantize_mb_4x4_c(MACROBLOCK *x) { 168 void vp9_quantize_mb_4x4_c(MACROBLOCK *x) {
169 vp9_quantize_mby_4x4_c(x); 169 vp9_quantize_mby_4x4_c(x);
170 vp9_quantize_mbuv_4x4_c(x); 170 vp9_quantize_mbuv_4x4_c(x);
171 } 171 }
172 172
173 void vp9_regular_quantize_b_2x2(BLOCK *b, BLOCKD *d) { 173 void vp9_regular_quantize_b_2x2(BLOCK *b, BLOCKD *d) {
174 int i, rc, eob; 174 int i, rc, eob;
175 int zbin; 175 int zbin;
176 int x, y, z, sz; 176 int x, y, z, sz;
177 short *zbin_boost_ptr = b->zrun_zbin_boost; 177 int16_t *zbin_boost_ptr = b->zrun_zbin_boost;
178 int zbin_zrun_index = 0; 178 int zbin_zrun_index = 0;
179 short *coeff_ptr = b->coeff; 179 int16_t *coeff_ptr = b->coeff;
180 short *zbin_ptr = b->zbin; 180 int16_t *zbin_ptr = b->zbin;
181 short *round_ptr = b->round; 181 int16_t *round_ptr = b->round;
182 short *quant_ptr = b->quant; 182 int16_t *quant_ptr = b->quant;
183 unsigned char *quant_shift_ptr = b->quant_shift; 183 uint8_t *quant_shift_ptr = b->quant_shift;
184 short *qcoeff_ptr = d->qcoeff; 184 int16_t *qcoeff_ptr = d->qcoeff;
185 short *dqcoeff_ptr = d->dqcoeff; 185 int16_t *dqcoeff_ptr = d->dqcoeff;
186 short *dequant_ptr = d->dequant; 186 int16_t *dequant_ptr = d->dequant;
187 short zbin_oq_value = b->zbin_extra; 187 int zbin_oq_value = b->zbin_extra;
188 // double q2nd = 4; 188 // double q2nd = 4;
189 vpx_memset(qcoeff_ptr, 0, 32); 189 vpx_memset(qcoeff_ptr, 0, 32);
190 vpx_memset(dqcoeff_ptr, 0, 32); 190 vpx_memset(dqcoeff_ptr, 0, 32);
191 191
192 eob = -1; 192 eob = -1;
193 193
194 for (i = 0; i < b->eob_max_offset_8x8; i++) { 194 for (i = 0; i < b->eob_max_offset_8x8; i++) {
195 rc = vp9_default_zig_zag1d[i]; 195 rc = vp9_default_zig_zag1d_4x4[i];
196 z = coeff_ptr[rc]; 196 z = coeff_ptr[rc];
197 197
198 zbin_boost_ptr = &b->zrun_zbin_boost[zbin_zrun_index]; 198 zbin_boost_ptr = &b->zrun_zbin_boost[zbin_zrun_index];
199 zbin_zrun_index += 4; 199 zbin_zrun_index += 4;
200 zbin = (zbin_ptr[rc] + *zbin_boost_ptr + zbin_oq_value); 200 zbin = (zbin_ptr[rc] + *zbin_boost_ptr + zbin_oq_value);
201 201
202 sz = (z >> 31); // sign of z 202 sz = (z >> 31); // sign of z
203 x = (z ^ sz) - sz; // x = abs(z) 203 x = (z ^ sz) - sz; // x = abs(z)
204 204
205 if (x >= zbin) { 205 if (x >= zbin) {
(...skipping 11 matching lines...) Expand all
217 } 217 }
218 } 218 }
219 219
220 d->eob = eob + 1; 220 d->eob = eob + 1;
221 } 221 }
222 222
223 void vp9_regular_quantize_b_8x8(BLOCK *b, BLOCKD *d) { 223 void vp9_regular_quantize_b_8x8(BLOCK *b, BLOCKD *d) {
224 int i, rc, eob; 224 int i, rc, eob;
225 int zbin; 225 int zbin;
226 int x, y, z, sz; 226 int x, y, z, sz;
227 short *zbin_boost_ptr = b->zrun_zbin_boost_8x8; 227 int16_t *zbin_boost_ptr = b->zrun_zbin_boost_8x8;
228 short *coeff_ptr = b->coeff; 228 int16_t *coeff_ptr = b->coeff;
229 short *zbin_ptr = b->zbin_8x8; 229 int16_t *zbin_ptr = b->zbin_8x8;
230 short *round_ptr = b->round; 230 int16_t *round_ptr = b->round;
231 short *quant_ptr = b->quant; 231 int16_t *quant_ptr = b->quant;
232 unsigned char *quant_shift_ptr = b->quant_shift; 232 uint8_t *quant_shift_ptr = b->quant_shift;
233 short *qcoeff_ptr = d->qcoeff; 233 int16_t *qcoeff_ptr = d->qcoeff;
234 short *dqcoeff_ptr = d->dqcoeff; 234 int16_t *dqcoeff_ptr = d->dqcoeff;
235 short *dequant_ptr = d->dequant; 235 int16_t *dequant_ptr = d->dequant;
236 short zbin_oq_value = b->zbin_extra; 236 int zbin_oq_value = b->zbin_extra;
237 237
238 vpx_memset(qcoeff_ptr, 0, 64 * sizeof(short)); 238 vpx_memset(qcoeff_ptr, 0, 64 * sizeof(int16_t));
239 vpx_memset(dqcoeff_ptr, 0, 64 * sizeof(short)); 239 vpx_memset(dqcoeff_ptr, 0, 64 * sizeof(int16_t));
240 240
241 eob = -1; 241 eob = -1;
242 242
243 for (i = 0; i < b->eob_max_offset_8x8; i++) { 243 for (i = 0; i < b->eob_max_offset_8x8; i++) {
244 rc = vp9_default_zig_zag1d_8x8[i]; 244 rc = vp9_default_zig_zag1d_8x8[i];
245 z = coeff_ptr[rc]; 245 z = coeff_ptr[rc];
246 246
247 zbin = (zbin_ptr[rc != 0] + *zbin_boost_ptr + zbin_oq_value); 247 zbin = (zbin_ptr[rc != 0] + *zbin_boost_ptr + zbin_oq_value);
248 zbin_boost_ptr++; 248 zbin_boost_ptr++;
249 249
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 x->e_mbd.block[i].eob = 0; 316 x->e_mbd.block[i].eob = 0;
317 x->e_mbd.block[24].eob = 0; 317 x->e_mbd.block[24].eob = 0;
318 x->quantize_b_16x16(&x->block[0], &x->e_mbd.block[0]); 318 x->quantize_b_16x16(&x->block[0], &x->e_mbd.block[0]);
319 } 319 }
320 320
321 void vp9_quantize_mb_16x16(MACROBLOCK *x) { 321 void vp9_quantize_mb_16x16(MACROBLOCK *x) {
322 vp9_quantize_mby_16x16(x); 322 vp9_quantize_mby_16x16(x);
323 vp9_quantize_mbuv_8x8(x); 323 vp9_quantize_mbuv_8x8(x);
324 } 324 }
325 325
326 void vp9_regular_quantize_b_16x16(BLOCK *b, BLOCKD *d) { 326 static void quantize(int16_t *zbin_boost_orig_ptr,
327 int16_t *coeff_ptr, int n_coeffs, int max_coeffs,
328 int16_t *zbin_ptr, int16_t *round_ptr, int16_t *quant_ptr,
329 uint8_t *quant_shift_ptr,
330 int16_t *qcoeff_ptr, int16_t *dqcoeff_ptr,
331 int16_t *dequant_ptr, int zbin_oq_value,
332 int *eob_ptr, const int *scan, int mul) {
327 int i, rc, eob; 333 int i, rc, eob;
328 int zbin; 334 int zbin;
329 int x, y, z, sz; 335 int x, y, z, sz;
330 short *zbin_boost_ptr = b->zrun_zbin_boost_16x16; 336 int16_t *zbin_boost_ptr = zbin_boost_orig_ptr;
331 short *coeff_ptr = b->coeff;
332 short *zbin_ptr = b->zbin_16x16;
333 short *round_ptr = b->round;
334 short *quant_ptr = b->quant;
335 unsigned char *quant_shift_ptr = b->quant_shift;
336 short *qcoeff_ptr = d->qcoeff;
337 short *dqcoeff_ptr = d->dqcoeff;
338 short *dequant_ptr = d->dequant;
339 short zbin_oq_value = b->zbin_extra;
340 337
341 vpx_memset(qcoeff_ptr, 0, 256*sizeof(short)); 338 vpx_memset(qcoeff_ptr, 0, n_coeffs*sizeof(int16_t));
342 vpx_memset(dqcoeff_ptr, 0, 256*sizeof(short)); 339 vpx_memset(dqcoeff_ptr, 0, n_coeffs*sizeof(int16_t));
343 340
344 eob = -1; 341 eob = -1;
345 for (i = 0; i < b->eob_max_offset_16x16; i++) { 342 for (i = 0; i < max_coeffs; i++) {
346 rc = vp9_default_zig_zag1d_16x16[i]; 343 rc = scan[i];
347 z = coeff_ptr[rc]; 344 z = coeff_ptr[rc] * mul;
348 345
349 zbin = (zbin_ptr[rc!=0] + *zbin_boost_ptr + zbin_oq_value); 346 zbin = (zbin_ptr[rc!=0] + *zbin_boost_ptr + zbin_oq_value);
350 zbin_boost_ptr ++; 347 zbin_boost_ptr ++;
351 348
352 sz = (z >> 31); // sign of z 349 sz = (z >> 31); // sign of z
353 x = (z ^ sz) - sz; // x = abs(z) 350 x = (z ^ sz) - sz; // x = abs(z)
354 351
355 if (x >= zbin) { 352 if (x >= zbin) {
356 x += (round_ptr[rc!=0]); 353 x += (round_ptr[rc!=0]);
357 y = ((int)(((int)(x * quant_ptr[rc!=0]) >> 16) + x)) 354 y = ((int)(((int)(x * quant_ptr[rc != 0]) >> 16) + x))
358 >> quant_shift_ptr[rc!=0]; // quantize (x) 355 >> quant_shift_ptr[rc!=0]; // quantize (x)
359 x = (y ^ sz) - sz; // get the sign back 356 x = (y ^ sz) - sz; // get the sign back
360 qcoeff_ptr[rc] = x; // write to destination 357 qcoeff_ptr[rc] = x; // write to destination
361 dqcoeff_ptr[rc] = x * dequant_ptr[rc!=0]; // dequantized value 358 dqcoeff_ptr[rc] = x * dequant_ptr[rc != 0] / mul; // dequantized value
362 359
363 if (y) { 360 if (y) {
364 eob = i; // last nonzero coeffs 361 eob = i; // last nonzero coeffs
365 zbin_boost_ptr = b->zrun_zbin_boost_16x16; 362 zbin_boost_ptr = zbin_boost_orig_ptr;
366 } 363 }
367 } 364 }
368 } 365 }
369 366
370 d->eob = eob + 1; 367 *eob_ptr = eob + 1;
368 }
369
370 void vp9_regular_quantize_b_16x16(BLOCK *b, BLOCKD *d) {
371 quantize(b->zrun_zbin_boost_16x16,
372 b->coeff,
373 256, b->eob_max_offset_16x16,
374 b->zbin_16x16, b->round, b->quant, b->quant_shift,
375 d->qcoeff,
376 d->dqcoeff,
377 d->dequant,
378 b->zbin_extra,
379 &d->eob, vp9_default_zig_zag1d_16x16, 1);
380 }
381
382 void vp9_quantize_sby_32x32(MACROBLOCK *x) {
383 x->e_mbd.block[0].eob = 0;
384 quantize(x->block[0].zrun_zbin_boost_32x32,
385 x->sb_coeff_data.coeff,
386 1024, x->block[0].eob_max_offset_32x32,
387 x->block[0].zbin_32x32,
388 x->block[0].round, x->block[0].quant, x->block[0].quant_shift,
389 x->e_mbd.sb_coeff_data.qcoeff,
390 x->e_mbd.sb_coeff_data.dqcoeff,
391 x->e_mbd.block[0].dequant,
392 x->block[0].zbin_extra,
393 &x->e_mbd.block[0].eob,
394 vp9_default_zig_zag1d_32x32, 2);
395 }
396
397 void vp9_quantize_sbuv_16x16(MACROBLOCK *x) {
398 int i;
399
400 x->e_mbd.block[16].eob = 0;
401 x->e_mbd.block[20].eob = 0;
402 for (i = 16; i < 24; i += 4)
403 quantize(x->block[i].zrun_zbin_boost_16x16,
404 x->sb_coeff_data.coeff + 1024 + (i - 16) * 64,
405 256, x->block[i].eob_max_offset_16x16,
406 x->block[i].zbin_16x16,
407 x->block[i].round, x->block[0].quant, x->block[i].quant_shift,
408 x->e_mbd.sb_coeff_data.qcoeff + 1024 + (i - 16) * 64,
409 x->e_mbd.sb_coeff_data.dqcoeff + 1024 + (i - 16) * 64,
410 x->e_mbd.block[i].dequant,
411 x->block[i].zbin_extra,
412 &x->e_mbd.block[i].eob,
413 vp9_default_zig_zag1d_16x16, 1);
371 } 414 }
372 415
373 /* quantize_b_pair function pointer in MACROBLOCK structure is set to one of 416 /* quantize_b_pair function pointer in MACROBLOCK structure is set to one of
374 * these two C functions if corresponding optimized routine is not available. 417 * these two C functions if corresponding optimized routine is not available.
375 * NEON optimized version implements currently the fast quantization for pair 418 * NEON optimized version implements currently the fast quantization for pair
376 * of blocks. */ 419 * of blocks. */
377 void vp9_regular_quantize_b_4x4_pair(BLOCK *b1, BLOCK *b2, 420 void vp9_regular_quantize_b_4x4_pair(BLOCK *b1, BLOCK *b2,
378 BLOCKD *d1, BLOCKD *d2) { 421 BLOCKD *d1, BLOCKD *d2) {
379 vp9_regular_quantize_b_4x4(b1, d1); 422 vp9_regular_quantize_b_4x4(b1, d1);
380 vp9_regular_quantize_b_4x4(b2, d2); 423 vp9_regular_quantize_b_4x4(b2, d2);
381 } 424 }
382 425
383 static void invert_quant(short *quant, 426 static void invert_quant(int16_t *quant,
384 unsigned char *shift, short d) { 427 uint8_t *shift, int d) {
385 unsigned t; 428 unsigned t;
386 int l; 429 int l;
387 t = d; 430 t = d;
388 for (l = 0; t > 1; l++) 431 for (l = 0; t > 1; l++)
389 t >>= 1; 432 t >>= 1;
390 t = 1 + (1 << (16 + l)) / d; 433 t = 1 + (1 << (16 + l)) / d;
391 *quant = (short)(t - (1 << 16)); 434 *quant = (int16_t)(t - (1 << 16));
392 *shift = l; 435 *shift = l;
393 } 436 }
394 437
395 void vp9_init_quantizer(VP9_COMP *cpi) { 438 void vp9_init_quantizer(VP9_COMP *cpi) {
396 int i; 439 int i;
397 int quant_val; 440 int quant_val;
398 int Q; 441 int Q;
399 static const int zbin_boost[16] = { 0, 0, 8, 10, 12, 14, 16, 20, 442 static const int zbin_boost[16] = { 0, 0, 8, 10, 12, 14, 16, 20,
400 24, 28, 32, 36, 40, 44, 44, 44 443 24, 28, 32, 36, 40, 44, 44, 44
401 }; 444 };
(...skipping 18 matching lines...) Expand all
420 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 463 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
421 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 464 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
422 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 465 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
423 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 466 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
424 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 467 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
425 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 468 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
426 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 469 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
427 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 470 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
428 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 471 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
429 }; 472 };
473 static const int zbin_boost_32x32[1024] = {
474 0, 0, 0, 8, 8, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28,
475 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 48, 48, 48, 48, 48, 48,
476 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
477 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
478 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
479 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
480 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
481 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
482 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
483 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
484 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
485 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
486 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
487 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
488 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
489 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
490 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
491 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
492 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
493 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
494 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
495 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
496 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
497 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
498 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
499 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
500 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
501 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
502 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
503 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
504 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
505 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
506 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
507 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
508 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
509 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
510 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
511 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
512 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
513 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
514 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
515 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
516 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
517 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
518 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
519 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
520 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
521 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
522 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
523 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
524 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
525 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
526 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
527 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
528 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
529 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
530 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
531 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
532 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
533 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
534 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
535 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
536 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
537 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
538 };
430 int qrounding_factor = 48; 539 int qrounding_factor = 48;
431 540
432 541
433 for (Q = 0; Q < QINDEX_RANGE; Q++) { 542 for (Q = 0; Q < QINDEX_RANGE; Q++) {
434 int qzbin_factor = (vp9_dc_quant(Q, 0) < 148) ? 84 : 80; 543 int qzbin_factor = (vp9_dc_quant(Q, 0) < 148) ? 84 : 80;
435 544
436 #if CONFIG_LOSSLESS 545 #if CONFIG_LOSSLESS
437 if (cpi->oxcf.lossless) { 546 if (cpi->oxcf.lossless) {
438 if (Q == 0) { 547 if (Q == 0) {
439 qzbin_factor = 64; 548 qzbin_factor = 64;
440 qrounding_factor = 64; 549 qrounding_factor = 64;
441 } 550 }
442 } 551 }
443 #endif 552 #endif
444 553
445 // dc values 554 // dc values
446 quant_val = vp9_dc_quant(Q, cpi->common.y1dc_delta_q); 555 quant_val = vp9_dc_quant(Q, cpi->common.y1dc_delta_q);
447 invert_quant(cpi->Y1quant[Q] + 0, 556 invert_quant(cpi->Y1quant[Q] + 0,
448 cpi->Y1quant_shift[Q] + 0, quant_val); 557 cpi->Y1quant_shift[Q] + 0, quant_val);
449 cpi->Y1zbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7; 558 cpi->Y1zbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
450 cpi->Y1zbin_8x8[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7; 559 cpi->Y1zbin_8x8[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
451 cpi->Y1zbin_16x16[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7; 560 cpi->Y1zbin_16x16[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
452 cpi->Y1round[Q][0] = (qrounding_factor * quant_val) >> 7; 561 cpi->Y1round[Q][0] = (qrounding_factor * quant_val) >> 7;
453 cpi->common.Y1dequant[Q][0] = quant_val; 562 cpi->common.Y1dequant[Q][0] = quant_val;
454 cpi->zrun_zbin_boost_y1[Q][0] = (quant_val * zbin_boost[0]) >> 7; 563 cpi->zrun_zbin_boost_y1[Q][0] = (quant_val * zbin_boost[0]) >> 7;
455 cpi->zrun_zbin_boost_y1_8x8[Q][0] = 564 cpi->zrun_zbin_boost_y1_8x8[Q][0] =
456 ((quant_val * zbin_boost_8x8[0]) + 64) >> 7; 565 ((quant_val * zbin_boost_8x8[0]) + 64) >> 7;
457 cpi->zrun_zbin_boost_y1_16x16[Q][0] = ((quant_val * zbin_boost_16x16[0]) + 6 4) >> 7; 566 cpi->zrun_zbin_boost_y1_16x16[Q][0] =
567 ((quant_val * zbin_boost_16x16[0]) + 64) >> 7;
568 cpi->Y1zbin_32x32[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
569 cpi->zrun_zbin_boost_y1_32x32[Q][0] =
570 ((quant_val * zbin_boost_32x32[0]) + 64) >> 7;
458 571
459 572
460 quant_val = vp9_dc2quant(Q, cpi->common.y2dc_delta_q); 573 quant_val = vp9_dc2quant(Q, cpi->common.y2dc_delta_q);
461 invert_quant(cpi->Y2quant[Q] + 0, 574 invert_quant(cpi->Y2quant[Q] + 0,
462 cpi->Y2quant_shift[Q] + 0, quant_val); 575 cpi->Y2quant_shift[Q] + 0, quant_val);
463 cpi->Y2zbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7; 576 cpi->Y2zbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
464 cpi->Y2zbin_8x8[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7; 577 cpi->Y2zbin_8x8[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
465 cpi->Y2zbin_16x16[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7; 578 cpi->Y2zbin_16x16[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
466 cpi->Y2round[Q][0] = (qrounding_factor * quant_val) >> 7; 579 cpi->Y2round[Q][0] = (qrounding_factor * quant_val) >> 7;
467 cpi->common.Y2dequant[Q][0] = quant_val; 580 cpi->common.Y2dequant[Q][0] = quant_val;
468 cpi->zrun_zbin_boost_y2[Q][0] = (quant_val * zbin_boost[0]) >> 7; 581 cpi->zrun_zbin_boost_y2[Q][0] = (quant_val * zbin_boost[0]) >> 7;
469 cpi->zrun_zbin_boost_y2_8x8[Q][0] = 582 cpi->zrun_zbin_boost_y2_8x8[Q][0] =
470 ((quant_val * zbin_boost_8x8[0]) + 64) >> 7; 583 ((quant_val * zbin_boost_8x8[0]) + 64) >> 7;
471 cpi->zrun_zbin_boost_y2_16x16[Q][0] = ((quant_val * zbin_boost_16x16[0]) + 6 4) >> 7; 584 cpi->zrun_zbin_boost_y2_16x16[Q][0] =
585 ((quant_val * zbin_boost_16x16[0]) + 64) >> 7;
472 586
473 quant_val = vp9_dc_uv_quant(Q, cpi->common.uvdc_delta_q); 587 quant_val = vp9_dc_uv_quant(Q, cpi->common.uvdc_delta_q);
474 invert_quant(cpi->UVquant[Q] + 0, 588 invert_quant(cpi->UVquant[Q] + 0,
475 cpi->UVquant_shift[Q] + 0, quant_val); 589 cpi->UVquant_shift[Q] + 0, quant_val);
476 cpi->UVzbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7; 590 cpi->UVzbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
477 cpi->UVzbin_8x8[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7; 591 cpi->UVzbin_8x8[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
478 cpi->UVzbin_16x16[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7; 592 cpi->UVzbin_16x16[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
479 cpi->UVround[Q][0] = (qrounding_factor * quant_val) >> 7; 593 cpi->UVround[Q][0] = (qrounding_factor * quant_val) >> 7;
480 cpi->common.UVdequant[Q][0] = quant_val; 594 cpi->common.UVdequant[Q][0] = quant_val;
481 cpi->zrun_zbin_boost_uv[Q][0] = (quant_val * zbin_boost[0]) >> 7; 595 cpi->zrun_zbin_boost_uv[Q][0] = (quant_val * zbin_boost[0]) >> 7;
482 cpi->zrun_zbin_boost_uv_8x8[Q][0] = 596 cpi->zrun_zbin_boost_uv_8x8[Q][0] =
483 ((quant_val * zbin_boost_8x8[0]) + 64) >> 7; 597 ((quant_val * zbin_boost_8x8[0]) + 64) >> 7;
484 cpi->zrun_zbin_boost_uv_16x16[Q][0] = ((quant_val * zbin_boost_16x16[0]) + 6 4) >> 7; 598 cpi->zrun_zbin_boost_uv_16x16[Q][0] =
599 ((quant_val * zbin_boost_16x16[0]) + 64) >> 7;
485 600
486 // all the 4x4 ac values =; 601 // all the 4x4 ac values =;
487 for (i = 1; i < 16; i++) { 602 for (i = 1; i < 16; i++) {
488 int rc = vp9_default_zig_zag1d[i]; 603 int rc = vp9_default_zig_zag1d_4x4[i];
489 604
490 quant_val = vp9_ac_yquant(Q); 605 quant_val = vp9_ac_yquant(Q);
491 invert_quant(cpi->Y1quant[Q] + rc, 606 invert_quant(cpi->Y1quant[Q] + rc,
492 cpi->Y1quant_shift[Q] + rc, quant_val); 607 cpi->Y1quant_shift[Q] + rc, quant_val);
493 cpi->Y1zbin[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7; 608 cpi->Y1zbin[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
494 cpi->Y1round[Q][rc] = (qrounding_factor * quant_val) >> 7; 609 cpi->Y1round[Q][rc] = (qrounding_factor * quant_val) >> 7;
495 cpi->common.Y1dequant[Q][rc] = quant_val; 610 cpi->common.Y1dequant[Q][rc] = quant_val;
496 cpi->zrun_zbin_boost_y1[Q][i] = 611 cpi->zrun_zbin_boost_y1[Q][i] =
497 ((quant_val * zbin_boost[i]) + 64) >> 7; 612 ((quant_val * zbin_boost[i]) + 64) >> 7;
498 613
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 cpi->zrun_zbin_boost_uv_8x8[Q][i] = 651 cpi->zrun_zbin_boost_uv_8x8[Q][i] =
537 ((quant_val * zbin_boost_8x8[i]) + 64) >> 7; 652 ((quant_val * zbin_boost_8x8[i]) + 64) >> 7;
538 } 653 }
539 654
540 // 16x16 structures. Same comment above applies. 655 // 16x16 structures. Same comment above applies.
541 for (i = 1; i < 256; i++) { 656 for (i = 1; i < 256; i++) {
542 int rc = vp9_default_zig_zag1d_16x16[i]; 657 int rc = vp9_default_zig_zag1d_16x16[i];
543 658
544 quant_val = vp9_ac_yquant(Q); 659 quant_val = vp9_ac_yquant(Q);
545 cpi->Y1zbin_16x16[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7; 660 cpi->Y1zbin_16x16[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
546 cpi->zrun_zbin_boost_y1_16x16[Q][i] = ((quant_val * zbin_boost_16x16[i]) + 64) >> 7; 661 cpi->zrun_zbin_boost_y1_16x16[Q][i] =
662 ((quant_val * zbin_boost_16x16[i]) + 64) >> 7;
547 663
548 quant_val = vp9_ac2quant(Q, cpi->common.y2ac_delta_q); 664 quant_val = vp9_ac2quant(Q, cpi->common.y2ac_delta_q);
549 cpi->Y2zbin_16x16[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7; 665 cpi->Y2zbin_16x16[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
550 cpi->zrun_zbin_boost_y2_16x16[Q][i] = ((quant_val * zbin_boost_16x16[i]) + 64) >> 7; 666 cpi->zrun_zbin_boost_y2_16x16[Q][i] =
667 ((quant_val * zbin_boost_16x16[i]) + 64) >> 7;
551 668
552 quant_val = vp9_ac_uv_quant(Q, cpi->common.uvac_delta_q); 669 quant_val = vp9_ac_uv_quant(Q, cpi->common.uvac_delta_q);
553 cpi->UVzbin_16x16[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7; 670 cpi->UVzbin_16x16[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
554 cpi->zrun_zbin_boost_uv_16x16[Q][i] = ((quant_val * zbin_boost_16x16[i]) + 64) >> 7; 671 cpi->zrun_zbin_boost_uv_16x16[Q][i] =
672 ((quant_val * zbin_boost_16x16[i]) + 64) >> 7;
673 }
674 // 32x32 structures. Same comment above applies.
675 for (i = 1; i < 1024; i++) {
676 int rc = vp9_default_zig_zag1d_32x32[i];
677
678 quant_val = vp9_ac_yquant(Q);
679 cpi->Y1zbin_32x32[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
680 cpi->zrun_zbin_boost_y1_32x32[Q][i] =
681 ((quant_val * zbin_boost_32x32[i]) + 64) >> 7;
555 } 682 }
556 } 683 }
557 } 684 }
558 685
559 void vp9_mb_init_quantizer(VP9_COMP *cpi, MACROBLOCK *x) { 686 void vp9_mb_init_quantizer(VP9_COMP *cpi, MACROBLOCK *x) {
560 int i; 687 int i;
561 int QIndex; 688 int QIndex;
562 MACROBLOCKD *xd = &x->e_mbd; 689 MACROBLOCKD *xd = &x->e_mbd;
563 int zbin_extra; 690 int zbin_extra;
564 int segment_id = xd->mode_info_context->mbmi.segment_id; 691 int segment_id = xd->mode_info_context->mbmi.segment_id;
(...skipping 20 matching lines...) Expand all
585 (cpi->zbin_over_quant + 712 (cpi->zbin_over_quant +
586 cpi->zbin_mode_boost + 713 cpi->zbin_mode_boost +
587 x->act_zbin_adj)) >> 7; 714 x->act_zbin_adj)) >> 7;
588 715
589 for (i = 0; i < 16; i++) { 716 for (i = 0; i < 16; i++) {
590 x->block[i].quant = cpi->Y1quant[QIndex]; 717 x->block[i].quant = cpi->Y1quant[QIndex];
591 x->block[i].quant_shift = cpi->Y1quant_shift[QIndex]; 718 x->block[i].quant_shift = cpi->Y1quant_shift[QIndex];
592 x->block[i].zbin = cpi->Y1zbin[QIndex]; 719 x->block[i].zbin = cpi->Y1zbin[QIndex];
593 x->block[i].zbin_8x8 = cpi->Y1zbin_8x8[QIndex]; 720 x->block[i].zbin_8x8 = cpi->Y1zbin_8x8[QIndex];
594 x->block[i].zbin_16x16 = cpi->Y1zbin_16x16[QIndex]; 721 x->block[i].zbin_16x16 = cpi->Y1zbin_16x16[QIndex];
722 x->block[i].zbin_32x32 = cpi->Y1zbin_32x32[QIndex];
595 x->block[i].round = cpi->Y1round[QIndex]; 723 x->block[i].round = cpi->Y1round[QIndex];
596 x->e_mbd.block[i].dequant = cpi->common.Y1dequant[QIndex]; 724 x->e_mbd.block[i].dequant = cpi->common.Y1dequant[QIndex];
597 x->block[i].zrun_zbin_boost = cpi->zrun_zbin_boost_y1[QIndex]; 725 x->block[i].zrun_zbin_boost = cpi->zrun_zbin_boost_y1[QIndex];
598 x->block[i].zrun_zbin_boost_8x8 = cpi->zrun_zbin_boost_y1_8x8[QIndex]; 726 x->block[i].zrun_zbin_boost_8x8 = cpi->zrun_zbin_boost_y1_8x8[QIndex];
599 x->block[i].zrun_zbin_boost_16x16 = cpi->zrun_zbin_boost_y1_16x16[QIndex]; 727 x->block[i].zrun_zbin_boost_16x16 = cpi->zrun_zbin_boost_y1_16x16[QIndex];
600 x->block[i].zbin_extra = (short)zbin_extra; 728 x->block[i].zrun_zbin_boost_32x32 = cpi->zrun_zbin_boost_y1_32x32[QIndex];
729 x->block[i].zbin_extra = (int16_t)zbin_extra;
601 730
602 // Segment max eob offset feature. 731 // Segment max eob offset feature.
603 if (vp9_segfeature_active(xd, segment_id, SEG_LVL_EOB)) { 732 if (vp9_segfeature_active(xd, segment_id, SEG_LVL_EOB)) {
604 x->block[i].eob_max_offset = 733 x->block[i].eob_max_offset =
605 vp9_get_segdata(xd, segment_id, SEG_LVL_EOB); 734 vp9_get_segdata(xd, segment_id, SEG_LVL_EOB);
606 x->block[i].eob_max_offset_8x8 = 735 x->block[i].eob_max_offset_8x8 =
607 vp9_get_segdata(xd, segment_id, SEG_LVL_EOB); 736 vp9_get_segdata(xd, segment_id, SEG_LVL_EOB);
608 x->block[i].eob_max_offset_16x16 = 737 x->block[i].eob_max_offset_16x16 =
609 vp9_get_segdata(xd, segment_id, SEG_LVL_EOB); 738 vp9_get_segdata(xd, segment_id, SEG_LVL_EOB);
739 x->block[i].eob_max_offset_32x32 =
740 vp9_get_segdata(xd, segment_id, SEG_LVL_EOB);
610 } else { 741 } else {
611 x->block[i].eob_max_offset = 16; 742 x->block[i].eob_max_offset = 16;
612 x->block[i].eob_max_offset_8x8 = 64; 743 x->block[i].eob_max_offset_8x8 = 64;
613 x->block[i].eob_max_offset_16x16 = 256; 744 x->block[i].eob_max_offset_16x16 = 256;
745 x->block[i].eob_max_offset_32x32 = 1024;
614 } 746 }
615 } 747 }
616 748
617 // UV 749 // UV
618 zbin_extra = (cpi->common.UVdequant[QIndex][1] * 750 zbin_extra = (cpi->common.UVdequant[QIndex][1] *
619 (cpi->zbin_over_quant + 751 (cpi->zbin_over_quant +
620 cpi->zbin_mode_boost + 752 cpi->zbin_mode_boost +
621 x->act_zbin_adj)) >> 7; 753 x->act_zbin_adj)) >> 7;
622 754
623 for (i = 16; i < 24; i++) { 755 for (i = 16; i < 24; i++) {
624 x->block[i].quant = cpi->UVquant[QIndex]; 756 x->block[i].quant = cpi->UVquant[QIndex];
625 x->block[i].quant_shift = cpi->UVquant_shift[QIndex]; 757 x->block[i].quant_shift = cpi->UVquant_shift[QIndex];
626 x->block[i].zbin = cpi->UVzbin[QIndex]; 758 x->block[i].zbin = cpi->UVzbin[QIndex];
627 x->block[i].zbin_8x8 = cpi->UVzbin_8x8[QIndex]; 759 x->block[i].zbin_8x8 = cpi->UVzbin_8x8[QIndex];
628 x->block[i].zbin_16x16 = cpi->UVzbin_16x16[QIndex]; 760 x->block[i].zbin_16x16 = cpi->UVzbin_16x16[QIndex];
629 x->block[i].round = cpi->UVround[QIndex]; 761 x->block[i].round = cpi->UVround[QIndex];
630 x->e_mbd.block[i].dequant = cpi->common.UVdequant[QIndex]; 762 x->e_mbd.block[i].dequant = cpi->common.UVdequant[QIndex];
631 x->block[i].zrun_zbin_boost = cpi->zrun_zbin_boost_uv[QIndex]; 763 x->block[i].zrun_zbin_boost = cpi->zrun_zbin_boost_uv[QIndex];
632 x->block[i].zrun_zbin_boost_8x8 = cpi->zrun_zbin_boost_uv_8x8[QIndex]; 764 x->block[i].zrun_zbin_boost_8x8 = cpi->zrun_zbin_boost_uv_8x8[QIndex];
633 x->block[i].zrun_zbin_boost_16x16 = cpi->zrun_zbin_boost_uv_16x16[QIndex]; 765 x->block[i].zrun_zbin_boost_16x16 = cpi->zrun_zbin_boost_uv_16x16[QIndex];
634 766
635 x->block[i].zbin_extra = (short)zbin_extra; 767 x->block[i].zbin_extra = (int16_t)zbin_extra;
636 768
637 // Segment max eob offset feature. 769 // Segment max eob offset feature.
638 if (vp9_segfeature_active(xd, segment_id, SEG_LVL_EOB)) { 770 if (vp9_segfeature_active(xd, segment_id, SEG_LVL_EOB)) {
639 x->block[i].eob_max_offset = 771 x->block[i].eob_max_offset =
640 vp9_get_segdata(xd, segment_id, SEG_LVL_EOB); 772 vp9_get_segdata(xd, segment_id, SEG_LVL_EOB);
641 x->block[i].eob_max_offset_8x8 = 773 x->block[i].eob_max_offset_8x8 =
642 vp9_get_segdata(xd, segment_id, SEG_LVL_EOB); 774 vp9_get_segdata(xd, segment_id, SEG_LVL_EOB);
775 x->block[i].eob_max_offset_16x16 =
776 vp9_get_segdata(xd, segment_id, SEG_LVL_EOB);
643 } else { 777 } else {
644 x->block[i].eob_max_offset = 16; 778 x->block[i].eob_max_offset = 16;
645 x->block[i].eob_max_offset_8x8 = 64; 779 x->block[i].eob_max_offset_8x8 = 64;
780 x->block[i].eob_max_offset_16x16 = 256;
646 } 781 }
647 } 782 }
648 783
649 // Y2 784 // Y2
650 zbin_extra = (cpi->common.Y2dequant[QIndex][1] * 785 zbin_extra = (cpi->common.Y2dequant[QIndex][1] *
651 ((cpi->zbin_over_quant / 2) + 786 ((cpi->zbin_over_quant / 2) +
652 cpi->zbin_mode_boost + 787 cpi->zbin_mode_boost +
653 x->act_zbin_adj)) >> 7; 788 x->act_zbin_adj)) >> 7;
654 789
655 x->block[24].quant = cpi->Y2quant[QIndex]; 790 x->block[24].quant = cpi->Y2quant[QIndex];
656 x->block[24].quant_shift = cpi->Y2quant_shift[QIndex]; 791 x->block[24].quant_shift = cpi->Y2quant_shift[QIndex];
657 x->block[24].zbin = cpi->Y2zbin[QIndex]; 792 x->block[24].zbin = cpi->Y2zbin[QIndex];
658 x->block[24].zbin_8x8 = cpi->Y2zbin_8x8[QIndex]; 793 x->block[24].zbin_8x8 = cpi->Y2zbin_8x8[QIndex];
659 x->block[24].zbin_16x16 = cpi->Y2zbin_16x16[QIndex]; 794 x->block[24].zbin_16x16 = cpi->Y2zbin_16x16[QIndex];
660 x->block[24].round = cpi->Y2round[QIndex]; 795 x->block[24].round = cpi->Y2round[QIndex];
661 x->e_mbd.block[24].dequant = cpi->common.Y2dequant[QIndex]; 796 x->e_mbd.block[24].dequant = cpi->common.Y2dequant[QIndex];
662 x->block[24].zrun_zbin_boost = cpi->zrun_zbin_boost_y2[QIndex]; 797 x->block[24].zrun_zbin_boost = cpi->zrun_zbin_boost_y2[QIndex];
663 x->block[24].zrun_zbin_boost_8x8 = cpi->zrun_zbin_boost_y2_8x8[QIndex]; 798 x->block[24].zrun_zbin_boost_8x8 = cpi->zrun_zbin_boost_y2_8x8[QIndex];
664 x->block[24].zrun_zbin_boost_16x16 = cpi->zrun_zbin_boost_y2_16x16[QIndex]; 799 x->block[24].zrun_zbin_boost_16x16 = cpi->zrun_zbin_boost_y2_16x16[QIndex];
665 x->block[24].zbin_extra = (short)zbin_extra; 800 x->block[24].zbin_extra = (int16_t)zbin_extra;
666 801
667 // TBD perhaps not use for Y2 802 // TBD perhaps not use for Y2
668 // Segment max eob offset feature. 803 // Segment max eob offset feature.
669 if (vp9_segfeature_active(xd, segment_id, SEG_LVL_EOB)) { 804 if (vp9_segfeature_active(xd, segment_id, SEG_LVL_EOB)) {
670 x->block[24].eob_max_offset = 805 x->block[24].eob_max_offset =
671 vp9_get_segdata(xd, segment_id, SEG_LVL_EOB); 806 vp9_get_segdata(xd, segment_id, SEG_LVL_EOB);
672 x->block[24].eob_max_offset_8x8 = 807 x->block[24].eob_max_offset_8x8 =
673 vp9_get_segdata(xd, segment_id, SEG_LVL_EOB); 808 vp9_get_segdata(xd, segment_id, SEG_LVL_EOB);
674 } else { 809 } else {
675 x->block[24].eob_max_offset = 16; 810 x->block[24].eob_max_offset = 16;
676 x->block[24].eob_max_offset_8x8 = 4; 811 x->block[24].eob_max_offset_8x8 = 4;
677 } 812 }
678 813
679 /* save this macroblock QIndex for vp9_update_zbin_extra() */ 814 /* save this macroblock QIndex for vp9_update_zbin_extra() */
680 x->e_mbd.q_index = QIndex; 815 x->e_mbd.q_index = QIndex;
681 } 816 }
682 817
683 void vp9_update_zbin_extra(VP9_COMP *cpi, MACROBLOCK *x) { 818 void vp9_update_zbin_extra(VP9_COMP *cpi, MACROBLOCK *x) {
684 int i; 819 int i;
685 int QIndex = x->e_mbd.q_index; 820 int QIndex = x->e_mbd.q_index;
686 int zbin_extra; 821 int zbin_extra;
687 822
688 // Y 823 // Y
689 zbin_extra = (cpi->common.Y1dequant[QIndex][1] * 824 zbin_extra = (cpi->common.Y1dequant[QIndex][1] *
690 (cpi->zbin_over_quant + 825 (cpi->zbin_over_quant +
691 cpi->zbin_mode_boost + 826 cpi->zbin_mode_boost +
692 x->act_zbin_adj)) >> 7; 827 x->act_zbin_adj)) >> 7;
693 for (i = 0; i < 16; i++) { 828 for (i = 0; i < 16; i++) {
694 x->block[i].zbin_extra = (short)zbin_extra; 829 x->block[i].zbin_extra = (int16_t)zbin_extra;
695 } 830 }
696 831
697 // UV 832 // UV
698 zbin_extra = (cpi->common.UVdequant[QIndex][1] * 833 zbin_extra = (cpi->common.UVdequant[QIndex][1] *
699 (cpi->zbin_over_quant + 834 (cpi->zbin_over_quant +
700 cpi->zbin_mode_boost + 835 cpi->zbin_mode_boost +
701 x->act_zbin_adj)) >> 7; 836 x->act_zbin_adj)) >> 7;
702 837
703 for (i = 16; i < 24; i++) { 838 for (i = 16; i < 24; i++) {
704 x->block[i].zbin_extra = (short)zbin_extra; 839 x->block[i].zbin_extra = (int16_t)zbin_extra;
705 } 840 }
706 841
707 // Y2 842 // Y2
708 zbin_extra = (cpi->common.Y2dequant[QIndex][1] * 843 zbin_extra = (cpi->common.Y2dequant[QIndex][1] *
709 ((cpi->zbin_over_quant / 2) + 844 ((cpi->zbin_over_quant / 2) +
710 cpi->zbin_mode_boost + 845 cpi->zbin_mode_boost +
711 x->act_zbin_adj)) >> 7; 846 x->act_zbin_adj)) >> 7;
712 847
713 x->block[24].zbin_extra = (short)zbin_extra; 848 x->block[24].zbin_extra = (int16_t)zbin_extra;
714 } 849 }
715 850
716 void vp9_frame_init_quantizer(VP9_COMP *cpi) { 851 void vp9_frame_init_quantizer(VP9_COMP *cpi) {
717 // Clear Zbin mode boost for default case 852 // Clear Zbin mode boost for default case
718 cpi->zbin_mode_boost = 0; 853 cpi->zbin_mode_boost = 0;
719 854
720 // MB level quantizer setup 855 // MB level quantizer setup
721 vp9_mb_init_quantizer(cpi, &cpi->mb); 856 vp9_mb_init_quantizer(cpi, &cpi->mb);
722 } 857 }
723 858
724 void vp9_set_quantizer(struct VP9_COMP *cpi, int Q) { 859 void vp9_set_quantizer(struct VP9_COMP *cpi, int Q) {
725 VP9_COMMON *cm = &cpi->common; 860 VP9_COMMON *cm = &cpi->common;
726 861
727 cm->base_qindex = Q; 862 cm->base_qindex = Q;
728 863
729 // if any of the delta_q values are changing update flag will 864 // if any of the delta_q values are changing update flag will
730 // have to be set. 865 // have to be set.
731 cm->y1dc_delta_q = 0; 866 cm->y1dc_delta_q = 0;
732 cm->y2ac_delta_q = 0; 867 cm->y2ac_delta_q = 0;
733 cm->uvdc_delta_q = 0; 868 cm->uvdc_delta_q = 0;
734 cm->uvac_delta_q = 0; 869 cm->uvac_delta_q = 0;
735 cm->y2dc_delta_q = 0; 870 cm->y2dc_delta_q = 0;
736 871
737 // quantizer has to be reinitialized if any delta_q changes. 872 // quantizer has to be reinitialized if any delta_q changes.
738 // As there are not any here for now this is inactive code. 873 // As there are not any here for now this is inactive code.
739 // if(update) 874 // if(update)
740 // vp9_init_quantizer(cpi); 875 // vp9_init_quantizer(cpi);
741 } 876 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_quantize.h ('k') | source/libvpx/vp9/encoder/vp9_ratectrl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698