annotate x86/intmath.h @ 914:66b39cb91dde libavutil

bswap: add macros to byteswap constants The normal byteswap functions might use inline asm which is suboptimal with constants (and cannot be used in static initialisers), so special macros for constants only is needed. We should not rely on the gcc __builtin_constant_p() test since it is not always available.
author mru
date Thu, 29 Apr 2010 14:41:20 +0000
parents 4d9ad0ed07d0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
816
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
1 /*
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
2 * Copyright (c) 2010 Mans Rullgard <mans@mansr.com>
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
3 *
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
4 * This file is part of FFmpeg.
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
5 *
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
6 * FFmpeg is free software; you can redistribute it and/or
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
7 * modify it under the terms of the GNU Lesser General Public
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
8 * License as published by the Free Software Foundation; either
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
9 * version 2.1 of the License, or (at your option) any later version.
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
10 *
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
11 * FFmpeg is distributed in the hope that it will be useful,
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
14 * Lesser General Public License for more details.
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
15 *
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
16 * You should have received a copy of the GNU Lesser General Public
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
17 * License along with FFmpeg; if not, write to the Free Software
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
19 */
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
20
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
21 #ifndef AVUTIL_X86_INTMATH_H
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
22 #define AVUTIL_X86_INTMATH_H
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
23
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
24 #define FASTDIV(a,b) \
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
25 ({\
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
26 int ret, dmy;\
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
27 __asm__ volatile(\
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
28 "mull %3"\
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
29 :"=d"(ret), "=a"(dmy)\
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
30 :"1"(a), "g"(ff_inverse[b])\
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
31 );\
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
32 ret;\
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
33 })
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
34
d87093e4b925 Move FASTDIV macro to intmath.h
mru
parents:
diff changeset
35 #endif /* AVUTIL_X86_INTMATH_H */