The current API where the plain size is exposed is not of much use - in most cases it is allocated dynamically anyway. If allocated e.g. on the stack via an uint8_t array, there's no guarantee that the struct's members are aligned properly (unless the array is overallocated and the opaque pointer within it manually aligned to some unspecified alignment).
Unified · Split
| @@ -13,6 +13,10 @@ libavutil: 2011-04-18 · 12 unmodified lines | |||
| 13 | 13 | ||
| 14 | API changes, most recent first: | 14 | API changes, most recent first: |
| 15 | 15 | ||
| 16 | 2012-10-xx - xxxxxxx - lavu 51.43.0 - aes.h, md5.h, sha.h, tree.h | ||
| 17 | Add functions for allocating the opaque contexts for the algorithms, | ||
| 18 | deprecate the context size variables. | ||
| 19 | |||
| 16 | 2012-10-xx - xxxxxxx - lavf 54.18.0 - avio.h | 20 | 2012-10-xx - xxxxxxx - lavf 54.18.0 - avio.h |
| 17 | Add avio_closep to complement avio_close. | 21 | Add avio_closep to complement avio_close. |
| 18 | 22 | ||
| @@ -39,7 +39,14 @@ typedef struct AVAES { · 38 unmodified lines | |||
| 39 | int rounds; | 39 | int rounds; |
| 40 | } AVAES; | 40 | } AVAES; |
| 41 | 41 | ||
| 42 | #if FF_API_CONTEXT_SIZE | ||
| 42 | const int av_aes_size= sizeof(AVAES); | 43 | const int av_aes_size= sizeof(AVAES); |
| 44 | #endif | ||
| 45 | |||
| 46 | struct AVAES *av_aes_alloc(void) | ||
| 47 | { | ||
| 48 | return av_mallocz(sizeof(struct AVAES)); | ||
| 49 | } | ||
| 43 | 50 | ||
| 44 | static const uint8_t rcon[10] = { | 51 | static const uint8_t rcon[10] = { |
| 45 | 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 | 52 | 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 |
| @@ -23,16 +23,26 @@ · 22 unmodified lines | |||
| 23 | 23 | ||
| 24 | #include <stdint.h> | 24 | #include <stdint.h> |
| 25 | 25 | ||
| 26 | #include "attributes.h" | ||
| 27 | #include "version.h" | ||
| 28 | |||
| 26 | /** | 29 | /** |
| 27 | * @defgroup lavu_aes AES | 30 | * @defgroup lavu_aes AES |
| 28 | * @ingroup lavu_crypto | 31 | * @ingroup lavu_crypto |
| 29 | * @{ | 32 | * @{ |
| 30 | */ | 33 | */ |
| 31 | 34 | ||
| 32 | extern const int av_aes_size; | 35 | #if FF_API_CONTEXT_SIZE |
| 36 | extern attribute_deprecated const int av_aes_size; | ||
| 37 | #endif | ||
| 33 | 38 | ||
| 34 | struct AVAES; | 39 | struct AVAES; |
| 35 | 40 | ||
| 41 | /** | ||
| 42 | * Allocate an AVAES context. | ||
| 43 | */ | ||
| 44 | struct AVAES *av_aes_alloc(void); | ||
| 45 | |||
| 36 | /** | 46 | /** |
| 37 | * Initialize an AVAES context. | 47 | * Initialize an AVAES context. |
| 38 | * @param key_bits 128, 192 or 256 | 48 | * @param key_bits 128, 192 or 256 |
| @@ -34,6 +34,7 @@ · 33 unmodified lines | |||
| 34 | #include "bswap.h" | 34 | #include "bswap.h" |
| 35 | #include "intreadwrite.h" | 35 | #include "intreadwrite.h" |
| 36 | #include "md5.h" | 36 | #include "md5.h" |
| 37 | #include "mem.h" | ||
| 37 | 38 | ||
| 38 | typedef struct AVMD5{ | 39 | typedef struct AVMD5{ |
| 39 | uint64_t len; | 40 | uint64_t len; |
| @@ -41,7 +42,14 @@ typedef struct AVMD5{ · 1 unmodified line | |||
| 41 | uint32_t ABCD[4]; | 42 | uint32_t ABCD[4]; |
| 42 | } AVMD5; | 43 | } AVMD5; |
| 43 | 44 | ||
| 45 | #if FF_API_CONTEXT_SIZE | ||
| 44 | const int av_md5_size = sizeof(AVMD5); | 46 | const int av_md5_size = sizeof(AVMD5); |
| 47 | #endif | ||
| 48 | |||
| 49 | struct AVMD5 *av_md5_alloc(void) | ||
| 50 | { | ||
| 51 | return av_mallocz(sizeof(struct AVMD5)); | ||
| 52 | } | ||
| 45 | 53 | ||
| 46 | static const uint8_t S[4][4] = { | 54 | static const uint8_t S[4][4] = { |
| 47 | { 7, 12, 17, 22 }, /* round 1 */ | 55 | { 7, 12, 17, 22 }, /* round 1 */ |
| @@ -23,16 +23,22 @@ · 22 unmodified lines | |||
| 23 | 23 | ||
| 24 | #include <stdint.h> | 24 | #include <stdint.h> |
| 25 | 25 | ||
| 26 | #include "attributes.h" | ||
| 27 | #include "version.h" | ||
| 28 | |||
| 26 | /** | 29 | /** |
| 27 | * @defgroup lavu_md5 MD5 | 30 | * @defgroup lavu_md5 MD5 |
| 28 | * @ingroup lavu_crypto | 31 | * @ingroup lavu_crypto |
| 29 | * @{ | 32 | * @{ |
| 30 | */ | 33 | */ |
| 31 | 34 | ||
| 32 | extern const int av_md5_size; | 35 | #if FF_API_CONTEXT_SIZE |
| 36 | extern attribute_deprecated const int av_md5_size; | ||
| 37 | #endif | ||
| 33 | 38 | ||
| 34 | struct AVMD5; | 39 | struct AVMD5; |
| 35 | 40 | ||
| 41 | struct AVMD5 *av_md5_alloc(void); | ||
| 36 | void av_md5_init(struct AVMD5 *ctx); | 42 | void av_md5_init(struct AVMD5 *ctx); |
| 37 | void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, const int len); | 43 | void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, const int len); |
| 38 | void av_md5_final(struct AVMD5 *ctx, uint8_t *dst); | 44 | void av_md5_final(struct AVMD5 *ctx, uint8_t *dst); |
| @@ -26,6 +26,7 @@ · 25 unmodified lines | |||
| 26 | #include "bswap.h" | 26 | #include "bswap.h" |
| 27 | #include "sha.h" | 27 | #include "sha.h" |
| 28 | #include "intreadwrite.h" | 28 | #include "intreadwrite.h" |
| 29 | #include "mem.h" | ||
| 29 | 30 | ||
| 30 | /** hash context */ | 31 | /** hash context */ |
| 31 | typedef struct AVSHA { | 32 | typedef struct AVSHA { |
| @@ -37,7 +38,14 @@ typedef struct AVSHA { · 5 unmodified lines | |||
| 37 | void (*transform)(uint32_t *state, const uint8_t buffer[64]); | 38 | void (*transform)(uint32_t *state, const uint8_t buffer[64]); |
| 38 | } AVSHA; | 39 | } AVSHA; |
| 39 | 40 | ||
| 41 | #if FF_API_CONTEXT_SIZE | ||
| 40 | const int av_sha_size = sizeof(AVSHA); | 42 | const int av_sha_size = sizeof(AVSHA); |
| 43 | #endif | ||
| 44 | |||
| 45 | struct AVSHA *av_sha_alloc(void) | ||
| 46 | { | ||
| 47 | return av_mallocz(sizeof(struct AVSHA)); | ||
| 48 | } | ||
| 41 | 49 | ||
| 42 | #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) | 50 | #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) |
| 43 | 51 | ||
| @@ -23,16 +23,26 @@ · 22 unmodified lines | |||
| 23 | 23 | ||
| 24 | #include <stdint.h> | 24 | #include <stdint.h> |
| 25 | 25 | ||
| 26 | #include "attributes.h" | ||
| 27 | #include "version.h" | ||
| 28 | |||
| 26 | /** | 29 | /** |
| 27 | * @defgroup lavu_sha SHA | 30 | * @defgroup lavu_sha SHA |
| 28 | * @ingroup lavu_crypto | 31 | * @ingroup lavu_crypto |
| 29 | * @{ | 32 | * @{ |
| 30 | */ | 33 | */ |
| 31 | 34 | ||
| 32 | extern const int av_sha_size; | 35 | #if FF_API_CONTEXT_SIZE |
| 36 | extern attribute_deprecated const int av_sha_size; | ||
| 37 | #endif | ||
| 33 | 38 | ||
| 34 | struct AVSHA; | 39 | struct AVSHA; |
| 35 | 40 | ||
| 41 | /** | ||
| 42 | * Allocate an AVSHA context. | ||
| 43 | */ | ||
| 44 | struct AVSHA *av_sha_alloc(void); | ||
| 45 | |||
| 36 | /** | 46 | /** |
| 37 | * Initialize SHA-1 or SHA-2 hashing. | 47 | * Initialize SHA-1 or SHA-2 hashing. |
| 38 | * | 48 | * |
| @@ -28,7 +28,14 @@ typedef struct AVTreeNode { · 27 unmodified lines | |||
| 28 | int state; | 28 | int state; |
| 29 | } AVTreeNode; | 29 | } AVTreeNode; |
| 30 | 30 | ||
| 31 | #if FF_API_CONTEXT_SIZE | ||
| 31 | const int av_tree_node_size = sizeof(AVTreeNode); | 32 | const int av_tree_node_size = sizeof(AVTreeNode); |
| 33 | #endif | ||
| 34 | |||
| 35 | struct AVTreeNode *av_tree_node_alloc(void) | ||
| 36 | { | ||
| 37 | return av_mallocz(sizeof(struct AVTreeNode)); | ||
| 38 | } | ||
| 32 | 39 | ||
| 33 | void *av_tree_find(const AVTreeNode *t, void *key, | 40 | void *av_tree_find(const AVTreeNode *t, void *key, |
| 34 | int (*cmp)(void *key, const void *b), void *next[2]) | 41 | int (*cmp)(void *key, const void *b), void *next[2]) |
| @@ -27,6 +27,9 @@ · 26 unmodified lines | |||
| 27 | #ifndef AVUTIL_TREE_H | 27 | #ifndef AVUTIL_TREE_H |
| 28 | #define AVUTIL_TREE_H | 28 | #define AVUTIL_TREE_H |
| 29 | 29 | ||
| 30 | #include "attributes.h" | ||
| 31 | #include "version.h" | ||
| 32 | |||
| 30 | /** | 33 | /** |
| 31 | * @addtogroup lavu_tree AVTree | 34 | * @addtogroup lavu_tree AVTree |
| 32 | * @ingroup lavu_data | 35 | * @ingroup lavu_data |
| @@ -40,7 +43,14 @@ · 7 unmodified lines | |||
| 40 | 43 | ||
| 41 | 44 | ||
| 42 | struct AVTreeNode; | 45 | struct AVTreeNode; |
| 43 | extern const int av_tree_node_size; | 46 | #if FF_API_CONTEXT_SIZE |
| 47 | extern attribute_deprecated const int av_tree_node_size; | ||
| 48 | #endif | ||
| 49 | |||
| 50 | /** | ||
| 51 | * Allocate an AVTreeNode. | ||
| 52 | */ | ||
| 53 | struct AVTreeNode *av_tree_node_alloc(void); | ||
| 44 | 54 | ||
| 45 | /** | 55 | /** |
| 46 | * Find an element. | 56 | * Find an element. |
| @@ -37,7 +37,7 @@ · 36 unmodified lines | |||
| 37 | */ | 37 | */ |
| 38 | 38 | ||
| 39 | #define LIBAVUTIL_VERSION_MAJOR 51 | 39 | #define LIBAVUTIL_VERSION_MAJOR 51 |
| 40 | #define LIBAVUTIL_VERSION_MINOR 42 | 40 | #define LIBAVUTIL_VERSION_MINOR 43 |
| 41 | #define LIBAVUTIL_VERSION_MICRO 0 | 41 | #define LIBAVUTIL_VERSION_MICRO 0 |
| 42 | 42 | ||
| 43 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ | 43 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |
| @@ -76,6 +76,9 @@ · 32 unmodified lines | |||
| 76 | #ifndef FF_API_PIX_FMT | 76 | #ifndef FF_API_PIX_FMT |
| 77 | #define FF_API_PIX_FMT (LIBAVUTIL_VERSION_MAJOR < 52) | 77 | #define FF_API_PIX_FMT (LIBAVUTIL_VERSION_MAJOR < 52) |
| 78 | #endif | 78 | #endif |
| 79 | #ifndef FF_API_CONTEXT_SIZE | ||
| 80 | #define FF_API_CONTEXT_SIZE (LIBAVUTIL_VERSION_MAJOR < 52) | ||
| 81 | #endif | ||
| 79 | 82 | ||
| 80 | /** | 83 | /** |
| 81 | * @} | 84 | * @} |