1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/liboil/src/jpeg/zigzag8x8_c.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,339 @@
1.4 +/*
1.5 + * LIBOIL - Library of Optimized Inner Loops
1.6 + * Copyright (c) 2003,2004 David A. Schleef <ds@schleef.org>
1.7 + * All rights reserved.
1.8 + *
1.9 + * Redistribution and use in source and binary forms, with or without
1.10 + * modification, are permitted provided that the following conditions
1.11 + * are met:
1.12 + * 1. Redistributions of source code must retain the above copyright
1.13 + * notice, this list of conditions and the following disclaimer.
1.14 + * 2. Redistributions in binary form must reproduce the above copyright
1.15 + * notice, this list of conditions and the following disclaimer in the
1.16 + * documentation and/or other materials provided with the distribution.
1.17 + *
1.18 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1.19 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1.20 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1.21 + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
1.22 + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1.23 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1.24 + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1.25 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
1.26 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
1.27 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1.28 + * POSSIBILITY OF SUCH DAMAGE.
1.29 + */
1.30 +//Portions Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
1.31 +
1.32 +#ifdef HAVE_CONFIG_H
1.33 +#include "config.h"
1.34 +#endif
1.35 +
1.36 +#include <liboil/liboil.h>
1.37 +#include "jpeg.h"
1.38 +
1.39 +/**
1.40 + * oil_zigzag8x8_s16:
1.41 + * @d_8x8:
1.42 + * @ds:
1.43 + * @s_8x8:
1.44 + * @ss:
1.45 + *
1.46 + * Reorders an 8x8 block using a zig-zag pattern. The zig-zag pattern
1.47 + * is described in the JPEG specification.
1.48 + *
1.49 + * FIXME: describe zigzag pattern
1.50 + */
1.51 +OIL_DEFINE_CLASS (zigzag8x8_s16,
1.52 + "int16_t *d_8x8, int ds, int16_t *s_8x8, int ss");
1.53 +/**
1.54 + * oil_unzigzag8x8_s16:
1.55 + * @d_8x8:
1.56 + * @ds:
1.57 + * @s_8x8:
1.58 + * @ss:
1.59 + *
1.60 + * Reorders an 8x8 block to reverse the zig-zag reordering of
1.61 + * @oil_zigzag8x8_s16.
1.62 + */
1.63 +OIL_DEFINE_CLASS (unzigzag8x8_s16,
1.64 + "int16_t *d_8x8, int ds, int16_t *s_8x8, int ss");
1.65 +
1.66 +
1.67 +
1.68 +#define BLOCK8x8_S16(ptr, stride, row, column) \
1.69 + (*((int16_t *)((void *)ptr + stride*row) + column))
1.70 +
1.71 +static const unsigned char zigzag_order[64] = {
1.72 + 0,
1.73 + 8, 1,
1.74 + 2, 9, 16,
1.75 + 24, 17, 10, 3,
1.76 + 4, 11, 18, 25, 32,
1.77 + 40, 33, 26, 19, 12, 5,
1.78 + 6, 13, 20, 27, 34, 41, 48,
1.79 + 56, 49, 42, 35, 28, 21, 14, 7,
1.80 + 15, 22, 29, 36, 43, 50, 57,
1.81 + 58, 51, 44, 37, 30, 23,
1.82 + 31, 38, 45, 52, 59,
1.83 + 60, 53, 46, 39,
1.84 + 47, 54, 61,
1.85 + 62, 55,
1.86 + 63
1.87 +};
1.88 +
1.89 +static const unsigned char unzigzag_order[64] = {
1.90 + 0, 1, 5, 6, 14, 15, 27, 28,
1.91 + 2, 4, 7, 13, 16, 26, 29, 42,
1.92 + 3, 8, 12, 17, 25, 30, 41, 43,
1.93 + 9, 11, 18, 24, 31, 40, 44, 53,
1.94 + 10, 19, 23, 32, 39, 45, 52, 54,
1.95 + 20, 22, 33, 38, 46, 51, 55, 60,
1.96 + 21, 34, 37, 47, 50, 56, 59, 61,
1.97 + 35, 36, 48, 49, 57, 58, 62, 63,
1.98 +};
1.99 +
1.100 +
1.101 +static void
1.102 +zigzag8x8_s16_ref(int16_t *dest, int dstr, int16_t *src, int sstr)
1.103 +{
1.104 + int i,j;
1.105 + unsigned int z;
1.106 +
1.107 + for(j=0;j<8;j++){
1.108 + for(i=0;i<8;i++){
1.109 + z = zigzag_order[j*8+i];
1.110 + OIL_GET(dest,j*dstr +i*sizeof(int16_t), int16_t) =
1.111 + OIL_GET(src, sstr*(z>>3)+(z&7)*sizeof(int16_t),
1.112 + int16_t);
1.113 + }
1.114 + }
1.115 +}
1.116 +OIL_DEFINE_IMPL_REF (zigzag8x8_s16_ref, zigzag8x8_s16);
1.117 +
1.118 +static void
1.119 +unzigzag8x8_s16_ref (int16_t *dest, int dstr, int16_t *src, int sstr)
1.120 +{
1.121 + int i,j;
1.122 + unsigned int z;
1.123 +
1.124 + for(i=0;i<8;i++){
1.125 + for(j=0;j<8;j++){
1.126 + z = unzigzag_order[i*8+j];
1.127 + OIL_GET(dest,j*dstr +i*sizeof(int16_t), int16_t) =
1.128 + OIL_GET(src, sstr*(z>>3)+(z&7)*sizeof(int16_t),
1.129 + int16_t);
1.130 + }
1.131 + }
1.132 +}
1.133 +OIL_DEFINE_IMPL_REF (unzigzag8x8_s16_ref, unzigzag8x8_s16);
1.134 +
1.135 +
1.136 +static void
1.137 +zigzag8x8_s16_unroll (int16_t *dest, int dstr, int16_t *src, int sstr)
1.138 +{
1.139 +#define ACK(x,y) \
1.140 + OIL_GET(dest, ((x)>>3) * dstr + ((x)&7) * sizeof(int16_t), int16_t) = \
1.141 + OIL_GET(src, ((y)>>3) * sstr + ((y)&7) * sizeof(int16_t), int16_t);
1.142 +
1.143 + ACK(0, 0);
1.144 + ACK(1, 8);
1.145 + ACK(2, 1);
1.146 + ACK(3, 2);
1.147 + ACK(4, 9);
1.148 + ACK(5, 16);
1.149 + ACK(6, 24);
1.150 + ACK(7, 17);
1.151 + ACK(8, 10);
1.152 + ACK(9, 3);
1.153 + ACK(10, 4);
1.154 + ACK(11, 11);
1.155 + ACK(12, 18);
1.156 + ACK(13, 25);
1.157 + ACK(14, 32);
1.158 + ACK(15, 40);
1.159 + ACK(16, 33);
1.160 + ACK(17, 26);
1.161 + ACK(18, 19);
1.162 + ACK(19, 12);
1.163 + ACK(20, 5);
1.164 + ACK(21, 6);
1.165 + ACK(22, 13);
1.166 + ACK(23, 20);
1.167 + ACK(24, 27);
1.168 + ACK(25, 34);
1.169 + ACK(26, 41);
1.170 + ACK(27, 48);
1.171 + ACK(28, 56);
1.172 + ACK(29, 49);
1.173 + ACK(30, 42);
1.174 + ACK(31, 35);
1.175 + ACK(32, 28);
1.176 + ACK(33, 21);
1.177 + ACK(34, 14);
1.178 + ACK(35, 7);
1.179 + ACK(36, 15);
1.180 + ACK(37, 22);
1.181 + ACK(38, 29);
1.182 + ACK(39, 36);
1.183 + ACK(40, 43);
1.184 + ACK(41, 50);
1.185 + ACK(42, 57);
1.186 + ACK(43, 58);
1.187 + ACK(44, 51);
1.188 + ACK(45, 44);
1.189 + ACK(46, 37);
1.190 + ACK(47, 30);
1.191 + ACK(48, 23);
1.192 + ACK(49, 31);
1.193 + ACK(50, 38);
1.194 + ACK(51, 45);
1.195 + ACK(52, 52);
1.196 + ACK(53, 59);
1.197 + ACK(54, 60);
1.198 + ACK(55, 53);
1.199 + ACK(56, 46);
1.200 + ACK(57, 39);
1.201 + ACK(58, 47);
1.202 + ACK(59, 54);
1.203 + ACK(60, 61);
1.204 + ACK(61, 62);
1.205 + ACK(62, 55);
1.206 + ACK(63, 63);
1.207 +}
1.208 +OIL_DEFINE_IMPL (zigzag8x8_s16_unroll, zigzag8x8_s16);
1.209 +
1.210 +static void
1.211 +unzigzag8x8_s16_unroll (int16_t *dest, int dstr, int16_t *src, int sstr)
1.212 +{
1.213 + ACK(0, 0)
1.214 + ACK(1, 2)
1.215 + ACK(2, 3)
1.216 + ACK(3, 9)
1.217 + ACK(4, 10)
1.218 + ACK(5, 20)
1.219 + ACK(6, 21)
1.220 + ACK(7, 35)
1.221 + ACK(8, 1)
1.222 + ACK(9, 4)
1.223 + ACK(10, 8)
1.224 + ACK(11, 11)
1.225 + ACK(12, 19)
1.226 + ACK(13, 22)
1.227 + ACK(14, 34)
1.228 + ACK(15, 36)
1.229 + ACK(16, 5)
1.230 + ACK(17, 7)
1.231 + ACK(18, 12)
1.232 + ACK(19, 18)
1.233 + ACK(20, 23)
1.234 + ACK(21, 33)
1.235 + ACK(22, 37)
1.236 + ACK(23, 48)
1.237 + ACK(24, 6)
1.238 + ACK(25, 13)
1.239 + ACK(26, 17)
1.240 + ACK(27, 24)
1.241 + ACK(28, 32)
1.242 + ACK(29, 38)
1.243 + ACK(30, 47)
1.244 + ACK(31, 49)
1.245 + ACK(32, 14)
1.246 + ACK(33, 16)
1.247 + ACK(34, 25)
1.248 + ACK(35, 31)
1.249 + ACK(36, 39)
1.250 + ACK(37, 46)
1.251 + ACK(38, 50)
1.252 + ACK(39, 57)
1.253 + ACK(40, 15)
1.254 + ACK(41, 26)
1.255 + ACK(42, 30)
1.256 + ACK(43, 40)
1.257 + ACK(44, 45)
1.258 + ACK(45, 51)
1.259 + ACK(46, 56)
1.260 + ACK(47, 58)
1.261 + ACK(48, 27)
1.262 + ACK(49, 29)
1.263 + ACK(50, 41)
1.264 + ACK(51, 44)
1.265 + ACK(52, 52)
1.266 + ACK(53, 55)
1.267 + ACK(54, 59)
1.268 + ACK(55, 62)
1.269 + ACK(56, 28)
1.270 + ACK(57, 42)
1.271 + ACK(58, 43)
1.272 + ACK(59, 53)
1.273 + ACK(60, 54)
1.274 + ACK(61, 60)
1.275 + ACK(62, 61)
1.276 + ACK(63, 63)
1.277 +}
1.278 +OIL_DEFINE_IMPL (unzigzag8x8_s16_unroll, unzigzag8x8_s16);
1.279 +
1.280 +
1.281 +#ifdef __SYMBIAN32__
1.282 +
1.283 +OilFunctionClass* __oil_function_class_zigzag8x8_s16() {
1.284 + return &_oil_function_class_zigzag8x8_s16;
1.285 +}
1.286 +#endif
1.287 +
1.288 +#ifdef __SYMBIAN32__
1.289 +
1.290 +OilFunctionClass* __oil_function_class_unzigzag8x8_s16() {
1.291 + return &_oil_function_class_unzigzag8x8_s16;
1.292 +}
1.293 +#endif
1.294 +
1.295 +
1.296 +
1.297 +#ifdef __SYMBIAN32__
1.298 +
1.299 +OilFunctionImpl* __oil_function_impl_zigzag8x8_s16_ref() {
1.300 + return &_oil_function_impl_zigzag8x8_s16_ref;
1.301 +}
1.302 +#endif
1.303 +
1.304 +#ifdef __SYMBIAN32__
1.305 +
1.306 +OilFunctionImpl* __oil_function_impl_unzigzag8x8_s16_ref() {
1.307 + return &_oil_function_impl_unzigzag8x8_s16_ref;
1.308 +}
1.309 +#endif
1.310 +
1.311 +#ifdef __SYMBIAN32__
1.312 +
1.313 +OilFunctionImpl* __oil_function_impl_zigzag8x8_s16_unroll() {
1.314 + return &_oil_function_impl_zigzag8x8_s16_unroll;
1.315 +}
1.316 +#endif
1.317 +
1.318 +#ifdef __SYMBIAN32__
1.319 +
1.320 +OilFunctionImpl* __oil_function_impl_unzigzag8x8_s16_unroll() {
1.321 + return &_oil_function_impl_unzigzag8x8_s16_unroll;
1.322 +}
1.323 +#endif
1.324 +
1.325 +
1.326 +
1.327 +#ifdef __SYMBIAN32__
1.328 +
1.329 +EXPORT_C void** _oil_function_class_ptr_zigzag8x8_s16 () {
1.330 + oil_function_class_ptr_zigzag8x8_s16 = __oil_function_class_zigzag8x8_s16();
1.331 + return &oil_function_class_ptr_zigzag8x8_s16->func;
1.332 + }
1.333 +#endif
1.334 +
1.335 +#ifdef __SYMBIAN32__
1.336 +
1.337 +EXPORT_C void** _oil_function_class_ptr_unzigzag8x8_s16 () {
1.338 + oil_function_class_ptr_unzigzag8x8_s16 = __oil_function_class_unzigzag8x8_s16();
1.339 + return &oil_function_class_ptr_unzigzag8x8_s16->func;
1.340 + }
1.341 +#endif
1.342 +