vp9_idct_blk.c 11.2 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
  int i, j;

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      if (*eobs++ > 1)
Yaowu Xu's avatar
Yaowu Xu committed
54
        xd->dc_itxm_add(q, dq, dst, dst, stride, stride, dc[0]);
55
      else
Yaowu Xu's avatar
Yaowu Xu committed
56
        xd->dc_only_itxm_add(dc[0], dst, dst, stride, stride);
57 58 59 60 61 62 63 64 65 66

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

    dst += 4 * stride - 16;
  }
}

67 68 69 70
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
71 72 73 74 75
  int i, j;

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      if (*eobs++ > 1)
76
        vp9_dequant_idct_add_c(q, dq, pre, dst, 16, stride);
John Koleszar's avatar
John Koleszar committed
77
      else {
78
        vp9_dc_only_idct_add_c(q[0]*dq[0], pre, dst, 16, stride);
John Koleszar's avatar
John Koleszar committed
79 80 81 82 83 84
        ((int *)q)[0] = 0;
      }

      q   += 16;
      pre += 4;
      dst += 4;
Fritz Koenig's avatar
Fritz Koenig committed
85
    }
John Koleszar's avatar
John Koleszar committed
86 87 88 89

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

92 93 94 95
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
96 97 98 99 100
  int i, j;

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

      q    += 16;
      pre  += 4;
      dstu += 4;
Fritz Koenig's avatar
Fritz Koenig committed
110 111
    }

John Koleszar's avatar
John Koleszar committed
112 113 114 115 116 117 118
    pre  += 32 - 8;
    dstu += 4 * stride - 8;
  }

  for (i = 0; i < 2; i++) {
    for (j = 0; j < 2; j++) {
      if (*eobs++ > 1)
119
        vp9_dequant_idct_add_c(q, dq, pre, dstv, 8, stride);
John Koleszar's avatar
John Koleszar committed
120
      else {
121
        vp9_dc_only_idct_add_c(q[0]*dq[0], pre, dstv, 8, stride);
John Koleszar's avatar
John Koleszar committed
122 123 124 125 126 127
        ((int *)q)[0] = 0;
      }

      q    += 16;
      pre  += 4;
      dstv += 4;
Fritz Koenig's avatar
Fritz Koenig committed
128
    }
John Koleszar's avatar
John Koleszar committed
129 130 131 132

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

135 136 137
void vp9_dequant_idct_add_uv_block_4x4_inplace_c(int16_t *q, const int16_t *dq,
                                                 uint8_t *dstu,
                                                 uint8_t *dstv,
138
                                                 int stride,
139
                                                 uint16_t *eobs,
140 141 142 143 144 145
                                                 MACROBLOCKD *xd) {
  int i, j;

  for (i = 0; i < 2; i++) {
    for (j = 0; j < 2; j++) {
      if (*eobs++ > 1) {
Yaowu Xu's avatar
Yaowu Xu committed
146
        xd->itxm_add(q, dq, dstu, dstu, stride, stride);
147
      } else {
Yaowu Xu's avatar
Yaowu Xu committed
148
        xd->dc_only_itxm_add(q[0]*dq[0], dstu, dstu, stride, stride);
149 150 151 152 153 154 155 156 157 158 159 160 161
        ((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) {
Yaowu Xu's avatar
Yaowu Xu committed
162
        xd->itxm_add(q, dq, dstv, dstv, stride, stride);
163
      } else {
Yaowu Xu's avatar
Yaowu Xu committed
164
        xd->dc_only_itxm_add(q[0]*dq[0], dstv, dstv, stride, stride);
165 166 167 168 169 170 171 172 173 174
        ((int *)q)[0] = 0;
      }

      q    += 16;
      dstv += 4;
    }

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

176 177 178 179 180
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,
181
                                           MACROBLOCKD *xd) {
Yunqing Wang's avatar
Yunqing Wang committed
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
  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]);
197 198
}

199 200 201
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
202
                                                   int stride,
203 204
                                                   uint16_t *eobs,
                                                   const int16_t *dc,
205
                                                   MACROBLOCKD *xd) {
Yunqing Wang's avatar
Yunqing Wang committed
206 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, 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
222 223
}

224 225 226 227
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,
228
                                        MACROBLOCKD *xd) {
229 230
  uint8_t *origdest = dst;
  uint8_t *origpred = pre;
231

Yunqing Wang's avatar
Yunqing Wang committed
232
  vp9_dequant_idct_add_8x8_c(q, dq, pre, dst, 16, stride, 0, xd->eobs[0]);
233
  vp9_dequant_idct_add_8x8_c(&q[64], dq, origpred + 8,
Yunqing Wang's avatar
Yunqing Wang committed
234
                             origdest + 8, 16, stride, 0, xd->eobs[4]);
235
  vp9_dequant_idct_add_8x8_c(&q[128], dq, origpred + 8 * 16,
Yunqing Wang's avatar
Yunqing Wang committed
236
                             origdest + 8 * stride, 16, stride, 0, xd->eobs[8]);
237
  vp9_dequant_idct_add_8x8_c(&q[192], dq, origpred + 8 * 16 + 8,
Yunqing Wang's avatar
Yunqing Wang committed
238 239
                             origdest + 8 * stride + 8, 16, stride, 0,
                             xd->eobs[12]);
240 241
}

242 243 244 245 246
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,
247
                                         MACROBLOCKD *xd) {
Yunqing Wang's avatar
Yunqing Wang committed
248
  vp9_dequant_idct_add_8x8_c(q, dq, pre, dstu, 8, stride, 0, xd->eobs[16]);
249 250 251 252

  q    += 64;
  pre  += 64;

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

256 257 258
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
259
                                                 int stride,
260
                                                 uint16_t *eobs,
261
                                                 MACROBLOCKD *xd) {
Yunqing Wang's avatar
Yunqing Wang committed
262 263
  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
264

Yunqing Wang's avatar
Yunqing Wang committed
265 266 267
  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
268 269
}

Hui Su's avatar
Hui Su committed
270
#if CONFIG_LOSSLESS
271 272 273
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
274
                                                int stride,
275 276
                                                uint16_t *eobs,
                                                const int16_t *dc) {
John Koleszar's avatar
John Koleszar committed
277 278 279 280 281
  int i, j;

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      if (*eobs++ > 1)
282
        vp9_dequant_dc_idct_add_lossless_c(q, dq, pre, dst, 16, stride, dc[0]);
John Koleszar's avatar
John Koleszar committed
283
      else
284
        vp9_dc_only_inv_walsh_add_c(dc[0], pre, dst, 16, stride);
John Koleszar's avatar
John Koleszar committed
285 286 287 288 289

      q   += 16;
      pre += 4;
      dst += 4;
      dc++;
Hui Su's avatar
Hui Su committed
290
    }
John Koleszar's avatar
John Koleszar committed
291 292 293 294

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

297 298 299 300
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
301 302 303 304 305
  int i, j;

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      if (*eobs++ > 1)
306
        vp9_dequant_idct_add_lossless_c(q, dq, pre, dst, 16, stride);
John Koleszar's avatar
John Koleszar committed
307
      else {
308
        vp9_dc_only_inv_walsh_add_c(q[0]*dq[0], pre, dst, 16, stride);
John Koleszar's avatar
John Koleszar committed
309 310 311 312 313 314
        ((int *)q)[0] = 0;
      }

      q   += 16;
      pre += 4;
      dst += 4;
Hui Su's avatar
Hui Su committed
315
    }
John Koleszar's avatar
John Koleszar committed
316 317 318 319

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

322 323 324 325
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
326
                                              int stride,
327
                                              uint16_t *eobs) {
John Koleszar's avatar
John Koleszar committed
328 329 330 331 332
  int i, j;

  for (i = 0; i < 2; i++) {
    for (j = 0; j < 2; j++) {
      if (*eobs++ > 1)
333
        vp9_dequant_idct_add_lossless_c(q, dq, pre, dstu, 8, stride);
John Koleszar's avatar
John Koleszar committed
334
      else {
335
        vp9_dc_only_inv_walsh_add_c(q[0]*dq[0], pre, dstu, 8, stride);
John Koleszar's avatar
John Koleszar committed
336 337 338 339 340 341
        ((int *)q)[0] = 0;
      }

      q    += 16;
      pre  += 4;
      dstu += 4;
Hui Su's avatar
Hui Su committed
342 343
    }

John Koleszar's avatar
John Koleszar committed
344 345 346 347 348 349 350
    pre  += 32 - 8;
    dstu += 4 * stride - 8;
  }

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

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

    pre  += 32 - 8;
    dstv += 4 * stride - 8;
  }
Hui Su's avatar
Hui Su committed
365 366 367
}
#endif