diff options
author | James Almer <jamrial@gmail.com> | 2025-04-01 12:11:56 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2025-04-05 20:46:40 -0300 |
commit | 3f30ae823e27e7a60c693b52ad44b10ac2ad2823 (patch) | |
tree | 97bfe42475db05481227377b4d7335204817a342 | |
parent | fe73b84879a560d69affca88ce21e61108e7c38d (diff) | |
download | ffmpeg-3f30ae823e27e7a60c693b52ad44b10ac2ad2823.tar.gz |
avutil/aes_ctr: simplify incrementing the counter
Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r-- | libavutil/aes_ctr.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/libavutil/aes_ctr.c b/libavutil/aes_ctr.c index d720aa6aaf..63dcb20d3a 100644 --- a/libavutil/aes_ctr.c +++ b/libavutil/aes_ctr.c @@ -32,7 +32,7 @@ #define AES_BLOCK_SIZE (16) typedef struct AVAESCTR { - uint8_t counter[AES_BLOCK_SIZE]; + DECLARE_ALIGNED(8, uint8_t, counter)[AES_BLOCK_SIZE]; DECLARE_ALIGNED(8, uint8_t, encrypted_counter)[AES_BLOCK_SIZE]; AVAES aes; } AVAESCTR; @@ -82,16 +82,10 @@ void av_aes_ctr_free(struct AVAESCTR *a) av_free(a); } -static void av_aes_ctr_increment_be64(uint8_t* counter) +static inline void av_aes_ctr_increment_be64(uint8_t* counter) { - uint8_t* cur_pos; - - for (cur_pos = counter + 7; cur_pos >= counter; cur_pos--) { - (*cur_pos)++; - if (*cur_pos != 0) { - break; - } - } + uint64_t c = AV_RB64A(counter) + 1; + AV_WB64A(counter, c); } void av_aes_ctr_increment_iv(struct AVAESCTR *a) |