vp9_recon.c 3.52 KB
Newer Older
John Koleszar's avatar
John Koleszar committed
1
/*
2
 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
John Koleszar's avatar
John Koleszar committed
3
 *
4
 *  Use of this source code is governed by a BSD-style license
5 6
 *  that can be found in the LICENSE file in the root of the source
 *  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.
John Koleszar's avatar
John Koleszar committed
9 10 11
 */


12
#include "vpx_ports/config.h"
13
#include "vp9_rtcd.h"
14
#include "vp9/common/vp9_blockd.h"
John Koleszar's avatar
John Koleszar committed
15

16
void vp9_recon_b_c
John Koleszar's avatar
John Koleszar committed
17
(
John Koleszar's avatar
John Koleszar committed
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
  unsigned char *pred_ptr,
  short *diff_ptr,
  unsigned char *dst_ptr,
  int stride
) {
  int r, c;

  for (r = 0; r < 4; r++) {
    for (c = 0; c < 4; c++) {
      int a = diff_ptr[c] + pred_ptr[c];

      if (a < 0)
        a = 0;

      if (a > 255)
        a = 255;

      dst_ptr[c] = (unsigned char) a;
John Koleszar's avatar
John Koleszar committed
36
    }
John Koleszar's avatar
John Koleszar committed
37 38 39 40 41

    dst_ptr += stride;
    diff_ptr += 16;
    pred_ptr += 16;
  }
John Koleszar's avatar
John Koleszar committed
42 43
}

44
void vp9_recon_uv_b_c
45
(
John Koleszar's avatar
John Koleszar committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
  unsigned char *pred_ptr,
  short *diff_ptr,
  unsigned char *dst_ptr,
  int stride
) {
  int r, c;

  for (r = 0; r < 4; r++) {
    for (c = 0; c < 4; c++) {
      int a = diff_ptr[c] + pred_ptr[c];

      if (a < 0)
        a = 0;

      if (a > 255)
        a = 255;

      dst_ptr[c] = (unsigned char) a;
64
    }
John Koleszar's avatar
John Koleszar committed
65 66 67 68 69

    dst_ptr += stride;
    diff_ptr += 8;
    pred_ptr += 8;
  }
70
}
71
void vp9_recon4b_c
John Koleszar's avatar
John Koleszar committed
72
(
John Koleszar's avatar
John Koleszar committed
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
  unsigned char *pred_ptr,
  short *diff_ptr,
  unsigned char *dst_ptr,
  int stride
) {
  int r, c;

  for (r = 0; r < 4; r++) {
    for (c = 0; c < 16; c++) {
      int a = diff_ptr[c] + pred_ptr[c];

      if (a < 0)
        a = 0;

      if (a > 255)
        a = 255;

      dst_ptr[c] = (unsigned char) a;
John Koleszar's avatar
John Koleszar committed
91
    }
John Koleszar's avatar
John Koleszar committed
92 93 94 95 96

    dst_ptr += stride;
    diff_ptr += 16;
    pred_ptr += 16;
  }
John Koleszar's avatar
John Koleszar committed
97 98
}

99
void vp9_recon2b_c
John Koleszar's avatar
John Koleszar committed
100
(
John Koleszar's avatar
John Koleszar committed
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
  unsigned char *pred_ptr,
  short *diff_ptr,
  unsigned char *dst_ptr,
  int stride
) {
  int r, c;

  for (r = 0; r < 4; r++) {
    for (c = 0; c < 8; c++) {
      int a = diff_ptr[c] + pred_ptr[c];

      if (a < 0)
        a = 0;

      if (a > 255)
        a = 255;

      dst_ptr[c] = (unsigned char) a;
John Koleszar's avatar
John Koleszar committed
119
    }
John Koleszar's avatar
John Koleszar committed
120 121 122 123 124

    dst_ptr += stride;
    diff_ptr += 8;
    pred_ptr += 8;
  }
John Koleszar's avatar
John Koleszar committed
125 126
}

Ronald S. Bultje's avatar
Ronald S. Bultje committed
127
#if CONFIG_SUPERBLOCKS
128
void vp9_recon_mby_s_c(MACROBLOCKD *xd, uint8_t *dst) {
Ronald S. Bultje's avatar
Ronald S. Bultje committed
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
  int x, y;
  BLOCKD *b = &xd->block[0];
  int stride = b->dst_stride;
  short *diff = b->diff;

  for (y = 0; y < 16; y++) {
    for (x = 0; x < 16; x++) {
      int a = dst[x] + diff[x];
      if (a < 0)
        a = 0;
      else if (a > 255)
        a = 255;
      dst[x] = a;
    }
    dst += stride;
    diff += 16;
  }
}

148
void vp9_recon_mbuv_s_c(MACROBLOCKD *xd, uint8_t *udst, uint8_t *vdst) {
Ronald S. Bultje's avatar
Ronald S. Bultje committed
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
  int x, y, i;
  uint8_t *dst = udst;

  for (i = 0; i < 2; i++, dst = vdst) {
    BLOCKD *b = &xd->block[16 + 4 * i];
    int stride = b->dst_stride;
    short *diff = b->diff;

    for (y = 0; y < 8; y++) {
      for (x = 0; x < 8; x++) {
        int a = dst[x] + diff[x];
        if (a < 0)
          a = 0;
        else if (a > 255)
          a = 255;
        dst[x] = a;
      }
      dst += stride;
      diff += 8;
    }
  }
}
#endif

173
void vp9_recon_mby_c(MACROBLOCKD *xd) {
John Koleszar's avatar
John Koleszar committed
174
  int i;
John Koleszar's avatar
John Koleszar committed
175

John Koleszar's avatar
John Koleszar committed
176
  for (i = 0; i < 16; i += 4) {
Paul Wilkins's avatar
Paul Wilkins committed
177
    BLOCKD *b = &xd->block[i];
John Koleszar's avatar
John Koleszar committed
178

179
    vp9_recon4b(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
John Koleszar's avatar
John Koleszar committed
180
  }
John Koleszar's avatar
John Koleszar committed
181 182
}

183
void vp9_recon_mb_c(MACROBLOCKD *xd) {
John Koleszar's avatar
John Koleszar committed
184
  int i;
John Koleszar's avatar
John Koleszar committed
185

John Koleszar's avatar
John Koleszar committed
186
  for (i = 0; i < 16; i += 4) {
Paul Wilkins's avatar
Paul Wilkins committed
187
    BLOCKD *b = &xd->block[i];
John Koleszar's avatar
John Koleszar committed
188

189
    vp9_recon4b(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
John Koleszar's avatar
John Koleszar committed
190
  }
John Koleszar's avatar
John Koleszar committed
191

John Koleszar's avatar
John Koleszar committed
192
  for (i = 16; i < 24; i += 2) {
Paul Wilkins's avatar
Paul Wilkins committed
193
    BLOCKD *b = &xd->block[i];
John Koleszar's avatar
John Koleszar committed
194

195
    vp9_recon2b(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
John Koleszar's avatar
John Koleszar committed
196
  }
John Koleszar's avatar
John Koleszar committed
197
}