vp9_idct_blk.c 12.9 KB
Newer Older
Fritz Koenig's avatar
Fritz Koenig committed
1
/*
2
 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
Fritz Koenig's avatar
Fritz Koenig committed
3
4
5
6
7
8
9
10
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

11
#include "vp9_rtcd.h"
12
#include "vp9/common/vp9_blockd.h"
Jim Bankoski's avatar
Jim Bankoski committed
13
14
15
#if CONFIG_LOSSLESS
#include "vp9/decoder/vp9_dequantize.h"
#endif
Johann's avatar
Johann committed
16

17
18
19
20
21
void vp9_dequant_dc_idct_add_y_block_c(int16_t *q, const int16_t *dq,
                                       uint8_t *pre,
                                       uint8_t *dst,
                                       int stride, uint16_t *eobs,
                                       const int16_t *dc) {
John Koleszar's avatar
John Koleszar committed
22
23
24
25
26
  int i, j;

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      if (*eobs++ > 1)
27
        vp9_dequant_dc_idct_add_c(q, dq, pre, dst, 16, stride, dc[0]);
John Koleszar's avatar
John Koleszar committed
28
      else
29
        vp9_dc_only_idct_add_c(dc[0], pre, dst, 16, stride);
John Koleszar's avatar
John Koleszar committed
30
31
32
33
34

      q   += 16;
      pre += 4;
      dst += 4;
      dc++;
Fritz Koenig's avatar
Fritz Koenig committed
35
    }
John Koleszar's avatar
John Koleszar committed
36
37
38
39

    pre += 64 - 16;
    dst += 4 * stride - 16;
  }
Fritz Koenig's avatar
Fritz Koenig committed
40
41
}

42
43
44
void vp9_dequant_dc_idct_add_y_block_4x4_inplace_c(int16_t *q,
                                                   const int16_t *dq,
                                                   uint8_t *dst,
45
                                                   int stride,
46
47
                                                   uint16_t *eobs,
                                                   const int16_t *dc,
48
                                                   MACROBLOCKD *xd) {
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
  int i, j;

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      if (*eobs++ > 1)
        vp9_dequant_dc_idct_add_c(q, dq, dst, dst, stride, stride, dc[0]);
      else
        vp9_dc_only_idct_add_c(dc[0], dst, dst, stride, stride);

      q   += 16;
      dst += 4;
      dc++;
    }

    dst += 4 * stride - 16;
  }
}

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
void vp9_dequant_idct_add_y_block_4x4_inplace_c(int16_t *q,
                                                const int16_t *dq,
                                                uint8_t *dst,
                                                int stride,
                                                uint16_t *eobs,
                                                MACROBLOCKD *xd) {
  int i, j;

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      if (*eobs++ > 1) {
        vp9_dequant_idct_add_c(q, dq, dst, dst, stride, stride);
      } else {
        vp9_dc_only_idct_add_c(q[0]*dq[0], dst, dst, stride, stride);
        ((int *)q)[0] = 0;
      }

      q   += 16;
      dst += 4;
    }

    dst += 4 * stride - 16;
  }
}

92
93
94
95
void vp9_dequant_idct_add_y_block_c(int16_t *q, const int16_t *dq,
                                    uint8_t *pre,
                                    uint8_t *dst,
                                    int stride, uint16_t *eobs) {
John Koleszar's avatar
John Koleszar committed
96
97
98
99
100
  int i, j;

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      if (*eobs++ > 1)
101
        vp9_dequant_idct_add_c(q, dq, pre, dst, 16, stride);
John Koleszar's avatar
John Koleszar committed
102
      else {
103
        vp9_dc_only_idct_add_c(q[0]*dq[0], pre, dst, 16, stride);
John Koleszar's avatar
John Koleszar committed
104
105
106
107
108
109
        ((int *)q)[0] = 0;
      }

      q   += 16;
      pre += 4;
      dst += 4;
Fritz Koenig's avatar
Fritz Koenig committed
110
    }
John Koleszar's avatar
John Koleszar committed
111
112
113
114

    pre += 64 - 16;
    dst += 4 * stride - 16;
  }
Fritz Koenig's avatar
Fritz Koenig committed
115
116
}

117
118
119
120
void vp9_dequant_idct_add_uv_block_c(int16_t *q, const int16_t *dq,
                                     uint8_t *pre, uint8_t *dstu,
                                     uint8_t *dstv, int stride,
                                     uint16_t *eobs) {
John Koleszar's avatar
John Koleszar committed
121
122
123
124
125
  int i, j;

  for (i = 0; i < 2; i++) {
    for (j = 0; j < 2; j++) {
      if (*eobs++ > 1)
126
        vp9_dequant_idct_add_c(q, dq, pre, dstu, 8, stride);
John Koleszar's avatar
John Koleszar committed
127
      else {
128
        vp9_dc_only_idct_add_c(q[0]*dq[0], pre, dstu, 8, stride);
John Koleszar's avatar
John Koleszar committed
129
130
131
132
133
134
        ((int *)q)[0] = 0;
      }

      q    += 16;
      pre  += 4;
      dstu += 4;
Fritz Koenig's avatar
Fritz Koenig committed
135
136
    }

John Koleszar's avatar
John Koleszar committed
137
138
139
140
141
142
143
    pre  += 32 - 8;
    dstu += 4 * stride - 8;
  }

  for (i = 0; i < 2; i++) {
    for (j = 0; j < 2; j++) {
      if (*eobs++ > 1)
144
        vp9_dequant_idct_add_c(q, dq, pre, dstv, 8, stride);
John Koleszar's avatar
John Koleszar committed
145
      else {
146
        vp9_dc_only_idct_add_c(q[0]*dq[0], pre, dstv, 8, stride);
John Koleszar's avatar
John Koleszar committed
147
148
149
150
151
152
        ((int *)q)[0] = 0;
      }

      q    += 16;
      pre  += 4;
      dstv += 4;
Fritz Koenig's avatar
Fritz Koenig committed
153
    }
John Koleszar's avatar
John Koleszar committed
154
155
156
157

    pre  += 32 - 8;
    dstv += 4 * stride - 8;
  }
Fritz Koenig's avatar
Fritz Koenig committed
158
}
159

160
161
162
void vp9_dequant_idct_add_uv_block_4x4_inplace_c(int16_t *q, const int16_t *dq,
                                                 uint8_t *dstu,
                                                 uint8_t *dstv,
163
                                                 int stride,
164
                                                 uint16_t *eobs,
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
                                                 MACROBLOCKD *xd) {
  int i, j;

  for (i = 0; i < 2; i++) {
    for (j = 0; j < 2; j++) {
      if (*eobs++ > 1) {
        vp9_dequant_idct_add_c(q, dq, dstu, dstu, stride, stride);
      } else {
        vp9_dc_only_idct_add_c(q[0]*dq[0], dstu, dstu, stride, stride);
        ((int *)q)[0] = 0;
      }

      q    += 16;
      dstu += 4;
    }

    dstu += 4 * stride - 8;
  }

  for (i = 0; i < 2; i++) {
    for (j = 0; j < 2; j++) {
      if (*eobs++ > 1) {
        vp9_dequant_idct_add_c(q, dq, dstv, dstv, stride, stride);
      } else {
        vp9_dc_only_idct_add_c(q[0]*dq[0], dstv, dstv, stride, stride);
        ((int *)q)[0] = 0;
      }

      q    += 16;
      dstv += 4;
    }

    dstv += 4 * stride - 8;
  }
}
Yaowu Xu's avatar
Yaowu Xu committed
200

201
202
203
204
205
void vp9_dequant_dc_idct_add_y_block_8x8_c(int16_t *q, const int16_t *dq,
                                           uint8_t *pre,
                                           uint8_t *dst,
                                           int stride, uint16_t *eobs,
                                           const int16_t *dc,
206
                                           MACROBLOCKD *xd) {
Yunqing Wang's avatar
Yunqing Wang committed
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
  q[0] = dc[0];
  vp9_dequant_idct_add_8x8_c(q, dq, pre, dst, 16, stride, 1, xd->eobs[0]);

  q[64] = dc[1];
  vp9_dequant_idct_add_8x8_c(&q[64], dq, pre + 8, dst + 8, 16, stride, 1,
                             xd->eobs[4]);

  q[128] = dc[4];
  vp9_dequant_idct_add_8x8_c(&q[128], dq, pre + 8 * 16,
                                dst + 8 * stride, 16, stride, 1, xd->eobs[8]);

  q[192] = dc[8];
  vp9_dequant_idct_add_8x8_c(&q[192], dq, pre + 8 * 16 + 8,
                                dst + 8 * stride + 8, 16, stride, 1,
                                xd->eobs[12]);
222
223
}

224
225
226
void vp9_dequant_dc_idct_add_y_block_8x8_inplace_c(int16_t *q,
                                                   const int16_t *dq,
                                                   uint8_t *dst,
Yunqing Wang's avatar
Yunqing Wang committed
227
                                                   int stride,
228
229
                                                   uint16_t *eobs,
                                                   const int16_t *dc,
230
                                                   MACROBLOCKD *xd) {
Yunqing Wang's avatar
Yunqing Wang committed
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
  q[0] = dc[0];
  vp9_dequant_idct_add_8x8_c(q, dq, dst, dst, stride, stride, 1, xd->eobs[0]);

  q[64] = dc[1];
  vp9_dequant_idct_add_8x8_c(&q[64], dq, dst + 8,
                                dst + 8, stride, stride, 1, xd->eobs[4]);

  q[128] = dc[4];
  vp9_dequant_idct_add_8x8_c(&q[128], dq, dst + 8 * stride,
                                dst + 8 * stride, stride, stride, 1,
                                xd->eobs[8]);

  q[192] = dc[8];
  vp9_dequant_idct_add_8x8_c(&q[192], dq, dst + 8 * stride + 8,
                                dst + 8 * stride + 8, stride, stride, 1,
                                xd->eobs[12]);
Ronald S. Bultje's avatar
Ronald S. Bultje committed
247
248
}

249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
void vp9_dequant_idct_add_y_block_8x8_inplace_c(int16_t *q,
                                                const int16_t *dq,
                                                uint8_t *dst,
                                                int stride,
                                                uint16_t *eobs,
                                                MACROBLOCKD *xd) {
  vp9_dequant_idct_add_8x8_c(q, dq, dst, dst, stride, stride, 0, xd->eobs[0]);

  vp9_dequant_idct_add_8x8_c(&q[64], dq, dst + 8,
                             dst + 8, stride, stride, 0, xd->eobs[4]);

  vp9_dequant_idct_add_8x8_c(&q[128], dq, dst + 8 * stride,
                             dst + 8 * stride, stride, stride, 0,
                             xd->eobs[8]);

  vp9_dequant_idct_add_8x8_c(&q[192], dq, dst + 8 * stride + 8,
                             dst + 8 * stride + 8, stride, stride, 0,
                             xd->eobs[12]);
}

269
270
271
272
void vp9_dequant_idct_add_y_block_8x8_c(int16_t *q, const int16_t *dq,
                                        uint8_t *pre,
                                        uint8_t *dst,
                                        int stride, uint16_t *eobs,
273
                                        MACROBLOCKD *xd) {
274
275
  uint8_t *origdest = dst;
  uint8_t *origpred = pre;
276

Yunqing Wang's avatar
Yunqing Wang committed
277
  vp9_dequant_idct_add_8x8_c(q, dq, pre, dst, 16, stride, 0, xd->eobs[0]);
278
  vp9_dequant_idct_add_8x8_c(&q[64], dq, origpred + 8,
Yunqing Wang's avatar
Yunqing Wang committed
279
                             origdest + 8, 16, stride, 0, xd->eobs[4]);
280
  vp9_dequant_idct_add_8x8_c(&q[128], dq, origpred + 8 * 16,
Yunqing Wang's avatar
Yunqing Wang committed
281
                             origdest + 8 * stride, 16, stride, 0, xd->eobs[8]);
282
  vp9_dequant_idct_add_8x8_c(&q[192], dq, origpred + 8 * 16 + 8,
Yunqing Wang's avatar
Yunqing Wang committed
283
284
                             origdest + 8 * stride + 8, 16, stride, 0,
                             xd->eobs[12]);
285
286
}

287
288
289
290
291
void vp9_dequant_idct_add_uv_block_8x8_c(int16_t *q, const int16_t *dq,
                                         uint8_t *pre,
                                         uint8_t *dstu,
                                         uint8_t *dstv,
                                         int stride, uint16_t *eobs,
292
                                         MACROBLOCKD *xd) {
Yunqing Wang's avatar
Yunqing Wang committed
293
  vp9_dequant_idct_add_8x8_c(q, dq, pre, dstu, 8, stride, 0, xd->eobs[16]);
294
295
296
297

  q    += 64;
  pre  += 64;

Yunqing Wang's avatar
Yunqing Wang committed
298
  vp9_dequant_idct_add_8x8_c(q, dq, pre, dstv, 8, stride, 0, xd->eobs[20]);
299
}
Yaowu Xu's avatar
Yaowu Xu committed
300

301
302
303
void vp9_dequant_idct_add_uv_block_8x8_inplace_c(int16_t *q, const int16_t *dq,
                                                 uint8_t *dstu,
                                                 uint8_t *dstv,
Yunqing Wang's avatar
Yunqing Wang committed
304
                                                 int stride,
305
                                                 uint16_t *eobs,
306
                                                 MACROBLOCKD *xd) {
Yunqing Wang's avatar
Yunqing Wang committed
307
308
  vp9_dequant_idct_add_8x8_c(q, dq, dstu, dstu, stride, stride, 0,
                             xd->eobs[16]);
Ronald S. Bultje's avatar
Ronald S. Bultje committed
309

Yunqing Wang's avatar
Yunqing Wang committed
310
311
312
  q += 64;
  vp9_dequant_idct_add_8x8_c(q, dq, dstv, dstv, stride, stride, 0,
                             xd->eobs[20]);
Ronald S. Bultje's avatar
Ronald S. Bultje committed
313
314
}

Hui Su's avatar
Hui Su committed
315
#if CONFIG_LOSSLESS
316
317
318
void vp9_dequant_dc_idct_add_y_block_lossless_c(int16_t *q, const int16_t *dq,
                                                uint8_t *pre,
                                                uint8_t *dst,
Yunqing Wang's avatar
Yunqing Wang committed
319
                                                int stride,
320
321
                                                uint16_t *eobs,
                                                const int16_t *dc) {
John Koleszar's avatar
John Koleszar committed
322
323
324
325
326
  int i, j;

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      if (*eobs++ > 1)
327
        vp9_dequant_dc_idct_add_lossless_c(q, dq, pre, dst, 16, stride, dc[0]);
John Koleszar's avatar
John Koleszar committed
328
      else
329
        vp9_dc_only_inv_walsh_add_c(dc[0], pre, dst, 16, stride);
John Koleszar's avatar
John Koleszar committed
330
331
332
333
334

      q   += 16;
      pre += 4;
      dst += 4;
      dc++;
Hui Su's avatar
Hui Su committed
335
    }
John Koleszar's avatar
John Koleszar committed
336
337
338
339

    pre += 64 - 16;
    dst += 4 * stride - 16;
  }
Hui Su's avatar
Hui Su committed
340
341
}

342
343
344
345
void vp9_dequant_idct_add_y_block_lossless_c(int16_t *q, const int16_t *dq,
                                             uint8_t *pre,
                                             uint8_t *dst,
                                             int stride, uint16_t *eobs) {
John Koleszar's avatar
John Koleszar committed
346
347
348
349
350
  int i, j;

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      if (*eobs++ > 1)
351
        vp9_dequant_idct_add_lossless_c(q, dq, pre, dst, 16, stride);
John Koleszar's avatar
John Koleszar committed
352
      else {
353
        vp9_dc_only_inv_walsh_add_c(q[0]*dq[0], pre, dst, 16, stride);
John Koleszar's avatar
John Koleszar committed
354
355
356
357
358
359
        ((int *)q)[0] = 0;
      }

      q   += 16;
      pre += 4;
      dst += 4;
Hui Su's avatar
Hui Su committed
360
    }
John Koleszar's avatar
John Koleszar committed
361
362
363
364

    pre += 64 - 16;
    dst += 4 * stride - 16;
  }
Hui Su's avatar
Hui Su committed
365
366
}

367
368
369
370
void vp9_dequant_idct_add_uv_block_lossless_c(int16_t *q, const int16_t *dq,
                                              uint8_t *pre,
                                              uint8_t *dstu,
                                              uint8_t *dstv,
Yunqing Wang's avatar
Yunqing Wang committed
371
                                              int stride,
372
                                              uint16_t *eobs) {
John Koleszar's avatar
John Koleszar committed
373
374
375
376
377
  int i, j;

  for (i = 0; i < 2; i++) {
    for (j = 0; j < 2; j++) {
      if (*eobs++ > 1)
378
        vp9_dequant_idct_add_lossless_c(q, dq, pre, dstu, 8, stride);
John Koleszar's avatar
John Koleszar committed
379
      else {
380
        vp9_dc_only_inv_walsh_add_c(q[0]*dq[0], pre, dstu, 8, stride);
John Koleszar's avatar
John Koleszar committed
381
382
383
384
385
386
        ((int *)q)[0] = 0;
      }

      q    += 16;
      pre  += 4;
      dstu += 4;
Hui Su's avatar
Hui Su committed
387
388
    }

John Koleszar's avatar
John Koleszar committed
389
390
391
392
393
394
395
    pre  += 32 - 8;
    dstu += 4 * stride - 8;
  }

  for (i = 0; i < 2; i++) {
    for (j = 0; j < 2; j++) {
      if (*eobs++ > 1)
396
        vp9_dequant_idct_add_lossless_c(q, dq, pre, dstv, 8, stride);
John Koleszar's avatar
John Koleszar committed
397
      else {
398
        vp9_dc_only_inv_walsh_add_c(q[0]*dq[0], pre, dstv, 8, stride);
John Koleszar's avatar
John Koleszar committed
399
400
401
402
403
404
        ((int *)q)[0] = 0;
      }

      q    += 16;
      pre  += 4;
      dstv += 4;
Hui Su's avatar
Hui Su committed
405
    }
John Koleszar's avatar
John Koleszar committed
406
407
408
409

    pre  += 32 - 8;
    dstv += 4 * stride - 8;
  }
Hui Su's avatar
Hui Su committed
410
411
412
}
#endif