Announced in e435beb1ea5380a90774dbf51fdc8c941e486551.
Unified · Split
| @@ -41,12 +41,7 @@ · 40 unmodified lines | ||
| 41 | 41 | #define DO4(buf) DO1(buf); DO1(buf); DO1(buf); DO1(buf); |
| 42 | 42 | #define DO16(buf) DO4(buf); DO4(buf); DO4(buf); DO4(buf); |
| 43 | 43 | |
| 44 | −#if FF_API_CRYPTO_SIZE_T | |
| 45 | −unsigned long av_adler32_update(unsigned long adler, const uint8_t * buf, | |
| 46 | − unsigned int len) | |
| 47 | −#else | |
| 48 | 44 | AVAdler av_adler32_update(AVAdler adler, const uint8_t *buf, size_t len) |
| 49 | −#endif | |
| 50 | 45 | { |
| 51 | 46 | unsigned long s1 = adler & 0xffff; |
| 52 | 47 | unsigned long s2 = adler >> 16; |
| @@ -30,7 +30,6 @@ · 29 unmodified lines | ||
| 30 | 30 | #include <stddef.h> |
| 31 | 31 | #include <stdint.h> |
| 32 | 32 | #include "attributes.h" |
| 33 | −#include "version.h" | |
| 34 | 33 | |
| 35 | 34 | /** |
| 36 | 35 | * @defgroup lavu_adler32 Adler-32 |
| @@ -40,11 +39,7 @@ · 3 unmodified lines | ||
| 40 | 39 | * @{ |
| 41 | 40 | */ |
| 42 | 41 | |
| 43 | −#if FF_API_CRYPTO_SIZE_T | |
| 44 | −typedef unsigned long AVAdler; | |
| 45 | −#else | |
| 46 | 42 | typedef uint32_t AVAdler; |
| 47 | −#endif | |
| 48 | 43 | |
| 49 | 44 | /** |
| 50 | 45 | * Calculate the Adler32 checksum of a buffer. |
| @@ -59,11 +54,7 @@ typedef uint32_t AVAdler; · 8 unmodified lines | ||
| 59 | 54 | * @return updated checksum |
| 60 | 55 | */ |
| 61 | 56 | AVAdler av_adler32_update(AVAdler adler, const uint8_t *buf, |
| 62 | −#if FF_API_CRYPTO_SIZE_T | |
| 63 | − unsigned int len) av_pure; | |
| 64 | −#else | |
| 65 | 57 | size_t len) av_pure; |
| 66 | −#endif | |
| 67 | 58 | |
| 68 | 59 | /** |
| 69 | 60 | * @} |
| @@ -157,11 +157,7 @@ void av_hash_init(AVHashContext *ctx) · 156 unmodified lines | ||
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | −#if FF_API_CRYPTO_SIZE_T | |
| 161 | −void av_hash_update(AVHashContext *ctx, const uint8_t *src, int len) | |
| 162 | −#else | |
| 163 | 160 | void av_hash_update(AVHashContext *ctx, const uint8_t *src, size_t len) |
| 164 | −#endif | |
| 165 | 161 | { |
| 166 | 162 | switch (ctx->type) { |
| 167 | 163 | case MD5: av_md5_update(ctx->ctx, src, len); break; |
| @@ -182,11 +182,7 @@ void av_hash_init(struct AVHashContext *ctx); · 181 unmodified lines | ||
| 182 | 182 | * @param[in] src Data to be added to the hash context |
| 183 | 183 | * @param[in] len Size of the additional data |
| 184 | 184 | */ |
| 185 | −#if FF_API_CRYPTO_SIZE_T | |
| 186 | −void av_hash_update(struct AVHashContext *ctx, const uint8_t *src, int len); | |
| 187 | −#else | |
| 188 | 185 | void av_hash_update(struct AVHashContext *ctx, const uint8_t *src, size_t len); |
| 189 | −#endif | |
| 190 | 186 | |
| 191 | 187 | /** |
| 192 | 188 | * Finalize a hash context and compute the actual hash value. |
| @@ -34,11 +34,7 @@ · 33 unmodified lines | ||
| 34 | 34 | #define MAX_BLOCKLEN 128 |
| 35 | 35 | |
| 36 | 36 | typedef void (*hmac_final)(void *ctx, uint8_t *dst); |
| 37 | −#if FF_API_CRYPTO_SIZE_T | |
| 38 | −typedef void (*hmac_update)(void *ctx, const uint8_t *src, int len); | |
| 39 | −#else | |
| 40 | 37 | typedef void (*hmac_update)(void *ctx, const uint8_t *src, size_t len); |
| 41 | −#endif | |
| 42 | 38 | typedef void (*hmac_init)(void *ctx); |
| 43 | 39 | |
| 44 | 40 | struct AVHMAC { |
| @@ -98,14 +98,13 @@ static const uint32_t T[64] = { // T[i]= fabs(sin(i+1)<<32) · 97 unmodified lines | ||
| 98 | 98 | a = b + (a << t | a >> (32 - t)); \ |
| 99 | 99 | } while (0) |
| 100 | 100 | |
| 101 | −static void body(uint32_t ABCD[4], const uint8_t *src, int nblocks) | |
| 101 | +static void body(uint32_t ABCD[4], const uint8_t *src, size_t nblocks) | |
| 102 | 102 | { |
| 103 | 103 | int i av_unused; |
| 104 | − int n; | |
| 105 | 104 | const uint32_t *X; |
| 106 | 105 | uint32_t a, b, c, d, t; |
| 107 | 106 | |
| 108 | − for (n = 0; n < nblocks; n++) { | |
| 107 | + for (size_t n = 0; n < nblocks; n++) { | |
| 109 | 108 | a = ABCD[3]; |
| 110 | 109 | b = ABCD[2]; |
| 111 | 110 | c = ABCD[1]; |
| @@ -150,11 +149,7 @@ void av_md5_init(AVMD5 *ctx) · 38 unmodified lines | ||
| 150 | 149 | ctx->ABCD[3] = 0x67452301; |
| 151 | 150 | } |
| 152 | 151 | |
| 153 | −#if FF_API_CRYPTO_SIZE_T | |
| 154 | −void av_md5_update(AVMD5 *ctx, const uint8_t *src, int len) | |
| 155 | −#else | |
| 156 | 152 | void av_md5_update(AVMD5 *ctx, const uint8_t *src, size_t len) |
| 157 | −#endif | |
| 158 | 153 | { |
| 159 | 154 | const uint8_t *end; |
| 160 | 155 | int j; |
| @@ -180,7 +175,7 @@ void av_md5_update(AVMD5 *ctx, const uint8_t *src, size_t len) · 19 unmodified lines | ||
| 180 | 175 | src += 64; |
| 181 | 176 | } |
| 182 | 177 | } else { |
| 183 | − int nblocks = len / 64; | |
| 178 | + size_t nblocks = len / 64; | |
| 184 | 179 | body(ctx->ABCD, src, nblocks); |
| 185 | 180 | src = end; |
| 186 | 181 | } |
| @@ -204,11 +199,7 @@ void av_md5_final(AVMD5 *ctx, uint8_t *dst) · 17 unmodified lines | ||
| 204 | 199 | AV_WL32(dst + 4 * i, ctx->ABCD[3 - i]); |
| 205 | 200 | } |
| 206 | 201 | |
| 207 | −#if FF_API_CRYPTO_SIZE_T | |
| 208 | −void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len) | |
| 209 | −#else | |
| 210 | 202 | void av_md5_sum(uint8_t *dst, const uint8_t *src, size_t len) |
| 211 | −#endif | |
| 212 | 203 | { |
| 213 | 204 | AVMD5 ctx; |
| 214 | 205 | |
| @@ -64,11 +64,7 @@ void av_md5_init(struct AVMD5 *ctx); · 63 unmodified lines | ||
| 64 | 64 | * @param src input data to update hash with |
| 65 | 65 | * @param len input data length |
| 66 | 66 | */ |
| 67 | −#if FF_API_CRYPTO_SIZE_T | |
| 68 | −void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, int len); | |
| 69 | −#else | |
| 70 | 67 | void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, size_t len); |
| 71 | −#endif | |
| 72 | 68 | |
| 73 | 69 | /** |
| 74 | 70 | * Finish hashing and output digest value. |
| @@ -85,11 +81,7 @@ void av_md5_final(struct AVMD5 *ctx, uint8_t *dst); · 10 unmodified lines | ||
| 85 | 81 | * @param src The data to hash |
| 86 | 82 | * @param len The length of the data, in bytes |
| 87 | 83 | */ |
| 88 | −#if FF_API_CRYPTO_SIZE_T | |
| 89 | −void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len); | |
| 90 | −#else | |
| 91 | 84 | void av_md5_sum(uint8_t *dst, const uint8_t *src, size_t len); |
| 92 | −#endif | |
| 93 | 85 | |
| 94 | 86 | /** |
| 95 | 87 | * @} |
| @@ -91,11 +91,7 @@ static inline uint64_t update_h2(uint64_t k, uint64_t h1, uint64_t h2) · 90 unmodified lines | ||
| 91 | 91 | return k; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | −#if FF_API_CRYPTO_SIZE_T | |
| 95 | −void av_murmur3_update(AVMurMur3 *c, const uint8_t *src, int len) | |
| 96 | −#else | |
| 97 | 94 | void av_murmur3_update(AVMurMur3 *c, const uint8_t *src, size_t len) |
| 98 | −#endif | |
| 99 | 95 | { |
| 100 | 96 | const uint8_t *end; |
| 101 | 97 | uint64_t h1 = c->h1, h2 = c->h2; |
| @@ -100,11 +100,7 @@ void av_murmur3_init(struct AVMurMur3 *c); · 99 unmodified lines | ||
| 100 | 100 | * @param[in] src Input data to update hash with |
| 101 | 101 | * @param[in] len Number of bytes to read from `src` |
| 102 | 102 | */ |
| 103 | −#if FF_API_CRYPTO_SIZE_T | |
| 104 | −void av_murmur3_update(struct AVMurMur3 *c, const uint8_t *src, int len); | |
| 105 | −#else | |
| 106 | 103 | void av_murmur3_update(struct AVMurMur3 *c, const uint8_t *src, size_t len); |
| 107 | −#endif | |
| 108 | 104 | |
| 109 | 105 | /** |
| 110 | 106 | * Finish hashing and output digest value. |
| @@ -511,13 +511,10 @@ av_cold int av_ripemd_init(AVRIPEMD *ctx, int bits) · 510 unmodified lines | ||
| 511 | 511 | return 0; |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | −#if FF_API_CRYPTO_SIZE_T | |
| 515 | −void av_ripemd_update(AVRIPEMD* ctx, const uint8_t* data, unsigned int len) | |
| 516 | −#else | |
| 517 | 514 | void av_ripemd_update(AVRIPEMD* ctx, const uint8_t* data, size_t len) |
| 518 | −#endif | |
| 519 | 515 | { |
| 520 | − unsigned int i, j; | |
| 516 | + unsigned int j; | |
| 517 | + size_t i; | |
| 521 | 518 | |
| 522 | 519 | j = ctx->count & 63; |
| 523 | 520 | ctx->count += len; |
| @@ -530,15 +527,19 @@ void av_ripemd_update(AVRIPEMD* ctx, const uint8_t* data, size_t len) · 6 unmodified lines | ||
| 530 | 527 | } |
| 531 | 528 | } |
| 532 | 529 | #else |
| 533 | − if ((j + len) > 63) { | |
| 530 | + if (len >= 64 - j) { | |
| 531 | + const uint8_t *end; | |
| 534 | 532 | memcpy(&ctx->buffer[j], data, (i = 64 - j)); |
| 535 | 533 | ctx->transform(ctx->state, ctx->buffer); |
| 536 | − for (; i + 63 < len; i += 64) | |
| 537 | − ctx->transform(ctx->state, &data[i]); | |
| 534 | + data += i; | |
| 535 | + len -= i; | |
| 536 | + end = data + (len & ~63); | |
| 537 | + len = len % 64; | |
| 538 | + for (; data < end; data += 64) | |
| 539 | + ctx->transform(ctx->state, data); | |
| 538 | 540 | j = 0; |
| 539 | − } else | |
| 540 | − i = 0; | |
| 541 | − memcpy(&ctx->buffer[j], &data[i], len - i); | |
| 541 | + } | |
| 542 | + memcpy(&ctx->buffer[j], data, len); | |
| 542 | 543 | #endif |
| 543 | 544 | } |
| 544 | 545 | |
| @@ -67,11 +67,7 @@ int av_ripemd_init(struct AVRIPEMD* context, int bits); · 66 unmodified lines | ||
| 67 | 67 | * @param data input data to update hash with |
| 68 | 68 | * @param len input data length |
| 69 | 69 | */ |
| 70 | −#if FF_API_CRYPTO_SIZE_T | |
| 71 | −void av_ripemd_update(struct AVRIPEMD* context, const uint8_t* data, unsigned int len); | |
| 72 | −#else | |
| 73 | 70 | void av_ripemd_update(struct AVRIPEMD* context, const uint8_t* data, size_t len); |
| 74 | −#endif | |
| 75 | 71 | |
| 76 | 72 | /** |
| 77 | 73 | * Finish hashing and output digest value. |
| @@ -311,13 +311,10 @@ av_cold int av_sha_init(AVSHA *ctx, int bits) · 310 unmodified lines | ||
| 311 | 311 | return 0; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | −#if FF_API_CRYPTO_SIZE_T | |
| 315 | −void av_sha_update(struct AVSHA *ctx, const uint8_t *data, unsigned int len) | |
| 316 | −#else | |
| 317 | 314 | void av_sha_update(struct AVSHA *ctx, const uint8_t *data, size_t len) |
| 318 | −#endif | |
| 319 | 315 | { |
| 320 | − unsigned int i, j; | |
| 316 | + unsigned int j; | |
| 317 | + size_t i; | |
| 321 | 318 | |
| 322 | 319 | j = ctx->count & 63; |
| 323 | 320 | ctx->count += len; |
| @@ -330,15 +327,19 @@ void av_sha_update(struct AVSHA *ctx, const uint8_t *data, size_t len) · 6 unmodified lines | ||
| 330 | 327 | } |
| 331 | 328 | } |
| 332 | 329 | #else |
| 333 | − if ((j + len) > 63) { | |
| 330 | + if (len >= 64 - j) { | |
| 331 | + const uint8_t *end; | |
| 334 | 332 | memcpy(&ctx->buffer[j], data, (i = 64 - j)); |
| 335 | 333 | ctx->transform(ctx->state, ctx->buffer); |
| 336 | − for (; i + 63 < len; i += 64) | |
| 337 | − ctx->transform(ctx->state, &data[i]); | |
| 334 | + data += i; | |
| 335 | + len -= i; | |
| 336 | + end = data + (len & ~63); | |
| 337 | + len = len % 64; | |
| 338 | + for (; data < end; data += 64) | |
| 339 | + ctx->transform(ctx->state, data); | |
| 338 | 340 | j = 0; |
| 339 | − } else | |
| 340 | − i = 0; | |
| 341 | − memcpy(&ctx->buffer[j], &data[i], len - i); | |
| 341 | + } | |
| 342 | + memcpy(&ctx->buffer[j], data, len); | |
| 342 | 343 | #endif |
| 343 | 344 | } |
| 344 | 345 | |
| @@ -74,11 +74,7 @@ int av_sha_init(struct AVSHA* context, int bits); · 73 unmodified lines | ||
| 74 | 74 | * @param data input data to update hash with |
| 75 | 75 | * @param len input data length |
| 76 | 76 | */ |
| 77 | −#if FF_API_CRYPTO_SIZE_T | |
| 78 | −void av_sha_update(struct AVSHA *ctx, const uint8_t *data, unsigned int len); | |
| 79 | −#else | |
| 80 | 77 | void av_sha_update(struct AVSHA *ctx, const uint8_t *data, size_t len); |
| 81 | −#endif | |
| 82 | 78 | |
| 83 | 79 | /** |
| 84 | 80 | * Finish hashing and output digest value. |
| @@ -239,13 +239,10 @@ av_cold int av_sha512_init(AVSHA512 *ctx, int bits) · 238 unmodified lines | ||
| 239 | 239 | return 0; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | −#if FF_API_CRYPTO_SIZE_T | |
| 243 | −void av_sha512_update(AVSHA512* ctx, const uint8_t* data, unsigned int len) | |
| 244 | −#else | |
| 245 | 242 | void av_sha512_update(AVSHA512* ctx, const uint8_t* data, size_t len) |
| 246 | −#endif | |
| 247 | 243 | { |
| 248 | − unsigned int i, j; | |
| 244 | + unsigned int j; | |
| 245 | + size_t i; | |
| 249 | 246 | |
| 250 | 247 | j = ctx->count & 127; |
| 251 | 248 | ctx->count += len; |
| @@ -258,15 +255,19 @@ void av_sha512_update(AVSHA512* ctx, const uint8_t* data, size_t len) · 6 unmodified lines | ||
| 258 | 255 | } |
| 259 | 256 | } |
| 260 | 257 | #else |
| 261 | − if ((j + len) > 127) { | |
| 258 | + if (len >= 128 - j) { | |
| 259 | + const uint8_t *end; | |
| 262 | 260 | memcpy(&ctx->buffer[j], data, (i = 128 - j)); |
| 263 | 261 | sha512_transform(ctx->state, ctx->buffer); |
| 264 | − for (; i + 127 < len; i += 128) | |
| 265 | − sha512_transform(ctx->state, &data[i]); | |
| 262 | + data += i; | |
| 263 | + len -= i; | |
| 264 | + end = data + (len & ~127); | |
| 265 | + len = len % 128; | |
| 266 | + for (; data < end; data += 128) | |
| 267 | + sha512_transform(ctx->state, data); | |
| 266 | 268 | j = 0; |
| 267 | − } else | |
| 268 | − i = 0; | |
| 269 | − memcpy(&ctx->buffer[j], &data[i], len - i); | |
| 269 | + } | |
| 270 | + memcpy(&ctx->buffer[j], data, len); | |
| 270 | 271 | #endif |
| 271 | 272 | } |
| 272 | 273 | |
| @@ -76,11 +76,7 @@ int av_sha512_init(struct AVSHA512* context, int bits); · 75 unmodified lines | ||
| 76 | 76 | * @param data input data to update hash with |
| 77 | 77 | * @param len input data length |
| 78 | 78 | */ |
| 79 | −#if FF_API_CRYPTO_SIZE_T | |
| 80 | −void av_sha512_update(struct AVSHA512* context, const uint8_t* data, unsigned int len); | |
| 81 | −#else | |
| 82 | 79 | void av_sha512_update(struct AVSHA512* context, const uint8_t* data, size_t len); |
| 83 | −#endif | |
| 84 | 80 | |
| 85 | 81 | /** |
| 86 | 82 | * Finish hashing and output digest value. |
| @@ -105,9 +105,6 @@ · 104 unmodified lines | ||
| 105 | 105 | * @{ |
| 106 | 106 | */ |
| 107 | 107 | |
| 108 | −#ifndef FF_API_CRYPTO_SIZE_T | |
| 109 | −#define FF_API_CRYPTO_SIZE_T (LIBAVUTIL_VERSION_MAJOR < 57) | |
| 110 | −#endif | |
| 111 | 108 | #ifndef FF_API_FRAME_GET_SET |
| 112 | 109 | #define FF_API_FRAME_GET_SET (LIBAVUTIL_VERSION_MAJOR < 57) |
| 113 | 110 | #endif |
| @@ -153,7 +153,7 @@ static int video_decode_example(const char *input_filename) · 152 unmodified lines | ||
| 153 | 153 | av_frame_unref(fr); |
| 154 | 154 | return number_of_written_bytes; |
| 155 | 155 | } |
| 156 | − printf("%d, %s, %s, %8"PRId64", %8d, 0x%08lx\n", video_stream, | |
| 156 | + printf("%d, %s, %s, %8"PRId64", %8d, 0x%08"PRIx32"\n", video_stream, | |
| 157 | 157 | av_ts2str(fr->pts), av_ts2str(fr->pkt_dts), fr->pkt_duration, |
| 158 | 158 | number_of_written_bytes, av_adler32_update(0, (const uint8_t*)byte_buffer, number_of_written_bytes)); |
| 159 | 159 | |