recon.c 4.08 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"
John Koleszar's avatar
John Koleszar committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
#include "recon.h"
#include "blockd.h"

void vp8_recon_b_c
(
    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 ;
        }

        dst_ptr += stride;
        diff_ptr += 16;
        pred_ptr += 16;
    }
}

void vp8_recon4b_c
(
    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 ;
        }

        dst_ptr += stride;
        diff_ptr += 16;
        pred_ptr += 16;
    }
}

void vp8_recon2b_c
(
    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 ;
        }

        dst_ptr += stride;
        diff_ptr += 8;
        pred_ptr += 8;
    }
}

109
void vp8_recon_mby_c(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x)
John Koleszar's avatar
John Koleszar committed
110
{
111 112 113 114
#if ARCH_ARM
    BLOCKD *b = &x->block[0];
    RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);

115
    /*b = &x->block[4];*/
116 117 118
    b += 4;
    RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);

119
    /*b = &x->block[8];*/
120 121 122
    b += 4;
    RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);

123
    /*b = &x->block[12];*/
124 125 126
    b += 4;
    RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
#else
John Koleszar's avatar
John Koleszar committed
127 128 129 130 131 132 133 134
    int i;

    for (i = 0; i < 16; i += 4)
    {
        BLOCKD *b = &x->block[i];

        RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
    }
135
#endif
John Koleszar's avatar
John Koleszar committed
136 137
}

138
void vp8_recon_mb_c(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x)
John Koleszar's avatar
John Koleszar committed
139
{
140 141 142 143 144 145 146 147 148 149 150 151
#if ARCH_ARM
    BLOCKD *b = &x->block[0];

    RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
    b += 4;
    RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
    b += 4;
    RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
    b += 4;
    RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
    b += 4;

152
    /*b = &x->block[16];*/
153 154 155 156 157 158 159 160 161 162 163 164

    RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
    b++;
    b++;
    RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
    b++;
    b++;
    RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
    b++;
    b++;
    RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
#else
John Koleszar's avatar
John Koleszar committed
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
    int i;

    for (i = 0; i < 16; i += 4)
    {
        BLOCKD *b = &x->block[i];

        RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
    }

    for (i = 16; i < 24; i += 2)
    {
        BLOCKD *b = &x->block[i];

        RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
    }
180
#endif
John Koleszar's avatar
John Koleszar committed
181
}