1 /* vectorize.h, this file is part of the
2  * AltiVec optimized library for MJPEG tools MPEG-1/2 Video Encoder
3  * Copyright (C) 2002  James Klicman <james@klicman.org>
4  *
5  * This library is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19 
20 /*
21  * Useful AltiVec macros
22  *
23  */
24 
25 #define VECTOR_ALIGNED(p) (((unsigned long)(p) & 15) == 0)
26 #define NOT_VECTOR_ALIGNED(p) (((unsigned long)(p) & 15) != 0)
27 
28 #define VECTOR_OFFSET(p) ((((unsigned long)(p))+15) & (~15))
29 
30 #define vs8(v)  ((vector signed char)(v))
31 #define vs16(v) ((vector signed short)(v))
32 #define vs32(v) ((vector signed int)(v))
33 #define vu8(v)  ((vector unsigned char)(v))
34 #define vu16(v) ((vector unsigned short)(v))
35 #define vu32(v) ((vector unsigned int)(v))
36 #define vb8(v)  ((vector bool char)(v))
37 #define vb16(v) ((vector bool short)(v))
38 #define vb32(v) ((vector bool int)(v))
39 #define vpx(v)  ((vector pixel)(v))
40 #define vfp(v)  ((vector float)(v))
41 
42 
43 typedef union {
44     unsigned int control;
45     struct {
46         unsigned char size;  /* 0 to 31, (size & 0x1F) */
47         unsigned char count; /* 0 to 255 */
48         signed short stride; /* -32768 to +32768 */
49     } block;
50 } DataStreamControl;
51 
52 #define DATA_STREAM_CONTROL(size,count,stride) \
53     ((((size)&0x1F)<<24)|(((count)&0xFF)<<16)|((stride)&0xFFFF))
54 
55 #ifdef HAVE_ALTIVEC_H
56 /* GNU GCC3 style vector constants */
57 #define VCONST(v...) {v}
58 #else
59 /* Motorola style vector constants */
60 #define VCONST(v...) (v)
61 #endif
62