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

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

Issue 668403002: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 2 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_encodemb.h ('k') | source/libvpx/vp9/encoder/vp9_encoder.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
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 for (r = 0; r < rows; r++) { 44 for (r = 0; r < rows; r++) {
45 for (c = 0; c < cols; c++) 45 for (c = 0; c < cols; c++)
46 diff[c] = src[c] - pred[c]; 46 diff[c] = src[c] - pred[c];
47 47
48 diff += diff_stride; 48 diff += diff_stride;
49 pred += pred_stride; 49 pred += pred_stride;
50 src += src_stride; 50 src += src_stride;
51 } 51 }
52 } 52 }
53 53
54 #if CONFIG_VP9_HIGHBITDEPTH
55 void vp9_highbd_subtract_block_c(int rows, int cols,
56 int16_t *diff, ptrdiff_t diff_stride,
57 const uint8_t *src8, ptrdiff_t src_stride,
58 const uint8_t *pred8, ptrdiff_t pred_stride,
59 int bd) {
60 int r, c;
61 uint16_t *src = CONVERT_TO_SHORTPTR(src8);
62 uint16_t *pred = CONVERT_TO_SHORTPTR(pred8);
63 (void) bd;
64
65 for (r = 0; r < rows; r++) {
66 for (c = 0; c < cols; c++) {
67 diff[c] = src[c] - pred[c];
68 }
69
70 diff += diff_stride;
71 pred += pred_stride;
72 src += src_stride;
73 }
74 }
75 #endif // CONFIG_VP9_HIGHBITDEPTH
76
54 void vp9_subtract_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) { 77 void vp9_subtract_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) {
55 struct macroblock_plane *const p = &x->plane[plane]; 78 struct macroblock_plane *const p = &x->plane[plane];
56 const struct macroblockd_plane *const pd = &x->e_mbd.plane[plane]; 79 const struct macroblockd_plane *const pd = &x->e_mbd.plane[plane];
57 const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd); 80 const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
58 const int bw = 4 * num_4x4_blocks_wide_lookup[plane_bsize]; 81 const int bw = 4 * num_4x4_blocks_wide_lookup[plane_bsize];
59 const int bh = 4 * num_4x4_blocks_high_lookup[plane_bsize]; 82 const int bh = 4 * num_4x4_blocks_high_lookup[plane_bsize];
60 83
84 #if CONFIG_VP9_HIGHBITDEPTH
85 if (x->e_mbd.cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
86 vp9_highbd_subtract_block(bh, bw, p->src_diff, bw, p->src.buf,
87 p->src.stride, pd->dst.buf, pd->dst.stride,
88 x->e_mbd.bd);
89 return;
90 }
91 #endif // CONFIG_VP9_HIGHBITDEPTH
61 vp9_subtract_block(bh, bw, p->src_diff, bw, p->src.buf, p->src.stride, 92 vp9_subtract_block(bh, bw, p->src_diff, bw, p->src.buf, p->src.stride,
62 pd->dst.buf, pd->dst.stride); 93 pd->dst.buf, pd->dst.stride);
63 } 94 }
64 95
65 #define RDTRUNC(RM, DM, R, D) ((128 + (R) * (RM)) & 0xFF) 96 #define RDTRUNC(RM, DM, R, D) ((128 + (R) * (RM)) & 0xFF)
66 97
67 typedef struct vp9_token_state { 98 typedef struct vp9_token_state {
68 int rate; 99 int rate;
69 int error; 100 int error;
70 int next; 101 int next;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 const int16_t *dequant_ptr = pd->dequant; 148 const int16_t *dequant_ptr = pd->dequant;
118 const uint8_t *const band_translate = get_band_translate(tx_size); 149 const uint8_t *const band_translate = get_band_translate(tx_size);
119 const scan_order *const so = get_scan(xd, tx_size, type, block); 150 const scan_order *const so = get_scan(xd, tx_size, type, block);
120 const int16_t *const scan = so->scan; 151 const int16_t *const scan = so->scan;
121 const int16_t *const nb = so->neighbors; 152 const int16_t *const nb = so->neighbors;
122 int next = eob, sz = 0; 153 int next = eob, sz = 0;
123 int64_t rdmult = mb->rdmult * plane_rd_mult[type], rddiv = mb->rddiv; 154 int64_t rdmult = mb->rdmult * plane_rd_mult[type], rddiv = mb->rddiv;
124 int64_t rd_cost0, rd_cost1; 155 int64_t rd_cost0, rd_cost1;
125 int rate0, rate1, error0, error1, t0, t1; 156 int rate0, rate1, error0, error1, t0, t1;
126 int best, band, pt, i, final_eob; 157 int best, band, pt, i, final_eob;
158 const TOKENVALUE *dct_value_tokens;
159 const int16_t *dct_value_cost;
127 160
128 assert((!type && !plane) || (type && plane)); 161 assert((!type && !plane) || (type && plane));
129 assert(eob <= default_eob); 162 assert(eob <= default_eob);
130 163
131 /* Now set up a Viterbi trellis to evaluate alternative roundings. */ 164 /* Now set up a Viterbi trellis to evaluate alternative roundings. */
132 if (!ref) 165 if (!ref)
133 rdmult = (rdmult * 9) >> 4; 166 rdmult = (rdmult * 9) >> 4;
134 167
135 /* Initialize the sentinel node of the trellis. */ 168 /* Initialize the sentinel node of the trellis. */
136 tokens[eob][0].rate = 0; 169 tokens[eob][0].rate = 0;
137 tokens[eob][0].error = 0; 170 tokens[eob][0].error = 0;
138 tokens[eob][0].next = default_eob; 171 tokens[eob][0].next = default_eob;
139 tokens[eob][0].token = EOB_TOKEN; 172 tokens[eob][0].token = EOB_TOKEN;
140 tokens[eob][0].qc = 0; 173 tokens[eob][0].qc = 0;
141 tokens[eob][1] = tokens[eob][0]; 174 tokens[eob][1] = tokens[eob][0];
142 175
176 #if CONFIG_VP9_HIGHBITDEPTH
177 if (xd->bd == 12) {
178 dct_value_tokens = vp9_dct_value_tokens_high12_ptr;
179 dct_value_cost = vp9_dct_value_cost_high12_ptr;
180 } else if (xd->bd == 10) {
181 dct_value_tokens = vp9_dct_value_tokens_high10_ptr;
182 dct_value_cost = vp9_dct_value_cost_high10_ptr;
183 } else {
184 dct_value_tokens = vp9_dct_value_tokens_ptr;
185 dct_value_cost = vp9_dct_value_cost_ptr;
186 }
187 #else
188 dct_value_tokens = vp9_dct_value_tokens_ptr;
189 dct_value_cost = vp9_dct_value_cost_ptr;
190 #endif
143 for (i = 0; i < eob; i++) 191 for (i = 0; i < eob; i++)
144 token_cache[scan[i]] = 192 token_cache[scan[i]] =
145 vp9_pt_energy_class[vp9_dct_value_tokens_ptr[qcoeff[scan[i]]].token]; 193 vp9_pt_energy_class[dct_value_tokens[qcoeff[scan[i]]].token];
146 194
147 for (i = eob; i-- > 0;) { 195 for (i = eob; i-- > 0;) {
148 int base_bits, d2, dx; 196 int base_bits, d2, dx;
149 const int rc = scan[i]; 197 const int rc = scan[i];
150 int x = qcoeff[rc]; 198 int x = qcoeff[rc];
151 /* Only add a trellis state for non-zero coefficients. */ 199 /* Only add a trellis state for non-zero coefficients. */
152 if (x) { 200 if (x) {
153 int shortcut = 0; 201 int shortcut = 0;
154 error0 = tokens[next][0].error; 202 error0 = tokens[next][0].error;
155 error1 = tokens[next][1].error; 203 error1 = tokens[next][1].error;
156 /* Evaluate the first possibility for this state. */ 204 /* Evaluate the first possibility for this state. */
157 rate0 = tokens[next][0].rate; 205 rate0 = tokens[next][0].rate;
158 rate1 = tokens[next][1].rate; 206 rate1 = tokens[next][1].rate;
159 t0 = (vp9_dct_value_tokens_ptr + x)->token; 207 t0 = (dct_value_tokens + x)->token;
160 /* Consider both possible successor states. */ 208 /* Consider both possible successor states. */
161 if (next < default_eob) { 209 if (next < default_eob) {
162 band = band_translate[i + 1]; 210 band = band_translate[i + 1];
163 pt = trellis_get_coeff_context(scan, nb, i, t0, token_cache); 211 pt = trellis_get_coeff_context(scan, nb, i, t0, token_cache);
164 rate0 += mb->token_costs[tx_size][type][ref][band][0][pt] 212 rate0 += mb->token_costs[tx_size][type][ref][band][0][pt]
165 [tokens[next][0].token]; 213 [tokens[next][0].token];
166 rate1 += mb->token_costs[tx_size][type][ref][band][0][pt] 214 rate1 += mb->token_costs[tx_size][type][ref][band][0][pt]
167 [tokens[next][1].token]; 215 [tokens[next][1].token];
168 } 216 }
169 UPDATE_RD_COST(); 217 UPDATE_RD_COST();
170 /* And pick the best. */ 218 /* And pick the best. */
171 best = rd_cost1 < rd_cost0; 219 best = rd_cost1 < rd_cost0;
172 base_bits = vp9_dct_value_cost_ptr[x]; 220 base_bits = dct_value_cost[x];
173 dx = mul * (dqcoeff[rc] - coeff[rc]); 221 dx = mul * (dqcoeff[rc] - coeff[rc]);
222 #if CONFIG_VP9_HIGHBITDEPTH
223 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
224 dx >>= xd->bd - 8;
225 }
226 #endif // CONFIG_VP9_HIGHBITDEPTH
174 d2 = dx * dx; 227 d2 = dx * dx;
175 tokens[i][0].rate = base_bits + (best ? rate1 : rate0); 228 tokens[i][0].rate = base_bits + (best ? rate1 : rate0);
176 tokens[i][0].error = d2 + (best ? error1 : error0); 229 tokens[i][0].error = d2 + (best ? error1 : error0);
177 tokens[i][0].next = next; 230 tokens[i][0].next = next;
178 tokens[i][0].token = t0; 231 tokens[i][0].token = t0;
179 tokens[i][0].qc = x; 232 tokens[i][0].qc = x;
180 best_index[i][0] = best; 233 best_index[i][0] = best;
181 234
182 /* Evaluate the second possibility for this state. */ 235 /* Evaluate the second possibility for this state. */
183 rate0 = tokens[next][0].rate; 236 rate0 = tokens[next][0].rate;
(...skipping 12 matching lines...) Expand all
196 } 249 }
197 250
198 /* Consider both possible successor states. */ 251 /* Consider both possible successor states. */
199 if (!x) { 252 if (!x) {
200 /* If we reduced this coefficient to zero, check to see if 253 /* If we reduced this coefficient to zero, check to see if
201 * we need to move the EOB back here. 254 * we need to move the EOB back here.
202 */ 255 */
203 t0 = tokens[next][0].token == EOB_TOKEN ? EOB_TOKEN : ZERO_TOKEN; 256 t0 = tokens[next][0].token == EOB_TOKEN ? EOB_TOKEN : ZERO_TOKEN;
204 t1 = tokens[next][1].token == EOB_TOKEN ? EOB_TOKEN : ZERO_TOKEN; 257 t1 = tokens[next][1].token == EOB_TOKEN ? EOB_TOKEN : ZERO_TOKEN;
205 } else { 258 } else {
206 t0 = t1 = (vp9_dct_value_tokens_ptr + x)->token; 259 t0 = t1 = (dct_value_tokens + x)->token;
207 } 260 }
208 if (next < default_eob) { 261 if (next < default_eob) {
209 band = band_translate[i + 1]; 262 band = band_translate[i + 1];
210 if (t0 != EOB_TOKEN) { 263 if (t0 != EOB_TOKEN) {
211 pt = trellis_get_coeff_context(scan, nb, i, t0, token_cache); 264 pt = trellis_get_coeff_context(scan, nb, i, t0, token_cache);
212 rate0 += mb->token_costs[tx_size][type][ref][band][!x][pt] 265 rate0 += mb->token_costs[tx_size][type][ref][band][!x][pt]
213 [tokens[next][0].token]; 266 [tokens[next][0].token];
214 } 267 }
215 if (t1 != EOB_TOKEN) { 268 if (t1 != EOB_TOKEN) {
216 pt = trellis_get_coeff_context(scan, nb, i, t1, token_cache); 269 pt = trellis_get_coeff_context(scan, nb, i, t1, token_cache);
217 rate1 += mb->token_costs[tx_size][type][ref][band][!x][pt] 270 rate1 += mb->token_costs[tx_size][type][ref][band][!x][pt]
218 [tokens[next][1].token]; 271 [tokens[next][1].token];
219 } 272 }
220 } 273 }
221 274
222 UPDATE_RD_COST(); 275 UPDATE_RD_COST();
223 /* And pick the best. */ 276 /* And pick the best. */
224 best = rd_cost1 < rd_cost0; 277 best = rd_cost1 < rd_cost0;
225 base_bits = vp9_dct_value_cost_ptr[x]; 278 base_bits = dct_value_cost[x];
226 279
227 if (shortcut) { 280 if (shortcut) {
281 #if CONFIG_VP9_HIGHBITDEPTH
282 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
283 dx -= ((dequant_ptr[rc != 0] >> (xd->bd - 8)) + sz) ^ sz;
284 } else {
285 dx -= (dequant_ptr[rc != 0] + sz) ^ sz;
286 }
287 #else
228 dx -= (dequant_ptr[rc != 0] + sz) ^ sz; 288 dx -= (dequant_ptr[rc != 0] + sz) ^ sz;
289 #endif // CONFIG_VP9_HIGHBITDEPTH
229 d2 = dx * dx; 290 d2 = dx * dx;
230 } 291 }
231 tokens[i][1].rate = base_bits + (best ? rate1 : rate0); 292 tokens[i][1].rate = base_bits + (best ? rate1 : rate0);
232 tokens[i][1].error = d2 + (best ? error1 : error0); 293 tokens[i][1].error = d2 + (best ? error1 : error0);
233 tokens[i][1].next = next; 294 tokens[i][1].next = next;
234 tokens[i][1].token = best ? t1 : t0; 295 tokens[i][1].token = best ? t1 : t0;
235 tokens[i][1].qc = x; 296 tokens[i][1].qc = x;
236 best_index[i][1] = best; 297 best_index[i][1] = best;
237 /* Finally, make this the new head of the trellis. */ 298 /* Finally, make this the new head of the trellis. */
238 next = i; 299 next = i;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 static INLINE void fdct32x32(int rd_transform, 357 static INLINE void fdct32x32(int rd_transform,
297 const int16_t *src, tran_low_t *dst, 358 const int16_t *src, tran_low_t *dst,
298 int src_stride) { 359 int src_stride) {
299 if (rd_transform) 360 if (rd_transform)
300 vp9_fdct32x32_rd(src, dst, src_stride); 361 vp9_fdct32x32_rd(src, dst, src_stride);
301 else 362 else
302 vp9_fdct32x32(src, dst, src_stride); 363 vp9_fdct32x32(src, dst, src_stride);
303 } 364 }
304 365
305 #if CONFIG_VP9_HIGHBITDEPTH 366 #if CONFIG_VP9_HIGHBITDEPTH
306 static INLINE void high_fdct32x32(int rd_transform, const int16_t *src, 367 static INLINE void highbd_fdct32x32(int rd_transform, const int16_t *src,
307 tran_low_t *dst, int src_stride) { 368 tran_low_t *dst, int src_stride) {
308 if (rd_transform) 369 if (rd_transform)
309 vp9_high_fdct32x32_rd(src, dst, src_stride); 370 vp9_highbd_fdct32x32_rd(src, dst, src_stride);
310 else 371 else
311 vp9_high_fdct32x32(src, dst, src_stride); 372 vp9_highbd_fdct32x32(src, dst, src_stride);
312 } 373 }
313 #endif 374 #endif // CONFIG_VP9_HIGHBITDEPTH
314 375
315 void vp9_xform_quant_fp(MACROBLOCK *x, int plane, int block, 376 void vp9_xform_quant_fp(MACROBLOCK *x, int plane, int block,
316 BLOCK_SIZE plane_bsize, TX_SIZE tx_size) { 377 BLOCK_SIZE plane_bsize, TX_SIZE tx_size) {
317 MACROBLOCKD *const xd = &x->e_mbd; 378 MACROBLOCKD *const xd = &x->e_mbd;
318 const struct macroblock_plane *const p = &x->plane[plane]; 379 const struct macroblock_plane *const p = &x->plane[plane];
319 const struct macroblockd_plane *const pd = &xd->plane[plane]; 380 const struct macroblockd_plane *const pd = &xd->plane[plane];
320 const scan_order *const scan_order = &vp9_default_scan_orders[tx_size]; 381 const scan_order *const scan_order = &vp9_default_scan_orders[tx_size];
321 tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block); 382 tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
322 tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block); 383 tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
323 tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); 384 tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
324 uint16_t *const eob = &p->eobs[block]; 385 uint16_t *const eob = &p->eobs[block];
325 const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize]; 386 const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize];
326 int i, j; 387 int i, j;
327 const int16_t *src_diff; 388 const int16_t *src_diff;
328 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j); 389 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j);
329 src_diff = &p->src_diff[4 * (j * diff_stride + i)]; 390 src_diff = &p->src_diff[4 * (j * diff_stride + i)];
330 391
392 #if CONFIG_VP9_HIGHBITDEPTH
393 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
394 switch (tx_size) {
395 case TX_32X32:
396 highbd_fdct32x32(x->use_lp32x32fdct, src_diff, coeff, diff_stride);
397 vp9_highbd_quantize_fp_32x32(coeff, 1024, x->skip_block, p->zbin,
398 p->round_fp, p->quant_fp, p->quant_shift,
399 qcoeff, dqcoeff, pd->dequant,
400 p->zbin_extra, eob, scan_order->scan,
401 scan_order->iscan);
402 break;
403 case TX_16X16:
404 vp9_highbd_fdct16x16(src_diff, coeff, diff_stride);
405 vp9_highbd_quantize_fp(coeff, 256, x->skip_block, p->zbin, p->round_fp,
406 p->quant_fp, p->quant_shift, qcoeff, dqcoeff,
407 pd->dequant, p->zbin_extra, eob,
408 scan_order->scan, scan_order->iscan);
409 break;
410 case TX_8X8:
411 vp9_highbd_fdct8x8(src_diff, coeff, diff_stride);
412 vp9_highbd_quantize_fp(coeff, 64, x->skip_block, p->zbin, p->round_fp,
413 p->quant_fp, p->quant_shift, qcoeff, dqcoeff,
414 pd->dequant, p->zbin_extra, eob,
415 scan_order->scan, scan_order->iscan);
416 break;
417 case TX_4X4:
418 x->fwd_txm4x4(src_diff, coeff, diff_stride);
419 vp9_highbd_quantize_fp(coeff, 16, x->skip_block, p->zbin, p->round_fp,
420 p->quant_fp, p->quant_shift, qcoeff, dqcoeff,
421 pd->dequant, p->zbin_extra, eob,
422 scan_order->scan, scan_order->iscan);
423 break;
424 default:
425 assert(0);
426 }
427 return;
428 }
429 #endif // CONFIG_VP9_HIGHBITDEPTH
430
331 switch (tx_size) { 431 switch (tx_size) {
332 case TX_32X32: 432 case TX_32X32:
333 fdct32x32(x->use_lp32x32fdct, src_diff, coeff, diff_stride); 433 fdct32x32(x->use_lp32x32fdct, src_diff, coeff, diff_stride);
334 vp9_quantize_fp_32x32(coeff, 1024, x->skip_block, p->zbin, p->round_fp, 434 vp9_quantize_fp_32x32(coeff, 1024, x->skip_block, p->zbin, p->round_fp,
335 p->quant_fp, p->quant_shift, qcoeff, dqcoeff, 435 p->quant_fp, p->quant_shift, qcoeff, dqcoeff,
336 pd->dequant, p->zbin_extra, eob, scan_order->scan, 436 pd->dequant, p->zbin_extra, eob, scan_order->scan,
337 scan_order->iscan); 437 scan_order->iscan);
338 break; 438 break;
339 case TX_16X16: 439 case TX_16X16:
340 vp9_fdct16x16(src_diff, coeff, diff_stride); 440 vp9_fdct16x16(src_diff, coeff, diff_stride);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block); 472 tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
373 tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); 473 tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
374 uint16_t *const eob = &p->eobs[block]; 474 uint16_t *const eob = &p->eobs[block];
375 const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize]; 475 const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize];
376 int i, j; 476 int i, j;
377 const int16_t *src_diff; 477 const int16_t *src_diff;
378 478
379 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j); 479 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j);
380 src_diff = &p->src_diff[4 * (j * diff_stride + i)]; 480 src_diff = &p->src_diff[4 * (j * diff_stride + i)];
381 481
482 #if CONFIG_VP9_HIGHBITDEPTH
483 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
484 switch (tx_size) {
485 case TX_32X32:
486 vp9_highbd_fdct32x32_1(src_diff, coeff, diff_stride);
487 vp9_highbd_quantize_dc_32x32(coeff, x->skip_block, p->round,
488 p->quant_fp[0], qcoeff, dqcoeff,
489 pd->dequant[0], eob);
490 break;
491 case TX_16X16:
492 vp9_highbd_fdct16x16_1(src_diff, coeff, diff_stride);
493 vp9_highbd_quantize_dc(coeff, x->skip_block, p->round,
494 p->quant_fp[0], qcoeff, dqcoeff,
495 pd->dequant[0], eob);
496 break;
497 case TX_8X8:
498 vp9_highbd_fdct8x8_1(src_diff, coeff, diff_stride);
499 vp9_highbd_quantize_dc(coeff, x->skip_block, p->round,
500 p->quant_fp[0], qcoeff, dqcoeff,
501 pd->dequant[0], eob);
502 break;
503 case TX_4X4:
504 x->fwd_txm4x4(src_diff, coeff, diff_stride);
505 vp9_highbd_quantize_dc(coeff, x->skip_block, p->round,
506 p->quant_fp[0], qcoeff, dqcoeff,
507 pd->dequant[0], eob);
508 break;
509 default:
510 assert(0);
511 }
512 return;
513 }
514 #endif // CONFIG_VP9_HIGHBITDEPTH
515
382 switch (tx_size) { 516 switch (tx_size) {
383 case TX_32X32: 517 case TX_32X32:
384 vp9_fdct32x32_1(src_diff, coeff, diff_stride); 518 vp9_fdct32x32_1(src_diff, coeff, diff_stride);
385 vp9_quantize_dc_32x32(coeff, x->skip_block, p->round, 519 vp9_quantize_dc_32x32(coeff, x->skip_block, p->round,
386 p->quant_fp[0], qcoeff, dqcoeff, 520 p->quant_fp[0], qcoeff, dqcoeff,
387 pd->dequant[0], eob); 521 pd->dequant[0], eob);
388 break; 522 break;
389 case TX_16X16: 523 case TX_16X16:
390 vp9_fdct16x16_1(src_diff, coeff, diff_stride); 524 vp9_fdct16x16_1(src_diff, coeff, diff_stride);
391 vp9_quantize_dc(coeff, x->skip_block, p->round, 525 vp9_quantize_dc(coeff, x->skip_block, p->round,
(...skipping 27 matching lines...) Expand all
419 tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block); 553 tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
420 tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block); 554 tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
421 tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); 555 tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
422 uint16_t *const eob = &p->eobs[block]; 556 uint16_t *const eob = &p->eobs[block];
423 const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize]; 557 const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize];
424 int i, j; 558 int i, j;
425 const int16_t *src_diff; 559 const int16_t *src_diff;
426 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j); 560 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j);
427 src_diff = &p->src_diff[4 * (j * diff_stride + i)]; 561 src_diff = &p->src_diff[4 * (j * diff_stride + i)];
428 562
563 #if CONFIG_VP9_HIGHBITDEPTH
564 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
565 switch (tx_size) {
566 case TX_32X32:
567 highbd_fdct32x32(x->use_lp32x32fdct, src_diff, coeff, diff_stride);
568 vp9_highbd_quantize_b_32x32(coeff, 1024, x->skip_block, p->zbin,
569 p->round, p->quant, p->quant_shift, qcoeff,
570 dqcoeff, pd->dequant, p->zbin_extra, eob,
571 scan_order->scan, scan_order->iscan);
572 break;
573 case TX_16X16:
574 vp9_highbd_fdct16x16(src_diff, coeff, diff_stride);
575 vp9_highbd_quantize_b(coeff, 256, x->skip_block, p->zbin, p->round,
576 p->quant, p->quant_shift, qcoeff, dqcoeff,
577 pd->dequant, p->zbin_extra, eob,
578 scan_order->scan, scan_order->iscan);
579 break;
580 case TX_8X8:
581 vp9_highbd_fdct8x8(src_diff, coeff, diff_stride);
582 vp9_highbd_quantize_b(coeff, 64, x->skip_block, p->zbin, p->round,
583 p->quant, p->quant_shift, qcoeff, dqcoeff,
584 pd->dequant, p->zbin_extra, eob,
585 scan_order->scan, scan_order->iscan);
586 break;
587 case TX_4X4:
588 x->fwd_txm4x4(src_diff, coeff, diff_stride);
589 vp9_highbd_quantize_b(coeff, 16, x->skip_block, p->zbin, p->round,
590 p->quant, p->quant_shift, qcoeff, dqcoeff,
591 pd->dequant, p->zbin_extra, eob,
592 scan_order->scan, scan_order->iscan);
593 break;
594 default:
595 assert(0);
596 }
597 return;
598 }
599 #endif // CONFIG_VP9_HIGHBITDEPTH
600
429 switch (tx_size) { 601 switch (tx_size) {
430 case TX_32X32: 602 case TX_32X32:
431 fdct32x32(x->use_lp32x32fdct, src_diff, coeff, diff_stride); 603 fdct32x32(x->use_lp32x32fdct, src_diff, coeff, diff_stride);
432 vp9_quantize_b_32x32(coeff, 1024, x->skip_block, p->zbin, p->round, 604 vp9_quantize_b_32x32(coeff, 1024, x->skip_block, p->zbin, p->round,
433 p->quant, p->quant_shift, qcoeff, dqcoeff, 605 p->quant, p->quant_shift, qcoeff, dqcoeff,
434 pd->dequant, p->zbin_extra, eob, scan_order->scan, 606 pd->dequant, p->zbin_extra, eob, scan_order->scan,
435 scan_order->iscan); 607 scan_order->iscan);
436 break; 608 break;
437 case TX_16X16: 609 case TX_16X16:
438 vp9_fdct16x16(src_diff, coeff, diff_stride); 610 vp9_fdct16x16(src_diff, coeff, diff_stride);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 *a = *l = optimize_b(x, plane, block, tx_size, ctx) > 0; 685 *a = *l = optimize_b(x, plane, block, tx_size, ctx) > 0;
514 } else { 686 } else {
515 *a = *l = p->eobs[block] > 0; 687 *a = *l = p->eobs[block] > 0;
516 } 688 }
517 689
518 if (p->eobs[block]) 690 if (p->eobs[block])
519 *(args->skip) = 0; 691 *(args->skip) = 0;
520 692
521 if (x->skip_encode || p->eobs[block] == 0) 693 if (x->skip_encode || p->eobs[block] == 0)
522 return; 694 return;
695 #if CONFIG_VP9_HIGHBITDEPTH
696 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
697 switch (tx_size) {
698 case TX_32X32:
699 vp9_highbd_idct32x32_add(dqcoeff, dst, pd->dst.stride,
700 p->eobs[block], xd->bd);
701 break;
702 case TX_16X16:
703 vp9_highbd_idct16x16_add(dqcoeff, dst, pd->dst.stride,
704 p->eobs[block], xd->bd);
705 break;
706 case TX_8X8:
707 vp9_highbd_idct8x8_add(dqcoeff, dst, pd->dst.stride,
708 p->eobs[block], xd->bd);
709 break;
710 case TX_4X4:
711 // this is like vp9_short_idct4x4 but has a special case around eob<=1
712 // which is significant (not just an optimization) for the lossless
713 // case.
714 x->highbd_itxm_add(dqcoeff, dst, pd->dst.stride,
715 p->eobs[block], xd->bd);
716 break;
717 default:
718 assert(0 && "Invalid transform size");
719 }
720 return;
721 }
722 #endif // CONFIG_VP9_HIGHBITDEPTH
523 723
524 switch (tx_size) { 724 switch (tx_size) {
525 case TX_32X32: 725 case TX_32X32:
526 vp9_idct32x32_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]); 726 vp9_idct32x32_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]);
527 break; 727 break;
528 case TX_16X16: 728 case TX_16X16:
529 vp9_idct16x16_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]); 729 vp9_idct16x16_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]);
530 break; 730 break;
531 case TX_8X8: 731 case TX_8X8:
532 vp9_idct8x8_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]); 732 vp9_idct8x8_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]);
(...skipping 17 matching lines...) Expand all
550 struct macroblock_plane *const p = &x->plane[plane]; 750 struct macroblock_plane *const p = &x->plane[plane];
551 struct macroblockd_plane *const pd = &xd->plane[plane]; 751 struct macroblockd_plane *const pd = &xd->plane[plane];
552 tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); 752 tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
553 int i, j; 753 int i, j;
554 uint8_t *dst; 754 uint8_t *dst;
555 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j); 755 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j);
556 dst = &pd->dst.buf[4 * j * pd->dst.stride + 4 * i]; 756 dst = &pd->dst.buf[4 * j * pd->dst.stride + 4 * i];
557 757
558 vp9_xform_quant(x, plane, block, plane_bsize, tx_size); 758 vp9_xform_quant(x, plane, block, plane_bsize, tx_size);
559 759
560 if (p->eobs[block] > 0) 760 if (p->eobs[block] > 0) {
761 #if CONFIG_VP9_HIGHBITDEPTH
762 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
763 x->highbd_itxm_add(dqcoeff, dst, pd->dst.stride, p->eobs[block], xd->bd);
764 return;
765 }
766 #endif // CONFIG_VP9_HIGHBITDEPTH
561 x->itxm_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]); 767 x->itxm_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]);
768 }
562 } 769 }
563 770
564 void vp9_encode_sby_pass1(MACROBLOCK *x, BLOCK_SIZE bsize) { 771 void vp9_encode_sby_pass1(MACROBLOCK *x, BLOCK_SIZE bsize) {
565 vp9_subtract_plane(x, bsize, 0); 772 vp9_subtract_plane(x, bsize, 0);
566 vp9_foreach_transformed_block_in_plane(&x->e_mbd, bsize, 0, 773 vp9_foreach_transformed_block_in_plane(&x->e_mbd, bsize, 0,
567 encode_block_pass1, x); 774 encode_block_pass1, x);
568 } 775 }
569 776
570 void vp9_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize) { 777 void vp9_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize) {
571 MACROBLOCKD *const xd = &x->e_mbd; 778 MACROBLOCKD *const xd = &x->e_mbd;
(...skipping 30 matching lines...) Expand all
602 MACROBLOCKD *const xd = &x->e_mbd; 809 MACROBLOCKD *const xd = &x->e_mbd;
603 MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi; 810 MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi;
604 struct macroblock_plane *const p = &x->plane[plane]; 811 struct macroblock_plane *const p = &x->plane[plane];
605 struct macroblockd_plane *const pd = &xd->plane[plane]; 812 struct macroblockd_plane *const pd = &xd->plane[plane];
606 tran_low_t *coeff = BLOCK_OFFSET(p->coeff, block); 813 tran_low_t *coeff = BLOCK_OFFSET(p->coeff, block);
607 tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block); 814 tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
608 tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); 815 tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
609 const scan_order *scan_order; 816 const scan_order *scan_order;
610 TX_TYPE tx_type; 817 TX_TYPE tx_type;
611 PREDICTION_MODE mode; 818 PREDICTION_MODE mode;
612 const int bwl = b_width_log2(plane_bsize); 819 const int bwl = b_width_log2_lookup[plane_bsize];
613 const int diff_stride = 4 * (1 << bwl); 820 const int diff_stride = 4 * (1 << bwl);
614 uint8_t *src, *dst; 821 uint8_t *src, *dst;
615 int16_t *src_diff; 822 int16_t *src_diff;
616 uint16_t *eob = &p->eobs[block]; 823 uint16_t *eob = &p->eobs[block];
617 const int src_stride = p->src.stride; 824 const int src_stride = p->src.stride;
618 const int dst_stride = pd->dst.stride; 825 const int dst_stride = pd->dst.stride;
619 int i, j; 826 int i, j;
620 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j); 827 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j);
621 dst = &pd->dst.buf[4 * (j * dst_stride + i)]; 828 dst = &pd->dst.buf[4 * (j * dst_stride + i)];
622 src = &p->src.buf[4 * (j * src_stride + i)]; 829 src = &p->src.buf[4 * (j * src_stride + i)];
623 src_diff = &p->src_diff[4 * (j * diff_stride + i)]; 830 src_diff = &p->src_diff[4 * (j * diff_stride + i)];
624 831
832 #if CONFIG_VP9_HIGHBITDEPTH
833 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
834 switch (tx_size) {
835 case TX_32X32:
836 scan_order = &vp9_default_scan_orders[TX_32X32];
837 mode = plane == 0 ? mbmi->mode : mbmi->uv_mode;
838 vp9_predict_intra_block(xd, block >> 6, bwl, TX_32X32, mode,
839 x->skip_encode ? src : dst,
840 x->skip_encode ? src_stride : dst_stride,
841 dst, dst_stride, i, j, plane);
842 if (!x->skip_recode) {
843 vp9_highbd_subtract_block(32, 32, src_diff, diff_stride,
844 src, src_stride, dst, dst_stride, xd->bd);
845 highbd_fdct32x32(x->use_lp32x32fdct, src_diff, coeff, diff_stride);
846 vp9_highbd_quantize_b_32x32(coeff, 1024, x->skip_block, p->zbin,
847 p->round, p->quant, p->quant_shift,
848 qcoeff, dqcoeff, pd->dequant,
849 p->zbin_extra, eob,
850 scan_order->scan, scan_order->iscan);
851 }
852 if (!x->skip_encode && *eob) {
853 vp9_highbd_idct32x32_add(dqcoeff, dst, dst_stride, *eob, xd->bd);
854 }
855 break;
856 case TX_16X16:
857 tx_type = get_tx_type(pd->plane_type, xd);
858 scan_order = &vp9_scan_orders[TX_16X16][tx_type];
859 mode = plane == 0 ? mbmi->mode : mbmi->uv_mode;
860 vp9_predict_intra_block(xd, block >> 4, bwl, TX_16X16, mode,
861 x->skip_encode ? src : dst,
862 x->skip_encode ? src_stride : dst_stride,
863 dst, dst_stride, i, j, plane);
864 if (!x->skip_recode) {
865 vp9_highbd_subtract_block(16, 16, src_diff, diff_stride,
866 src, src_stride, dst, dst_stride, xd->bd);
867 vp9_highbd_fht16x16(src_diff, coeff, diff_stride, tx_type);
868 vp9_highbd_quantize_b(coeff, 256, x->skip_block, p->zbin, p->round,
869 p->quant, p->quant_shift, qcoeff, dqcoeff,
870 pd->dequant, p->zbin_extra, eob,
871 scan_order->scan, scan_order->iscan);
872 }
873 if (!x->skip_encode && *eob) {
874 vp9_highbd_iht16x16_add(tx_type, dqcoeff, dst, dst_stride,
875 *eob, xd->bd);
876 }
877 break;
878 case TX_8X8:
879 tx_type = get_tx_type(pd->plane_type, xd);
880 scan_order = &vp9_scan_orders[TX_8X8][tx_type];
881 mode = plane == 0 ? mbmi->mode : mbmi->uv_mode;
882 vp9_predict_intra_block(xd, block >> 2, bwl, TX_8X8, mode,
883 x->skip_encode ? src : dst,
884 x->skip_encode ? src_stride : dst_stride,
885 dst, dst_stride, i, j, plane);
886 if (!x->skip_recode) {
887 vp9_highbd_subtract_block(8, 8, src_diff, diff_stride,
888 src, src_stride, dst, dst_stride, xd->bd);
889 vp9_highbd_fht8x8(src_diff, coeff, diff_stride, tx_type);
890 vp9_highbd_quantize_b(coeff, 64, x->skip_block, p->zbin, p->round,
891 p->quant, p->quant_shift, qcoeff, dqcoeff,
892 pd->dequant, p->zbin_extra, eob,
893 scan_order->scan, scan_order->iscan);
894 }
895 if (!x->skip_encode && *eob) {
896 vp9_highbd_iht8x8_add(tx_type, dqcoeff, dst, dst_stride, *eob,
897 xd->bd);
898 }
899 break;
900 case TX_4X4:
901 tx_type = get_tx_type_4x4(pd->plane_type, xd, block);
902 scan_order = &vp9_scan_orders[TX_4X4][tx_type];
903 mode = plane == 0 ? get_y_mode(xd->mi[0].src_mi, block) : mbmi->uv_mode;
904 vp9_predict_intra_block(xd, block, bwl, TX_4X4, mode,
905 x->skip_encode ? src : dst,
906 x->skip_encode ? src_stride : dst_stride,
907 dst, dst_stride, i, j, plane);
908
909 if (!x->skip_recode) {
910 vp9_highbd_subtract_block(4, 4, src_diff, diff_stride,
911 src, src_stride, dst, dst_stride, xd->bd);
912 if (tx_type != DCT_DCT)
913 vp9_highbd_fht4x4(src_diff, coeff, diff_stride, tx_type);
914 else
915 x->fwd_txm4x4(src_diff, coeff, diff_stride);
916 vp9_highbd_quantize_b(coeff, 16, x->skip_block, p->zbin, p->round,
917 p->quant, p->quant_shift, qcoeff, dqcoeff,
918 pd->dequant, p->zbin_extra, eob,
919 scan_order->scan, scan_order->iscan);
920 }
921
922 if (!x->skip_encode && *eob) {
923 if (tx_type == DCT_DCT) {
924 // this is like vp9_short_idct4x4 but has a special case around
925 // eob<=1 which is significant (not just an optimization) for the
926 // lossless case.
927 x->highbd_itxm_add(dqcoeff, dst, dst_stride, *eob, xd->bd);
928 } else {
929 vp9_highbd_iht4x4_16_add(dqcoeff, dst, dst_stride, tx_type, xd->bd);
930 }
931 }
932 break;
933 default:
934 assert(0);
935 return;
936 }
937 if (*eob)
938 *(args->skip) = 0;
939 return;
940 }
941 #endif // CONFIG_VP9_HIGHBITDEPTH
942
625 switch (tx_size) { 943 switch (tx_size) {
626 case TX_32X32: 944 case TX_32X32:
627 scan_order = &vp9_default_scan_orders[TX_32X32]; 945 scan_order = &vp9_default_scan_orders[TX_32X32];
628 mode = plane == 0 ? mbmi->mode : mbmi->uv_mode; 946 mode = plane == 0 ? mbmi->mode : mbmi->uv_mode;
629 vp9_predict_intra_block(xd, block >> 6, bwl, TX_32X32, mode, 947 vp9_predict_intra_block(xd, block >> 6, bwl, TX_32X32, mode,
630 x->skip_encode ? src : dst, 948 x->skip_encode ? src : dst,
631 x->skip_encode ? src_stride : dst_stride, 949 x->skip_encode ? src_stride : dst_stride,
632 dst, dst_stride, i, j, plane); 950 dst, dst_stride, i, j, plane);
633 if (!x->skip_recode) { 951 if (!x->skip_recode) {
634 vp9_subtract_block(32, 32, src_diff, diff_stride, 952 vp9_subtract_block(32, 32, src_diff, diff_stride,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 } 1048 }
731 1049
732 1050
733 void vp9_encode_intra_block_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) { 1051 void vp9_encode_intra_block_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) {
734 const MACROBLOCKD *const xd = &x->e_mbd; 1052 const MACROBLOCKD *const xd = &x->e_mbd;
735 struct encode_b_args arg = {x, NULL, &xd->mi[0].src_mi->mbmi.skip}; 1053 struct encode_b_args arg = {x, NULL, &xd->mi[0].src_mi->mbmi.skip};
736 1054
737 vp9_foreach_transformed_block_in_plane(xd, bsize, plane, encode_block_intra, 1055 vp9_foreach_transformed_block_in_plane(xd, bsize, plane, encode_block_intra,
738 &arg); 1056 &arg);
739 } 1057 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_encodemb.h ('k') | source/libvpx/vp9/encoder/vp9_encoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698