idct_blk.c 10.6 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 "vpx_rtcd.h"
12
#include "vp9/common/idct.h"
Johann's avatar
Johann committed
13

14 15 16
void vp9_dequant_dc_idct_add_y_block_c(short *q, short *dq,
                                       unsigned char *pre,
                                       unsigned char *dst,
Yunqing Wang's avatar
Yunqing Wang committed
17
                                       int stride, unsigned short *eobs,
18
                                       short *dc) {
John Koleszar's avatar
John Koleszar committed
19 20 21 22 23
  int i, j;

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

      q   += 16;
      pre += 4;
      dst += 4;
      dc++;
Fritz Koenig's avatar
Fritz Koenig committed
32
    }
John Koleszar's avatar
John Koleszar committed
33 34 35 36

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

39 40 41
#if CONFIG_SUPERBLOCKS
void vp9_dequant_dc_idct_add_y_block_4x4_inplace_c(short *q, short *dq,
                                                   unsigned char *dst,
42 43
                                                   int stride,
                                                   unsigned short *eobs,
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
                                                   short *dc, MACROBLOCKD *xd) {
  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;
  }
}
#endif

64 65 66
void vp9_dequant_idct_add_y_block_c(short *q, short *dq,
                                    unsigned char *pre,
                                    unsigned char *dst,
Yunqing Wang's avatar
Yunqing Wang committed
67
                                    int stride, unsigned short *eobs) {
John Koleszar's avatar
John Koleszar committed
68 69 70 71 72
  int i, j;

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

      q   += 16;
      pre += 4;
      dst += 4;
Fritz Koenig's avatar
Fritz Koenig committed
82
    }
John Koleszar's avatar
John Koleszar committed
83 84 85 86

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

89 90
void vp9_dequant_idct_add_uv_block_c(short *q, short *dq, unsigned char *pre,
                                     unsigned char *dstu, unsigned char *dstv,
Yunqing Wang's avatar
Yunqing Wang committed
91
                                     int stride, unsigned short *eobs) {
John Koleszar's avatar
John Koleszar committed
92 93 94 95 96
  int i, j;

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

      q    += 16;
      pre  += 4;
      dstu += 4;
Fritz Koenig's avatar
Fritz Koenig committed
106 107
    }

John Koleszar's avatar
John Koleszar committed
108 109 110 111 112 113 114
    pre  += 32 - 8;
    dstu += 4 * stride - 8;
  }

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

      q    += 16;
      pre  += 4;
      dstv += 4;
Fritz Koenig's avatar
Fritz Koenig committed
124
    }
John Koleszar's avatar
John Koleszar committed
125 126 127 128

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

131 132 133 134
#if CONFIG_SUPERBLOCKS
void vp9_dequant_idct_add_uv_block_4x4_inplace_c(short *q, short *dq,
                                                 unsigned char *dstu,
                                                 unsigned char *dstv,
135 136
                                                 int stride,
                                                 unsigned short *eobs,
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
                                                 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;
  }
}
#endif
Yaowu Xu's avatar
Yaowu Xu committed
173

174 175 176
void vp9_dequant_dc_idct_add_y_block_8x8_c(short *q, short *dq,
                                           unsigned char *pre,
                                           unsigned char *dst,
Yunqing Wang's avatar
Yunqing Wang committed
177 178
                                           int stride, unsigned short *eobs,
                                           short *dc,
179
                                           MACROBLOCKD *xd) {
180 181
  vp9_dequant_dc_idct_add_8x8_c(q, dq, pre, dst, 16, stride, dc[0]);
  vp9_dequant_dc_idct_add_8x8_c(&q[64], dq, pre + 8, dst + 8, 16, stride, dc[1]);
182 183 184 185
  vp9_dequant_dc_idct_add_8x8_c(&q[128], dq, pre + 8 * 16,
                                dst + 8 * stride, 16, stride, dc[4]);
  vp9_dequant_dc_idct_add_8x8_c(&q[192], dq, pre + 8 * 16 + 8,
                                dst + 8 * stride + 8, 16, stride, dc[8]);
186 187
}

Ronald S. Bultje's avatar
Ronald S. Bultje committed
188
#if CONFIG_SUPERBLOCKS
189 190
void vp9_dequant_dc_idct_add_y_block_8x8_inplace_c(short *q, short *dq,
                                                   unsigned char *dst,
Yunqing Wang's avatar
Yunqing Wang committed
191 192
                                                   int stride,
                                                   unsigned short *eobs,
193
                                                   short *dc, MACROBLOCKD *xd) {
194
  vp9_dequant_dc_idct_add_8x8_c(q, dq, dst, dst, stride, stride, dc[0]);
195 196 197 198 199 200
  vp9_dequant_dc_idct_add_8x8_c(&q[64], dq, dst + 8,
                                dst + 8, stride, stride, dc[1]);
  vp9_dequant_dc_idct_add_8x8_c(&q[128], dq, dst + 8 * stride,
                                dst + 8 * stride, stride, stride, dc[4]);
  vp9_dequant_dc_idct_add_8x8_c(&q[192], dq, dst + 8 * stride + 8,
                                dst + 8 * stride + 8, stride, stride, dc[8]);
Ronald S. Bultje's avatar
Ronald S. Bultje committed
201 202 203
}
#endif

204 205 206
void vp9_dequant_idct_add_y_block_8x8_c(short *q, short *dq,
                                        unsigned char *pre,
                                        unsigned char *dst,
Yunqing Wang's avatar
Yunqing Wang committed
207
                                        int stride, unsigned short *eobs,
208
                                        MACROBLOCKD *xd) {
209 210 211
  unsigned char *origdest = dst;
  unsigned char *origpred = pre;

212
  vp9_dequant_idct_add_8x8_c(q, dq, pre, dst, 16, stride);
213 214 215 216 217 218
  vp9_dequant_idct_add_8x8_c(&q[64], dq, origpred + 8,
                             origdest + 8, 16, stride);
  vp9_dequant_idct_add_8x8_c(&q[128], dq, origpred + 8 * 16,
                             origdest + 8 * stride, 16, stride);
  vp9_dequant_idct_add_8x8_c(&q[192], dq, origpred + 8 * 16 + 8,
                             origdest + 8 * stride + 8, 16, stride);
219 220
}

221 222 223 224
void vp9_dequant_idct_add_uv_block_8x8_c(short *q, short *dq,
                                         unsigned char *pre,
                                         unsigned char *dstu,
                                         unsigned char *dstv,
Yunqing Wang's avatar
Yunqing Wang committed
225
                                         int stride, unsigned short *eobs,
226
                                         MACROBLOCKD *xd) {
227
  vp9_dequant_idct_add_8x8_c(q, dq, pre, dstu, 8, stride);
228 229 230 231

  q    += 64;
  pre  += 64;

232
  vp9_dequant_idct_add_8x8_c(q, dq, pre, dstv, 8, stride);
233
}
Yaowu Xu's avatar
Yaowu Xu committed
234

Ronald S. Bultje's avatar
Ronald S. Bultje committed
235
#if CONFIG_SUPERBLOCKS
236 237 238
void vp9_dequant_idct_add_uv_block_8x8_inplace_c(short *q, short *dq,
                                                 unsigned char *dstu,
                                                 unsigned char *dstv,
Yunqing Wang's avatar
Yunqing Wang committed
239 240
                                                 int stride,
                                                 unsigned short *eobs,
241
                                                 MACROBLOCKD *xd) {
242
  vp9_dequant_idct_add_8x8_c(q, dq, dstu, dstu, stride, stride);
Ronald S. Bultje's avatar
Ronald S. Bultje committed
243 244 245

  q    += 64;

246
  vp9_dequant_idct_add_8x8_c(q, dq, dstv, dstv, stride, stride);
Ronald S. Bultje's avatar
Ronald S. Bultje committed
247 248 249
}
#endif

Hui Su's avatar
Hui Su committed
250
#if CONFIG_LOSSLESS
251 252 253
void vp9_dequant_dc_idct_add_y_block_lossless_c(short *q, short *dq,
                                                unsigned char *pre,
                                                unsigned char *dst,
Yunqing Wang's avatar
Yunqing Wang committed
254 255
                                                int stride,
                                                unsigned short *eobs,
256
                                                short *dc) {
John Koleszar's avatar
John Koleszar committed
257 258 259 260 261
  int i, j;

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      if (*eobs++ > 1)
262
        vp9_dequant_dc_idct_add_lossless_c(q, dq, pre, dst, 16, stride, dc[0]);
John Koleszar's avatar
John Koleszar committed
263
      else
264
        vp9_dc_only_inv_walsh_add_c(dc[0], pre, dst, 16, stride);
John Koleszar's avatar
John Koleszar committed
265 266 267 268 269

      q   += 16;
      pre += 4;
      dst += 4;
      dc++;
Hui Su's avatar
Hui Su committed
270
    }
John Koleszar's avatar
John Koleszar committed
271 272 273 274

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

277 278 279
void vp9_dequant_idct_add_y_block_lossless_c(short *q, short *dq,
                                             unsigned char *pre,
                                             unsigned char *dst,
Yunqing Wang's avatar
Yunqing Wang committed
280
                                             int stride, unsigned short *eobs) {
John Koleszar's avatar
John Koleszar committed
281 282 283 284 285
  int i, j;

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      if (*eobs++ > 1)
286
        vp9_dequant_idct_add_lossless_c(q, dq, pre, dst, 16, stride);
John Koleszar's avatar
John Koleszar committed
287
      else {
288
        vp9_dc_only_inv_walsh_add_c(q[0]*dq[0], pre, dst, 16, stride);
John Koleszar's avatar
John Koleszar committed
289 290 291 292 293 294
        ((int *)q)[0] = 0;
      }

      q   += 16;
      pre += 4;
      dst += 4;
Hui Su's avatar
Hui Su committed
295
    }
John Koleszar's avatar
John Koleszar committed
296 297 298 299

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

302 303 304 305
void vp9_dequant_idct_add_uv_block_lossless_c(short *q, short *dq,
                                              unsigned char *pre,
                                              unsigned char *dstu,
                                              unsigned char *dstv,
Yunqing Wang's avatar
Yunqing Wang committed
306 307
                                              int stride,
                                              unsigned short *eobs) {
John Koleszar's avatar
John Koleszar committed
308 309 310 311 312
  int i, j;

  for (i = 0; i < 2; i++) {
    for (j = 0; j < 2; j++) {
      if (*eobs++ > 1)
313
        vp9_dequant_idct_add_lossless_c(q, dq, pre, dstu, 8, stride);
John Koleszar's avatar
John Koleszar committed
314
      else {
315
        vp9_dc_only_inv_walsh_add_c(q[0]*dq[0], pre, dstu, 8, stride);
John Koleszar's avatar
John Koleszar committed
316 317 318 319 320 321
        ((int *)q)[0] = 0;
      }

      q    += 16;
      pre  += 4;
      dstu += 4;
Hui Su's avatar
Hui Su committed
322 323
    }

John Koleszar's avatar
John Koleszar committed
324 325 326 327 328 329 330
    pre  += 32 - 8;
    dstu += 4 * stride - 8;
  }

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

      q    += 16;
      pre  += 4;
      dstv += 4;
Hui Su's avatar
Hui Su committed
340
    }
John Koleszar's avatar
John Koleszar committed
341 342 343 344

    pre  += 32 - 8;
    dstv += 4 * stride - 8;
  }
Hui Su's avatar
Hui Su committed
345 346 347
}
#endif