annotate aes.h @ 728:1fa3820b1a84 libavutil

ARM asm for AV_RN*() ARMv6 and later support unaligned loads and stores for single word/halfword but not double/multiple. GCC is ignorant of this and will always use bytewise accesses for unaligned data. Casting to an int32_t pointer is dangerous since a load/store double or multiple instruction might be used (this happens with some code in FFmpeg). Implementing the AV_[RW]* macros with inline asm using only supported instructions gives fast and safe unaligned accesses. ARM RVCT does the right thing with generic code. This gives an overall speedup of up to 10%.
author mru
date Sat, 18 Apr 2009 00:00:28 +0000
parents 0a51400a64c9
children e34e8d654ded
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
201
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
1 /*
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
2 * copyright (c) 2007 Michael Niedermayer <michaelni@gmx.at>
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
3 *
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
4 * This file is part of FFmpeg.
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
5 *
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
6 * FFmpeg is free software; you can redistribute it and/or
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
7 * modify it under the terms of the GNU Lesser General Public
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
8 * License as published by the Free Software Foundation; either
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
9 * version 2.1 of the License, or (at your option) any later version.
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
10 *
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
11 * FFmpeg is distributed in the hope that it will be useful,
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
14 * Lesser General Public License for more details.
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
15 *
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
16 * You should have received a copy of the GNU Lesser General Public
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
17 * License along with FFmpeg; if not, write to the Free Software
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
19 */
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
20
567
bd4052d9050c Globally rename the header inclusion guard names.
stefano
parents: 466
diff changeset
21 #ifndef AVUTIL_AES_H
bd4052d9050c Globally rename the header inclusion guard names.
stefano
parents: 466
diff changeset
22 #define AVUTIL_AES_H
201
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
23
343
f21d1907d47c include all prerequisites in header files
mru
parents: 341
diff changeset
24 #include <stdint.h>
f21d1907d47c include all prerequisites in header files
mru
parents: 341
diff changeset
25
206
cd7c6ff2132c remove dependancy on *malloc()
michael
parents: 202
diff changeset
26 extern const int av_aes_size;
cd7c6ff2132c remove dependancy on *malloc()
michael
parents: 202
diff changeset
27
201
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
28 struct AVAES;
921cee9e3a14 the missing header ...
michael
parents:
diff changeset
29
202
f80912b7cb09 av_aes_init()
michael
parents: 201
diff changeset
30 /**
466
f4fd038fcb58 misc spelling fixes
diego
parents: 392
diff changeset
31 * Initializes an AVAES context.
202
f80912b7cb09 av_aes_init()
michael
parents: 201
diff changeset
32 * @param key_bits 128, 192 or 256
f80912b7cb09 av_aes_init()
michael
parents: 201
diff changeset
33 * @param decrypt 0 for encryption, 1 for decryption
f80912b7cb09 av_aes_init()
michael
parents: 201
diff changeset
34 */
241
998d097d926d make key parameter const
bcoudurier
parents: 221
diff changeset
35 int av_aes_init(struct AVAES *a, const uint8_t *key, int key_bits, int decrypt);
202
f80912b7cb09 av_aes_init()
michael
parents: 201
diff changeset
36
217
10fffb98ff76 public API
michael
parents: 206
diff changeset
37 /**
466
f4fd038fcb58 misc spelling fixes
diego
parents: 392
diff changeset
38 * Encrypts / decrypts.
217
10fffb98ff76 public API
michael
parents: 206
diff changeset
39 * @param count number of 16 byte blocks
10fffb98ff76 public API
michael
parents: 206
diff changeset
40 * @param dst destination array, can be equal to src
10fffb98ff76 public API
michael
parents: 206
diff changeset
41 * @param src source array, can be equal to dst
341
53126d45b095 misc typo fixes
diego
parents: 241
diff changeset
42 * @param iv initialization vector for CBC mode, if NULL then ECB will be used
217
10fffb98ff76 public API
michael
parents: 206
diff changeset
43 * @param decrypt 0 for encryption, 1 for decryption
10fffb98ff76 public API
michael
parents: 206
diff changeset
44 */
635
0a51400a64c9 Add "const" to AES function arguments where possible without generating
reimar
parents: 567
diff changeset
45 void av_aes_crypt(struct AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt);
217
10fffb98ff76 public API
michael
parents: 206
diff changeset
46
567
bd4052d9050c Globally rename the header inclusion guard names.
stefano
parents: 466
diff changeset
47 #endif /* AVUTIL_AES_H */