1 /* 2 * ac.h -- main aclib include 3 * Written by Andrew Church <achurch@achurch.org> 4 * 5 * This file is part of transcode, a video stream processing tool. 6 * transcode is free software, distributable under the terms of the GNU 7 * General Public License (version 2 or later). See the file COPYING 8 * for details. 9 */ 10 11 #ifndef ACLIB_AC_H 12 #define ACLIB_AC_H 13 14 #ifdef HAVE_CONFIG_H 15 # include "config.h" 16 #endif 17 18 #include <stddef.h> 19 #include <stdint.h> 20 #include <sys/types.h> 21 22 /*************************************************************************/ 23 24 /* CPU acceleration support flags, for use with ac_init(): */ 25 26 #define AC_IA32ASM 0x0001 /* x86-32: standard assembly (no MMX) */ 27 #define AC_AMD64ASM 0x0002 /* x86-64: standard assembly (no MMX) */ 28 #define AC_CMOVE 0x0004 /* x86: CMOVcc instruction */ 29 #define AC_MMX 0x0008 /* x86: MMX instructions */ 30 #define AC_MMXEXT 0x0010 /* x86: MMX extended instructions (AMD) */ 31 #define AC_3DNOW 0x0020 /* x86: 3DNow! instructions (AMD) */ 32 #define AC_3DNOWEXT 0x0040 /* x86: 3DNow! instructions (AMD) */ 33 #define AC_SSE 0x0080 /* x86: SSE instructions */ 34 #define AC_SSE2 0x0100 /* x86: SSE2 instructions */ 35 #define AC_SSE3 0x0200 /* x86: SSE3 instructions */ 36 #define AC_SSSE3 0x0400 /* x86: SSSE3 instructions */ 37 #define AC_SSE41 0x0800 /* x86: SSE4.1 instructions */ 38 #define AC_SSE42 0x1000 /* x86: SSE4.2 instructions (Intel) */ 39 #define AC_SSE4A 0x2000 /* x86: SSE4a instructions (AMD) */ 40 #define AC_SSE5 0x4000 /* x86: SSE5 instructions (AMD) */ 41 42 #define AC_NONE 0 /* No acceleration (vanilla C functions) */ 43 #define AC_ALL (~0) /* All available acceleration */ 44 45 46 /* Endianness flag: */ 47 #define AC_LITTLE_ENDIAN 1 48 #define AC_BIG_ENDIAN 2 49 50 /*************************************************************************/ 51 52 /* Library initialization function--MUST be called before any other aclib 53 * functions are used! `accel' selects the accelerations to enable: 54 * AC_NONE, AC_ALL, or a combination of the other AC_* flags above. The 55 * value will always be masked to the acceleration options available on the 56 * actual CPU, as returned by ac_cpuinfo(). Returns 1 on success, 0 on 57 * failure. This function can be called multiple times to change the set 58 * of acceleration features to be used. */ 59 extern int ac_init(int accel); 60 61 /* Returns the set of acceleration features supported by this CPU. */ 62 extern int ac_cpuinfo(void); 63 64 /* Returns the endianness of this CPU (AC_BIG_ENDIAN or AC_LITTLE_ENDIAN). */ 65 extern int ac_endian(void); 66 67 /* Utility routine to convert a set of flags to a descriptive string. The 68 * string is stored in a static buffer overwritten each call. */ 69 extern const char *ac_flagstotext(int accel); 70 71 /* Utility routine to parse a comma-separate descriptive string to the 72 corrisponding flag. The reverse of ac_flagstotext. 73 Returns 1 on success, 0 on failure */ 74 extern int ac_parseflags(const char *text, int *accel); 75 76 /*************************************************************************/ 77 78 /* Acceleration-enabled functions: */ 79 80 /* Optimized memcpy(). The copy direction is guaranteed to be ascending 81 * (so ac_memcpy(ptr, ptr+1, size) will work). */ 82 extern void *ac_memcpy(void *dest, const void *src, size_t size); 83 84 /* Average of two sets of data */ 85 extern void ac_average(const uint8_t *src1, const uint8_t *src2, 86 uint8_t *dest, int bytes); 87 88 /* Weighted average of two sets of data (weight1+weight2 should be 65536) */ 89 extern void ac_rescale(const uint8_t *src1, const uint8_t *src2, 90 uint8_t *dest, int bytes, 91 uint32_t weight1, uint32_t weight2); 92 93 /* Image format manipulation is available in aclib/imgconvert.h */ 94 95 /*************************************************************************/ 96 97 #endif /* ACLIB_AC_H */ 98 99 /* 100 * Local variables: 101 * c-file-style: "stroustrup" 102 * c-file-offsets: ((case-label . *) (statement-case-intro . *)) 103 * indent-tabs-mode: nil 104 * End: 105 * 106 * vim: expandtab shiftwidth=4: 107 */ 108