bilinearfilter_arm.c 5.09 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 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
 */


#include <math.h>
#include "subpixel.h"

#define BLOCK_HEIGHT_WIDTH 4
#define VP8_FILTER_WEIGHT 128
#define VP8_FILTER_SHIFT  7

static const short bilinear_filters[8][2] =
{
    { 128,   0 },
    { 112,  16 },
    {  96,  32 },
    {  80,  48 },
    {  64,  64 },
    {  48,  80 },
    {  32,  96 },
    {  16, 112 }
};


extern void vp8_filter_block2d_bil_first_pass_armv6
(
    unsigned char *src_ptr,
    unsigned short *output_ptr,
    unsigned int src_pixels_per_line,
    unsigned int output_height,
    unsigned int output_width,
    const short *vp8_filter
);

extern void vp8_filter_block2d_bil_second_pass_armv6
(
    unsigned short *src_ptr,
    unsigned char  *output_ptr,
    int output_pitch,
    unsigned int  output_height,
    unsigned int  output_width,
    const short *vp8_filter
);

52
#if 0
John Koleszar's avatar
John Koleszar committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
void vp8_filter_block2d_bil_first_pass_6
(
    unsigned char *src_ptr,
    unsigned short *output_ptr,
    unsigned int src_pixels_per_line,
    unsigned int output_height,
    unsigned int output_width,
    const short *vp8_filter
)
{
    unsigned int i, j;

    for ( i=0; i<output_height; i++ )
    {
        for ( j=0; j<output_width; j++ )
        {
69
            /* Apply bilinear filter */
John Koleszar's avatar
John Koleszar committed
70 71 72 73 74 75
            output_ptr[j] = ( ( (int)src_ptr[0]          * vp8_filter[0]) +
                               ((int)src_ptr[1] * vp8_filter[1]) +
                                (VP8_FILTER_WEIGHT/2) ) >> VP8_FILTER_SHIFT;
            src_ptr++;
        }

76
        /* Next row... */
John Koleszar's avatar
John Koleszar committed
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
        src_ptr    += src_pixels_per_line - output_width;
        output_ptr += output_width;
    }
}

void vp8_filter_block2d_bil_second_pass_6
(
    unsigned short *src_ptr,
    unsigned char  *output_ptr,
    int output_pitch,
    unsigned int  output_height,
    unsigned int  output_width,
    const short *vp8_filter
)
{
    unsigned int  i,j;
    int  Temp;

    for ( i=0; i<output_height; i++ )
    {
        for ( j=0; j<output_width; j++ )
        {
99
            /* Apply filter */
John Koleszar's avatar
John Koleszar committed
100 101 102 103 104 105 106
            Temp =  ((int)src_ptr[0]         * vp8_filter[0]) +
                    ((int)src_ptr[output_width] * vp8_filter[1]) +
                    (VP8_FILTER_WEIGHT/2);
            output_ptr[j] = (unsigned int)(Temp >> VP8_FILTER_SHIFT);
            src_ptr++;
        }

107 108
        /* Next row... */
        /*src_ptr    += src_pixels_per_line - output_width;*/
John Koleszar's avatar
John Koleszar committed
109 110 111
        output_ptr += output_pitch;
    }
}
112
#endif
John Koleszar's avatar
John Koleszar committed
113 114 115 116 117 118 119 120 121 122 123 124 125 126

void vp8_filter_block2d_bil_armv6
(
    unsigned char *src_ptr,
    unsigned char *output_ptr,
    unsigned int   src_pixels_per_line,
    unsigned int   dst_pitch,
    const short      *HFilter,
    const short      *VFilter,
    int            Width,
    int            Height
)
{

127
    unsigned short FData[36*16]; /* Temp data bufffer used in filtering */
John Koleszar's avatar
John Koleszar committed
128

129 130
    /* First filter 1-D horizontally... */
    /* pixel_step = 1; */
John Koleszar's avatar
John Koleszar committed
131 132
    vp8_filter_block2d_bil_first_pass_armv6(src_ptr, FData, src_pixels_per_line, Height + 1, Width, HFilter);

133
    /* then 1-D vertically... */
John Koleszar's avatar
John Koleszar committed
134 135 136 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 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
    vp8_filter_block2d_bil_second_pass_armv6(FData, output_ptr, dst_pitch, Height, Width, VFilter);
}


void vp8_bilinear_predict4x4_armv6
(
    unsigned char  *src_ptr,
    int   src_pixels_per_line,
    int  xoffset,
    int  yoffset,
    unsigned char *dst_ptr,
    int dst_pitch
)
{
    const short  *HFilter;
    const short  *VFilter;

    HFilter = bilinear_filters[xoffset];
    VFilter = bilinear_filters[yoffset];

    vp8_filter_block2d_bil_armv6(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 4, 4);
}

void vp8_bilinear_predict8x8_armv6
(
    unsigned char  *src_ptr,
    int  src_pixels_per_line,
    int  xoffset,
    int  yoffset,
    unsigned char *dst_ptr,
    int  dst_pitch
)
{
    const short  *HFilter;
    const short  *VFilter;

    HFilter = bilinear_filters[xoffset];
    VFilter = bilinear_filters[yoffset];

    vp8_filter_block2d_bil_armv6(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 8, 8);
}

void vp8_bilinear_predict8x4_armv6
(
    unsigned char  *src_ptr,
    int  src_pixels_per_line,
    int  xoffset,
    int  yoffset,
    unsigned char *dst_ptr,
    int  dst_pitch
)
{
    const short  *HFilter;
    const short  *VFilter;

    HFilter = bilinear_filters[xoffset];
    VFilter = bilinear_filters[yoffset];

    vp8_filter_block2d_bil_armv6(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 8, 4);
}

void vp8_bilinear_predict16x16_armv6
(
    unsigned char  *src_ptr,
    int  src_pixels_per_line,
    int  xoffset,
    int  yoffset,
    unsigned char *dst_ptr,
    int  dst_pitch
)
{
    const short  *HFilter;
    const short  *VFilter;

    HFilter = bilinear_filters[xoffset];
    VFilter = bilinear_filters[yoffset];

    vp8_filter_block2d_bil_armv6(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 16, 16);
}