summaryrefslogtreecommitdiffstats
path: root/debian/transcode/transcode-1.1.7/aclib/ac.h
blob: d2a542b28b93ae12b6c72c8bb627490fce85c09f (plain)
1
2
3
4
5
6
7
8
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
 * ac.h -- main aclib include
 * Written by Andrew Church <achurch@achurch.org>
 *
 * This file is part of transcode, a video stream processing tool.
 * transcode is free software, distributable under the terms of the GNU
 * General Public License (version 2 or later).  See the file COPYING
 * for details.
 */

#ifndef ACLIB_AC_H
#define ACLIB_AC_H

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>

/*************************************************************************/

/* CPU acceleration support flags, for use with ac_init(): */

#define AC_IA32ASM      0x0001  /* x86-32: standard assembly (no MMX) */
#define AC_AMD64ASM     0x0002  /* x86-64: standard assembly (no MMX) */
#define AC_CMOVE        0x0004  /* x86: CMOVcc instruction */
#define AC_MMX          0x0008  /* x86: MMX instructions */
#define AC_MMXEXT       0x0010  /* x86: MMX extended instructions (AMD) */
#define AC_3DNOW        0x0020  /* x86: 3DNow! instructions (AMD) */
#define AC_3DNOWEXT     0x0040  /* x86: 3DNow! instructions (AMD) */
#define AC_SSE          0x0080  /* x86: SSE instructions */
#define AC_SSE2         0x0100  /* x86: SSE2 instructions */
#define AC_SSE3         0x0200  /* x86: SSE3 instructions */
#define AC_SSSE3        0x0400  /* x86: SSSE3 instructions */
#define AC_SSE41        0x0800  /* x86: SSE4.1 instructions */
#define AC_SSE42        0x1000  /* x86: SSE4.2 instructions (Intel) */
#define AC_SSE4A        0x2000  /* x86: SSE4a instructions (AMD) */
#define AC_SSE5         0x4000  /* x86: SSE5 instructions (AMD) */

#define AC_NONE         0       /* No acceleration (vanilla C functions) */
#define AC_ALL          (~0)    /* All available acceleration */


/* Endianness flag: */
#define AC_LITTLE_ENDIAN        1
#define AC_BIG_ENDIAN           2

/*************************************************************************/

/* Library initialization function--MUST be called before any other aclib
 * functions are used!  `accel' selects the accelerations to enable:
 * AC_NONE, AC_ALL, or a combination of the other AC_* flags above.  The
 * value will always be masked to the acceleration options available on the
 * actual CPU, as returned by ac_cpuinfo().  Returns 1 on success, 0 on
 * failure.  This function can be called multiple times to change the set
 * of acceleration features to be used. */
extern int ac_init(int accel);

/* Returns the set of acceleration features supported by this CPU. */
extern int ac_cpuinfo(void);

/* Returns the endianness of this CPU (AC_BIG_ENDIAN or AC_LITTLE_ENDIAN). */
extern int ac_endian(void);

/* Utility routine to convert a set of flags to a descriptive string.  The
 * string is stored in a static buffer overwritten each call. */
extern const char *ac_flagstotext(int accel);

/* Utility routine to parse a comma-separate descriptive string to the
   corrisponding flag. The reverse of ac_flagstotext.
   Returns 1 on success, 0 on failure */
extern int ac_parseflags(const char *text, int *accel);

/*************************************************************************/

/* Acceleration-enabled functions: */

/* Optimized memcpy().  The copy direction is guaranteed to be ascending
 * (so ac_memcpy(ptr, ptr+1, size) will work). */
extern void *ac_memcpy(void *dest, const void *src, size_t size);

/* Average of two sets of data */
extern void ac_average(const uint8_t *src1, const uint8_t *src2,
                       uint8_t *dest, int bytes);

/* Weighted average of two sets of data (weight1+weight2 should be 65536) */
extern void ac_rescale(const uint8_t *src1, const uint8_t *src2,
                       uint8_t *dest, int bytes,
                       uint32_t weight1, uint32_t weight2);

/* Image format manipulation is available in aclib/imgconvert.h */

/*************************************************************************/

#endif  /* ACLIB_AC_H */

/*
 * Local variables:
 *   c-file-style: "stroustrup"
 *   c-file-offsets: ((case-label . *) (statement-case-intro . *))
 *   indent-tabs-mode: nil
 * End:
 *
 * vim: expandtab shiftwidth=4:
 */