vp9_recon.c 3.98 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_config.h"
13
#include "vp9_rtcd.h"
14
#include "vp9/common/vp9_blockd.h"
John Koleszar's avatar
John Koleszar committed
15

16 17 18 19
static INLINE void recon(int rows, int cols,
                         const uint8_t *pred_ptr, int pred_stride,
                         const int16_t *diff_ptr, int diff_stride,
                         uint8_t *dst_ptr, int dst_stride) {
John Koleszar's avatar
John Koleszar committed
20 21
  int r, c;

22 23
  for (r = 0; r < rows; r++) {
    for (c = 0; c < cols; c++)
24
      dst_ptr[c] = clip_pixel(diff_ptr[c] + pred_ptr[c]);
John Koleszar's avatar
John Koleszar committed
25

26 27 28
    dst_ptr += dst_stride;
    diff_ptr += diff_stride;
    pred_ptr += pred_stride;
John Koleszar's avatar
John Koleszar committed
29
  }
John Koleszar's avatar
John Koleszar committed
30 31
}

John Koleszar's avatar
John Koleszar committed
32

33 34 35 36
void vp9_recon_b_c(uint8_t *pred_ptr, int16_t *diff_ptr, uint8_t *dst_ptr,
                   int stride) {
  recon(4, 4, pred_ptr, 16, diff_ptr, 16, dst_ptr, stride);
}
John Koleszar's avatar
John Koleszar committed
37

38 39 40
void vp9_recon_uv_b_c(uint8_t *pred_ptr, int16_t *diff_ptr, uint8_t *dst_ptr,
                      int stride) {
  recon(4, 4, pred_ptr, 8, diff_ptr, 8, dst_ptr, stride);
41
}
42

43
void vp9_recon4b_c(uint8_t *pred_ptr, int16_t *diff_ptr, uint8_t *dst_ptr,
44
                   int stride) {
45
  recon(4, 16, pred_ptr, 16, diff_ptr, 16, dst_ptr, stride);
John Koleszar's avatar
John Koleszar committed
46 47
}

48
void vp9_recon2b_c(uint8_t *pred_ptr, int16_t *diff_ptr, uint8_t *dst_ptr,
49
                   int stride) {
50
  recon(4, 8, pred_ptr, 8, diff_ptr, 8, dst_ptr, stride);
John Koleszar's avatar
John Koleszar committed
51 52
}

53
void vp9_recon_mby_s_c(MACROBLOCKD *xd, uint8_t *dst) {
Ronald S. Bultje's avatar
Ronald S. Bultje committed
54
  int x, y;
55 56 57
  BLOCKD *const b = &xd->block[0];
  const int stride = b->dst_stride;
  const int16_t *diff = b->diff;
Ronald S. Bultje's avatar
Ronald S. Bultje committed
58 59

  for (y = 0; y < 16; y++) {
60
    for (x = 0; x < 16; x++)
61
      dst[x] = clip_pixel(dst[x] + diff[x]);
62

Ronald S. Bultje's avatar
Ronald S. Bultje committed
63 64 65 66 67
    dst += stride;
    diff += 16;
  }
}

68
void vp9_recon_mbuv_s_c(MACROBLOCKD *xd, uint8_t *udst, uint8_t *vdst) {
Ronald S. Bultje's avatar
Ronald S. Bultje committed
69 70 71 72
  int x, y, i;
  uint8_t *dst = udst;

  for (i = 0; i < 2; i++, dst = vdst) {
73 74 75
    BLOCKD *const b = &xd->block[16 + 4 * i];
    const int stride = b->dst_stride;
    const int16_t *diff = b->diff;
Ronald S. Bultje's avatar
Ronald S. Bultje committed
76 77

    for (y = 0; y < 8; y++) {
78
      for (x = 0; x < 8; x++)
79
        dst[x] = clip_pixel(dst[x] + diff[x]);
80

Ronald S. Bultje's avatar
Ronald S. Bultje committed
81 82 83 84 85
      dst += stride;
      diff += 8;
    }
  }
}
86

87 88 89
void vp9_recon_sby_s_c(MACROBLOCKD *mb, uint8_t *dst,
                       BLOCK_SIZE_TYPE bsize) {
  const int bw = 16 << mb_width_log2(bsize), bh = 16 << mb_height_log2(bsize);
90 91 92
  int x, y;
  const int stride = mb->block[0].dst_stride;
  const int16_t *diff = mb->diff;
93

94 95
  for (y = 0; y < bh; y++) {
    for (x = 0; x < bw; x++)
96
      dst[x] = clip_pixel(dst[x] + diff[x]);
97

98
    dst += stride;
99
    diff += bw;
100 101 102
  }
}

103 104 105 106 107
void vp9_recon_sbuv_s_c(MACROBLOCKD *mb, uint8_t *u_dst, uint8_t *v_dst,
                        BLOCK_SIZE_TYPE bsize) {
  const int bwl = mb_width_log2(bsize), bhl = mb_height_log2(bsize);
  const int uoff = (16 * 16) << (bwl + bhl), voff = (uoff * 5) >> 2;
  const int bw = 8 << bwl, bh = 8 << bhl;
108 109
  int x, y;
  const int stride = mb->block[16].dst_stride;
110 111
  const int16_t *u_diff = mb->diff + uoff;
  const int16_t *v_diff = mb->diff + voff;
112

113 114
  for (y = 0; y < bh; y++) {
    for (x = 0; x < bw; x++) {
115 116
      u_dst[x] = clip_pixel(u_dst[x] + u_diff[x]);
      v_dst[x] = clip_pixel(v_dst[x] + v_diff[x]);
117
    }
118 119 120

    u_dst += stride;
    v_dst += stride;
121 122
    u_diff += bw;
    v_diff += bw;
123 124
  }
}
Ronald S. Bultje's avatar
Ronald S. Bultje committed
125

126
void vp9_recon_mby_c(MACROBLOCKD *xd) {
John Koleszar's avatar
John Koleszar committed
127
  int i;
John Koleszar's avatar
John Koleszar committed
128

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

132
    vp9_recon4b(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
John Koleszar's avatar
John Koleszar committed
133
  }
John Koleszar's avatar
John Koleszar committed
134 135
}

136
void vp9_recon_mb_c(MACROBLOCKD *xd) {
John Koleszar's avatar
John Koleszar committed
137
  int i;
John Koleszar's avatar
John Koleszar committed
138

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

142
    vp9_recon4b(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
John Koleszar's avatar
John Koleszar committed
143
  }
John Koleszar's avatar
John Koleszar committed
144

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

148
    vp9_recon2b(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
John Koleszar's avatar
John Koleszar committed
149
  }
John Koleszar's avatar
John Koleszar committed
150
}