Update contrib.
2 * LIBOIL - Library of Optimized Inner Loops
3 * Copyright (c) 2003,2004 David A. Schleef <ds@schleef.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
27 //Portions Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
33 #include <liboil/liboil.h>
43 * Reorders an 8x8 block using a zig-zag pattern. The zig-zag pattern
44 * is described in the JPEG specification.
46 * FIXME: describe zigzag pattern
48 OIL_DEFINE_CLASS (zigzag8x8_s16,
49 "int16_t *d_8x8, int ds, int16_t *s_8x8, int ss");
51 * oil_unzigzag8x8_s16:
57 * Reorders an 8x8 block to reverse the zig-zag reordering of
60 OIL_DEFINE_CLASS (unzigzag8x8_s16,
61 "int16_t *d_8x8, int ds, int16_t *s_8x8, int ss");
65 #define BLOCK8x8_S16(ptr, stride, row, column) \
66 (*((int16_t *)((void *)ptr + stride*row) + column))
68 static const unsigned char zigzag_order[64] = {
74 40, 33, 26, 19, 12, 5,
75 6, 13, 20, 27, 34, 41, 48,
76 56, 49, 42, 35, 28, 21, 14, 7,
77 15, 22, 29, 36, 43, 50, 57,
78 58, 51, 44, 37, 30, 23,
86 static const unsigned char unzigzag_order[64] = {
87 0, 1, 5, 6, 14, 15, 27, 28,
88 2, 4, 7, 13, 16, 26, 29, 42,
89 3, 8, 12, 17, 25, 30, 41, 43,
90 9, 11, 18, 24, 31, 40, 44, 53,
91 10, 19, 23, 32, 39, 45, 52, 54,
92 20, 22, 33, 38, 46, 51, 55, 60,
93 21, 34, 37, 47, 50, 56, 59, 61,
94 35, 36, 48, 49, 57, 58, 62, 63,
99 zigzag8x8_s16_ref(int16_t *dest, int dstr, int16_t *src, int sstr)
106 z = zigzag_order[j*8+i];
107 OIL_GET(dest,j*dstr +i*sizeof(int16_t), int16_t) =
108 OIL_GET(src, sstr*(z>>3)+(z&7)*sizeof(int16_t),
113 OIL_DEFINE_IMPL_REF (zigzag8x8_s16_ref, zigzag8x8_s16);
116 unzigzag8x8_s16_ref (int16_t *dest, int dstr, int16_t *src, int sstr)
123 z = unzigzag_order[i*8+j];
124 OIL_GET(dest,j*dstr +i*sizeof(int16_t), int16_t) =
125 OIL_GET(src, sstr*(z>>3)+(z&7)*sizeof(int16_t),
130 OIL_DEFINE_IMPL_REF (unzigzag8x8_s16_ref, unzigzag8x8_s16);
134 zigzag8x8_s16_unroll (int16_t *dest, int dstr, int16_t *src, int sstr)
137 OIL_GET(dest, ((x)>>3) * dstr + ((x)&7) * sizeof(int16_t), int16_t) = \
138 OIL_GET(src, ((y)>>3) * sstr + ((y)&7) * sizeof(int16_t), int16_t);
205 OIL_DEFINE_IMPL (zigzag8x8_s16_unroll, zigzag8x8_s16);
208 unzigzag8x8_s16_unroll (int16_t *dest, int dstr, int16_t *src, int sstr)
275 OIL_DEFINE_IMPL (unzigzag8x8_s16_unroll, unzigzag8x8_s16);
280 OilFunctionClass* __oil_function_class_zigzag8x8_s16() {
281 return &_oil_function_class_zigzag8x8_s16;
287 OilFunctionClass* __oil_function_class_unzigzag8x8_s16() {
288 return &_oil_function_class_unzigzag8x8_s16;
296 OilFunctionImpl* __oil_function_impl_zigzag8x8_s16_ref() {
297 return &_oil_function_impl_zigzag8x8_s16_ref;
303 OilFunctionImpl* __oil_function_impl_unzigzag8x8_s16_ref() {
304 return &_oil_function_impl_unzigzag8x8_s16_ref;
310 OilFunctionImpl* __oil_function_impl_zigzag8x8_s16_unroll() {
311 return &_oil_function_impl_zigzag8x8_s16_unroll;
317 OilFunctionImpl* __oil_function_impl_unzigzag8x8_s16_unroll() {
318 return &_oil_function_impl_unzigzag8x8_s16_unroll;
326 EXPORT_C void** _oil_function_class_ptr_zigzag8x8_s16 () {
327 oil_function_class_ptr_zigzag8x8_s16 = __oil_function_class_zigzag8x8_s16();
328 return &oil_function_class_ptr_zigzag8x8_s16->func;
334 EXPORT_C void** _oil_function_class_ptr_unzigzag8x8_s16 () {
335 oil_function_class_ptr_unzigzag8x8_s16 = __oil_function_class_unzigzag8x8_s16();
336 return &oil_function_class_ptr_unzigzag8x8_s16->func;