vp9_recon.c 3.34 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
void vp9_recon_b_c(uint8_t *pred_ptr, int16_t *diff_ptr, uint8_t *dst_ptr,
                   int stride) {
35
  recon(4, 4, pred_ptr, stride, diff_ptr, 16, dst_ptr, stride);
36
}
John Koleszar's avatar
John Koleszar committed
37

38 39
void vp9_recon_uv_b_c(uint8_t *pred_ptr, int16_t *diff_ptr, uint8_t *dst_ptr,
                      int stride) {
40
  recon(4, 4, pred_ptr, stride, 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, stride, 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, stride, diff_ptr, 8, dst_ptr, stride);
John Koleszar's avatar
John Koleszar committed
51 52
}

53 54 55
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);
56 57 58
  int x, y;
  const int stride = mb->block[0].dst_stride;
  const int16_t *diff = mb->diff;
59

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

64
    dst += stride;
65
    diff += bw;
66 67 68
  }
}

69 70 71 72 73
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;
74 75
  int x, y;
  const int stride = mb->block[16].dst_stride;
76 77
  const int16_t *u_diff = mb->diff + uoff;
  const int16_t *v_diff = mb->diff + voff;
78

79 80
  for (y = 0; y < bh; y++) {
    for (x = 0; x < bw; x++) {
81 82
      u_dst[x] = clip_pixel(u_dst[x] + u_diff[x]);
      v_dst[x] = clip_pixel(v_dst[x] + v_diff[x]);
83
    }
84 85 86

    u_dst += stride;
    v_dst += stride;
87 88
    u_diff += bw;
    v_diff += bw;
89 90
  }
}
Ronald S. Bultje's avatar
Ronald S. Bultje committed
91

92
void vp9_recon_mby_c(MACROBLOCKD *xd) {
John Koleszar's avatar
John Koleszar committed
93
  int i;
John Koleszar's avatar
John Koleszar committed
94

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

98 99
    vp9_recon4b(*(b->base_dst) + b->dst, b->diff,
                *(b->base_dst) + b->dst, b->dst_stride);
John Koleszar's avatar
John Koleszar committed
100
  }
John Koleszar's avatar
John Koleszar committed
101 102
}

103
void vp9_recon_mb_c(MACROBLOCKD *xd) {
John Koleszar's avatar
John Koleszar committed
104
  int i;
John Koleszar's avatar
John Koleszar committed
105

John Koleszar's avatar
John Koleszar committed
106
  for (i = 0; i < 16; i += 4) {
Paul Wilkins's avatar
Paul Wilkins committed
107
    BLOCKD *b = &xd->block[i];
108 109
    vp9_recon4b(*(b->base_dst) + b->dst, b->diff,
                *(b->base_dst) + b->dst, b->dst_stride);
John Koleszar's avatar
John Koleszar committed
110
  }
John Koleszar's avatar
John Koleszar committed
111

John Koleszar's avatar
John Koleszar committed
112
  for (i = 16; i < 24; i += 2) {
Paul Wilkins's avatar
Paul Wilkins committed
113
    BLOCKD *b = &xd->block[i];
114 115
    vp9_recon2b(*(b->base_dst) + b->dst, b->diff,
                *(b->base_dst) + b->dst, b->dst_stride);
John Koleszar's avatar
John Koleszar committed
116
  }
John Koleszar's avatar
John Koleszar committed
117
}