]> git.sesse.net Git - ffmpeg/blob - libavutil/tomi/intreadwrite.h
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavutil / tomi / intreadwrite.h
1 /*
2  * Copyright (c) 2010 Mans Rullgard <mans@mansr.com>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg 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  * FFmpeg 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 FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20
21 #ifndef AVUTIL_TOMI_INTREADWRITE_H
22 #define AVUTIL_TOMI_INTREADWRITE_H
23
24 #include <stdint.h>
25 #include "config.h"
26
27 #define AV_RB16 AV_RB16
28 static av_always_inline uint16_t AV_RB16(const void *p)
29 {
30     uint16_t v;
31     __asm__ ("loadacc,   (%1+) \n\t"
32              "rol8             \n\t"
33              "storeacc,  %0    \n\t"
34              "loadacc,   (%1+) \n\t"
35              "add,       %0    \n\t"
36              : "=r"(v), "+a"(p));
37     return v;
38 }
39
40 #define AV_WB16 AV_WB16
41 static av_always_inline void AV_WB16(void *p, uint16_t v)
42 {
43     __asm__ volatile ("loadacc,   %1    \n\t"
44                       "lsr8             \n\t"
45                       "storeacc,  (%0+) \n\t"
46                       "loadacc,   %1    \n\t"
47                       "storeacc,  (%0+) \n\t"
48                       : "+&a"(p) : "r"(v));
49 }
50
51 #define AV_RL16 AV_RL16
52 static av_always_inline uint16_t AV_RL16(const void *p)
53 {
54     uint16_t v;
55     __asm__ ("loadacc,   (%1+) \n\t"
56              "storeacc,  %0    \n\t"
57              "loadacc,   (%1+) \n\t"
58              "rol8             \n\t"
59              "add,       %0    \n\t"
60              : "=r"(v), "+a"(p));
61     return v;
62 }
63
64 #define AV_WL16 AV_WL16
65 static av_always_inline void AV_WL16(void *p, uint16_t v)
66 {
67     __asm__ volatile ("loadacc,   %1    \n\t"
68                       "storeacc,  (%0+) \n\t"
69                       "lsr8             \n\t"
70                       "storeacc,  (%0+) \n\t"
71                       : "+&a"(p) : "r"(v));
72 }
73
74 #define AV_RB32 AV_RB32
75 static av_always_inline uint32_t AV_RB32(const void *p)
76 {
77     uint32_t v;
78     __asm__ ("loadacc,   (%1+) \n\t"
79              "rol8             \n\t"
80              "rol8             \n\t"
81              "rol8             \n\t"
82              "storeacc,  %0    \n\t"
83              "loadacc,   (%1+) \n\t"
84              "rol8             \n\t"
85              "rol8             \n\t"
86              "add,       %0    \n\t"
87              "loadacc,   (%1+) \n\t"
88              "rol8             \n\t"
89              "add,       %0    \n\t"
90              "loadacc,   (%1+) \n\t"
91              "add,       %0    \n\t"
92              : "=r"(v), "+a"(p));
93     return v;
94 }
95
96 #define AV_WB32 AV_WB32
97 static av_always_inline void AV_WB32(void *p, uint32_t v)
98 {
99     __asm__ volatile ("loadacc,   #4    \n\t"
100                       "add,       %0    \n\t"
101                       "loadacc,   %1    \n\t"
102                       "storeacc,  (-%0) \n\t"
103                       "lsr8             \n\t"
104                       "storeacc,  (-%0) \n\t"
105                       "lsr8             \n\t"
106                       "storeacc,  (-%0) \n\t"
107                       "lsr8             \n\t"
108                       "storeacc,  (-%0) \n\t"
109                       : "+&a"(p) : "r"(v));
110 }
111
112 #define AV_RL32 AV_RL32
113 static av_always_inline uint32_t AV_RL32(const void *p)
114 {
115     uint32_t v;
116     __asm__ ("loadacc,   (%1+) \n\t"
117              "storeacc,  %0    \n\t"
118              "loadacc,   (%1+) \n\t"
119              "rol8             \n\t"
120              "add,       %0    \n\t"
121              "loadacc,   (%1+) \n\t"
122              "rol8             \n\t"
123              "rol8             \n\t"
124              "add,       %0    \n\t"
125              "loadacc,   (%1+) \n\t"
126              "rol8             \n\t"
127              "rol8             \n\t"
128              "rol8             \n\t"
129              "add,       %0    \n\t"
130              : "=r"(v), "+a"(p));
131     return v;
132 }
133
134 #define AV_WL32 AV_WL32
135 static av_always_inline void AV_WL32(void *p, uint32_t v)
136 {
137     __asm__ volatile ("loadacc,   %1    \n\t"
138                       "storeacc,  (%0+) \n\t"
139                       "lsr8             \n\t"
140                       "storeacc,  (%0+) \n\t"
141                       "lsr8             \n\t"
142                       "storeacc,  (%0+) \n\t"
143                       "lsr8             \n\t"
144                       "storeacc,  (%0+) \n\t"
145                       : "+&a"(p) : "r"(v));
146 }
147
148 #endif /* AVUTIL_TOMI_INTREADWRITE_H */