Merge "Skip computation of distortion in vp8_pick_inter_mode if active_map is used"
[libvpx.git] / vp8 / decoder / dequantize.c
blobdd0c13b7dc1b6f9bb3b0c5d800f14eb8de1b82c2
1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
12 #include "vpx_ports/config.h"
13 #include "dequantize.h"
14 #include "vp8/common/idct.h"
15 #include "vpx_mem/vpx_mem.h"
17 extern void vp8_short_idct4x4llm_c(short *input, short *output, int pitch) ;
18 extern void vp8_short_idct4x4llm_1_c(short *input, short *output, int pitch);
21 void vp8_dequantize_b_c(BLOCKD *d)
23 int i;
24 short *DQ = d->dqcoeff;
25 short *Q = d->qcoeff;
26 short *DQC = d->dequant;
28 for (i = 0; i < 16; i++)
30 DQ[i] = Q[i] * DQC[i];
34 void vp8_dequant_idct_add_c(short *input, short *dq, unsigned char *pred,
35 unsigned char *dest, int pitch, int stride)
37 short output[16];
38 short *diff_ptr = output;
39 int r, c;
40 int i;
42 for (i = 0; i < 16; i++)
44 input[i] = dq[i] * input[i];
47 /* the idct halves ( >> 1) the pitch */
48 vp8_short_idct4x4llm_c(input, output, 4 << 1);
50 vpx_memset(input, 0, 32);
52 for (r = 0; r < 4; r++)
54 for (c = 0; c < 4; c++)
56 int a = diff_ptr[c] + pred[c];
58 if (a < 0)
59 a = 0;
61 if (a > 255)
62 a = 255;
64 dest[c] = (unsigned char) a;
67 dest += stride;
68 diff_ptr += 4;
69 pred += pitch;
73 void vp8_dequant_dc_idct_add_c(short *input, short *dq, unsigned char *pred,
74 unsigned char *dest, int pitch, int stride,
75 int Dc)
77 int i;
78 short output[16];
79 short *diff_ptr = output;
80 int r, c;
82 input[0] = (short)Dc;
84 for (i = 1; i < 16; i++)
86 input[i] = dq[i] * input[i];
89 /* the idct halves ( >> 1) the pitch */
90 vp8_short_idct4x4llm_c(input, output, 4 << 1);
92 vpx_memset(input, 0, 32);
94 for (r = 0; r < 4; r++)
96 for (c = 0; c < 4; c++)
98 int a = diff_ptr[c] + pred[c];
100 if (a < 0)
101 a = 0;
103 if (a > 255)
104 a = 255;
106 dest[c] = (unsigned char) a;
109 dest += stride;
110 diff_ptr += 4;
111 pred += pitch;