diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-10-12 14:52:34 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-10-12 14:52:34 +0200 |
commit | f391e405dfde35bfb3fea9ccc09bd67b5cc0a8f2 (patch) | |
tree | 739e823660aa365a392c509acd1ac1686272029f /libavutil | |
parent | d6135a886d85bdbf271c55a238c3336670adc742 (diff) | |
parent | e002e3291e6dc7953f843abf56fc14f08f238b21 (diff) | |
download | ffmpeg-f391e405dfde35bfb3fea9ccc09bd67b5cc0a8f2.tar.gz |
Merge commit 'e002e3291e6dc7953f843abf56fc14f08f238b21'
* commit 'e002e3291e6dc7953f843abf56fc14f08f238b21':
Use the new aes/md5/sha/tree allocation functions
avutil: Add functions for allocating opaque contexts for algorithms
svq3: fix pointer type warning
svq3: replace unsafe pointer casting with intreadwrite macros
parseutils-test: various cleanups
Conflicts:
doc/APIchanges
libavcodec/svq3.c
libavutil/parseutils.c
libavutil/version.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/aes.c | 7 | ||||
-rw-r--r-- | libavutil/aes.h | 12 | ||||
-rw-r--r-- | libavutil/md5.c | 8 | ||||
-rw-r--r-- | libavutil/md5.h | 8 | ||||
-rw-r--r-- | libavutil/parseutils.c | 9 | ||||
-rw-r--r-- | libavutil/sha.c | 8 | ||||
-rw-r--r-- | libavutil/sha.h | 12 | ||||
-rw-r--r-- | libavutil/tree.c | 9 | ||||
-rw-r--r-- | libavutil/tree.h | 12 | ||||
-rw-r--r-- | libavutil/version.h | 5 |
10 files changed, 80 insertions, 10 deletions
diff --git a/libavutil/aes.c b/libavutil/aes.c index 7950902280..555cbb82cf 100644 --- a/libavutil/aes.c +++ b/libavutil/aes.c @@ -39,7 +39,14 @@ typedef struct AVAES { int rounds; } AVAES; +#if FF_API_CONTEXT_SIZE const int av_aes_size= sizeof(AVAES); +#endif + +struct AVAES *av_aes_alloc(void) +{ + return av_mallocz(sizeof(struct AVAES)); +} static const uint8_t rcon[10] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 diff --git a/libavutil/aes.h b/libavutil/aes.h index bafa4cc3c4..9c1a54e036 100644 --- a/libavutil/aes.h +++ b/libavutil/aes.h @@ -23,17 +23,27 @@ #include <stdint.h> +#include "attributes.h" +#include "version.h" + /** * @defgroup lavu_aes AES * @ingroup lavu_crypto * @{ */ -extern const int av_aes_size; +#if FF_API_CONTEXT_SIZE +extern attribute_deprecated const int av_aes_size; +#endif struct AVAES; /** + * Allocate an AVAES context. + */ +struct AVAES *av_aes_alloc(void); + +/** * Initialize an AVAES context. * @param key_bits 128, 192 or 256 * @param decrypt 0 for encryption, 1 for decryption diff --git a/libavutil/md5.c b/libavutil/md5.c index 00447f92f0..ce8400fdac 100644 --- a/libavutil/md5.c +++ b/libavutil/md5.c @@ -34,6 +34,7 @@ #include "bswap.h" #include "intreadwrite.h" #include "md5.h" +#include "mem.h" typedef struct AVMD5{ uint64_t len; @@ -41,7 +42,14 @@ typedef struct AVMD5{ uint32_t ABCD[4]; } AVMD5; +#if FF_API_CONTEXT_SIZE const int av_md5_size = sizeof(AVMD5); +#endif + +struct AVMD5 *av_md5_alloc(void) +{ + return av_mallocz(sizeof(struct AVMD5)); +} static const uint8_t S[4][4] = { { 7, 12, 17, 22 }, /* round 1 */ diff --git a/libavutil/md5.h b/libavutil/md5.h index a3534edad0..69199cc53c 100644 --- a/libavutil/md5.h +++ b/libavutil/md5.h @@ -23,16 +23,22 @@ #include <stdint.h> +#include "attributes.h" +#include "version.h" + /** * @defgroup lavu_md5 MD5 * @ingroup lavu_crypto * @{ */ -extern const int av_md5_size; +#if FF_API_CONTEXT_SIZE +extern attribute_deprecated const int av_md5_size; +#endif struct AVMD5; +struct AVMD5 *av_md5_alloc(void); void av_md5_init(struct AVMD5 *ctx); void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, const int len); void av_md5_final(struct AVMD5 *ctx, uint8_t *dst); diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c index 54231c0b9c..84bb9f7876 100644 --- a/libavutil/parseutils.c +++ b/libavutil/parseutils.c @@ -690,7 +690,7 @@ int main(void) printf("Testing av_parse_video_rate()\n"); { int i; - const char *rates[] = { + static const char *const rates[] = { "-inf", "inf", "nan", @@ -720,7 +720,7 @@ int main(void) for (i = 0; i < FF_ARRAY_ELEMS(rates); i++) { int ret; - AVRational q = (AVRational){0, 0}; + AVRational q = { 0, 0 }; ret = av_parse_video_rate(&q, rates[i]); printf("'%s' -> %d/%d %s\n", rates[i], q.num, q.den, ret ? "ERROR" : "OK"); @@ -731,7 +731,7 @@ int main(void) { int i; uint8_t rgba[4]; - const char *color_names[] = { + static const char *const color_names[] = { "bikeshed", "RaNdOm", "foo", @@ -774,7 +774,8 @@ int main(void) for (i = 0; i < FF_ARRAY_ELEMS(color_names); i++) { if (av_parse_color(rgba, color_names[i], -1, NULL) >= 0) - printf("%s -> R(%d) G(%d) B(%d) A(%d)\n", color_names[i], rgba[0], rgba[1], rgba[2], rgba[3]); + printf("%s -> R(%d) G(%d) B(%d) A(%d)\n", + color_names[i], rgba[0], rgba[1], rgba[2], rgba[3]); else printf("%s -> error\n", color_names[i]); } diff --git a/libavutil/sha.c b/libavutil/sha.c index c5d13c127a..e3a956a4b5 100644 --- a/libavutil/sha.c +++ b/libavutil/sha.c @@ -26,6 +26,7 @@ #include "bswap.h" #include "sha.h" #include "intreadwrite.h" +#include "mem.h" /** hash context */ typedef struct AVSHA { @@ -37,7 +38,14 @@ typedef struct AVSHA { void (*transform)(uint32_t *state, const uint8_t buffer[64]); } AVSHA; +#if FF_API_CONTEXT_SIZE const int av_sha_size = sizeof(AVSHA); +#endif + +struct AVSHA *av_sha_alloc(void) +{ + return av_mallocz(sizeof(struct AVSHA)); +} #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) diff --git a/libavutil/sha.h b/libavutil/sha.h index d891cae87f..744c66f5d9 100644 --- a/libavutil/sha.h +++ b/libavutil/sha.h @@ -23,17 +23,27 @@ #include <stdint.h> +#include "attributes.h" +#include "version.h" + /** * @defgroup lavu_sha SHA * @ingroup lavu_crypto * @{ */ -extern const int av_sha_size; +#if FF_API_CONTEXT_SIZE +extern attribute_deprecated const int av_sha_size; +#endif struct AVSHA; /** + * Allocate an AVSHA context. + */ +struct AVSHA *av_sha_alloc(void); + +/** * Initialize SHA-1 or SHA-2 hashing. * * @param context pointer to the function context (of size av_sha_size) diff --git a/libavutil/tree.c b/libavutil/tree.c index 4206539c37..cba6fe8c78 100644 --- a/libavutil/tree.c +++ b/libavutil/tree.c @@ -28,7 +28,14 @@ typedef struct AVTreeNode { int state; } AVTreeNode; +#if FF_API_CONTEXT_SIZE const int av_tree_node_size = sizeof(AVTreeNode); +#endif + +struct AVTreeNode *av_tree_node_alloc(void) +{ + return av_mallocz(sizeof(struct AVTreeNode)); +} void *av_tree_find(const AVTreeNode *t, void *key, int (*cmp)(void *key, const void *b), void *next[2]) @@ -213,7 +220,7 @@ int main (void) } av_log(NULL, AV_LOG_ERROR, "inserting %4d\n", j); if (!node) - node = av_mallocz(av_tree_node_size); + node = av_tree_node_alloc(); av_tree_insert(&root, (void *) (j + 1), cmp, &node); j = av_lfg_get(&prng) % 86294; diff --git a/libavutil/tree.h b/libavutil/tree.h index 12f76f011c..71874967f9 100644 --- a/libavutil/tree.h +++ b/libavutil/tree.h @@ -27,6 +27,9 @@ #ifndef AVUTIL_TREE_H #define AVUTIL_TREE_H +#include "attributes.h" +#include "version.h" + /** * @addtogroup lavu_tree AVTree * @ingroup lavu_data @@ -40,7 +43,14 @@ struct AVTreeNode; -extern const int av_tree_node_size; +#if FF_API_CONTEXT_SIZE +extern attribute_deprecated const int av_tree_node_size; +#endif + +/** + * Allocate an AVTreeNode. + */ +struct AVTreeNode *av_tree_node_alloc(void); /** * Find an element. diff --git a/libavutil/version.h b/libavutil/version.h index d807a1955c..6c313e4202 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -39,7 +39,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 51 -#define LIBAVUTIL_VERSION_MINOR 74 +#define LIBAVUTIL_VERSION_MINOR 75 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ @@ -84,6 +84,9 @@ #ifndef FF_API_PIX_FMT #define FF_API_PIX_FMT (LIBAVUTIL_VERSION_MAJOR < 52) #endif +#ifndef FF_API_CONTEXT_SIZE +#define FF_API_CONTEXT_SIZE (LIBAVUTIL_VERSION_MAJOR < 52) +#endif /** * @} |