]> git.sesse.net Git - ffmpeg/blob - libavcodec/arm/dca.h
arm: get_cabac inline asm
[ffmpeg] / libavcodec / arm / dca.h
1 /*
2  * Copyright (c) 2011 Mans Rullgard <mans@mansr.com>
3  *
4  * This file is part of Libav.
5  *
6  * Libav is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * Libav is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with Libav; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20
21 #ifndef AVCODEC_ARM_DCA_H
22 #define AVCODEC_ARM_DCA_H
23
24 #include <stdint.h>
25
26 #include "config.h"
27 #include "libavcodec/dcadsp.h"
28 #include "libavcodec/mathops.h"
29
30 #if HAVE_ARMV6_INLINE && AV_GCC_VERSION_AT_LEAST(4,4)
31
32 #define decode_blockcodes decode_blockcodes
33 static inline int decode_blockcodes(int code1, int code2, int levels,
34                                     int32_t *values)
35 {
36     int32_t v0, v1, v2, v3, v4, v5;
37
38     __asm__ ("smmul   %8,  %14, %18           \n"
39              "smmul   %11, %15, %18           \n"
40              "smlabb  %14, %8,  %17, %14      \n"
41              "smlabb  %15, %11, %17, %15      \n"
42              "smmul   %9,  %8,  %18           \n"
43              "smmul   %12, %11, %18           \n"
44              "sub     %14, %14, %16, lsr #1   \n"
45              "sub     %15, %15, %16, lsr #1   \n"
46              "smlabb  %8,  %9,  %17, %8       \n"
47              "smlabb  %11, %12, %17, %11      \n"
48              "smmul   %10, %9,  %18           \n"
49              "smmul   %13, %12, %18           \n"
50              "str     %14, %0                 \n"
51              "str     %15, %4                 \n"
52              "sub     %8,  %8,  %16, lsr #1   \n"
53              "sub     %11, %11, %16, lsr #1   \n"
54              "smlabb  %9,  %10, %17, %9       \n"
55              "smlabb  %12, %13, %17, %12      \n"
56              "smmul   %14, %10, %18           \n"
57              "smmul   %15, %13, %18           \n"
58              "str     %8,  %1                 \n"
59              "str     %11, %5                 \n"
60              "sub     %9,  %9,  %16, lsr #1   \n"
61              "sub     %12, %12, %16, lsr #1   \n"
62              "smlabb  %10, %14, %17, %10      \n"
63              "smlabb  %13, %15, %17, %13      \n"
64              "str     %9,  %2                 \n"
65              "str     %12, %6                 \n"
66              "sub     %10, %10, %16, lsr #1   \n"
67              "sub     %13, %13, %16, lsr #1   \n"
68              "str     %10, %3                 \n"
69              "str     %13, %7                 \n"
70              : "=m"(values[0]), "=m"(values[1]),
71                "=m"(values[2]), "=m"(values[3]),
72                "=m"(values[4]), "=m"(values[5]),
73                "=m"(values[6]), "=m"(values[7]),
74                "=&r"(v0), "=&r"(v1), "=&r"(v2),
75                "=&r"(v3), "=&r"(v4), "=&r"(v5),
76                "+&r"(code1), "+&r"(code2)
77              : "r"(levels - 1), "r"(-levels), "r"(ff_inverse[levels]));
78
79     return code1 | code2;
80 }
81
82 #endif
83
84 #endif /* AVCODEC_ARM_DCA_H */