1 : /*
2 : * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 : *
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 : */
10 :
11 :
12 : #include "vpx_ports/config.h"
13 : #include "dequantize.h"
14 : #include "vp8/common/idct.h"
15 : #include "vpx_mem/vpx_mem.h"
16 :
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);
19 :
20 :
21 0 : void vp8_dequantize_b_c(BLOCKD *d)
22 : {
23 : int i;
24 0 : short *DQ = d->dqcoeff;
25 0 : short *Q = d->qcoeff;
26 0 : short *DQC = d->dequant;
27 :
28 0 : for (i = 0; i < 16; i++)
29 : {
30 0 : DQ[i] = Q[i] * DQC[i];
31 : }
32 0 : }
33 :
34 0 : void vp8_dequant_idct_add_c(short *input, short *dq, unsigned char *pred,
35 : unsigned char *dest, int pitch, int stride)
36 : {
37 : short output[16];
38 0 : short *diff_ptr = output;
39 : int r, c;
40 : int i;
41 :
42 0 : for (i = 0; i < 16; i++)
43 : {
44 0 : input[i] = dq[i] * input[i];
45 : }
46 :
47 : /* the idct halves ( >> 1) the pitch */
48 0 : vp8_short_idct4x4llm_c(input, output, 4 << 1);
49 :
50 0 : vpx_memset(input, 0, 32);
51 :
52 0 : for (r = 0; r < 4; r++)
53 : {
54 0 : for (c = 0; c < 4; c++)
55 : {
56 0 : int a = diff_ptr[c] + pred[c];
57 :
58 0 : if (a < 0)
59 0 : a = 0;
60 :
61 0 : if (a > 255)
62 0 : a = 255;
63 :
64 0 : dest[c] = (unsigned char) a;
65 : }
66 :
67 0 : dest += stride;
68 0 : diff_ptr += 4;
69 0 : pred += pitch;
70 : }
71 0 : }
72 :
73 0 : 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)
76 : {
77 : int i;
78 : short output[16];
79 0 : short *diff_ptr = output;
80 : int r, c;
81 :
82 0 : input[0] = (short)Dc;
83 :
84 0 : for (i = 1; i < 16; i++)
85 : {
86 0 : input[i] = dq[i] * input[i];
87 : }
88 :
89 : /* the idct halves ( >> 1) the pitch */
90 0 : vp8_short_idct4x4llm_c(input, output, 4 << 1);
91 :
92 0 : vpx_memset(input, 0, 32);
93 :
94 0 : for (r = 0; r < 4; r++)
95 : {
96 0 : for (c = 0; c < 4; c++)
97 : {
98 0 : int a = diff_ptr[c] + pred[c];
99 :
100 0 : if (a < 0)
101 0 : a = 0;
102 :
103 0 : if (a > 255)
104 0 : a = 255;
105 :
106 0 : dest[c] = (unsigned char) a;
107 : }
108 :
109 0 : dest += stride;
110 0 : diff_ptr += 4;
111 0 : pred += pitch;
112 : }
113 0 : }
|