summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/APIchanges4
-rw-r--r--libavcodec/flacenc.c2
-rw-r--r--libavcodec/svq3.c18
-rw-r--r--libavformat/crypto.c2
-rw-r--r--libavformat/httpauth.c2
-rw-r--r--libavformat/mxfdec.c2
-rw-r--r--libavformat/nut.c2
-rw-r--r--libavformat/rtmpproto.c2
-rw-r--r--libavutil/aes.c7
-rw-r--r--libavutil/aes.h12
-rw-r--r--libavutil/md5.c8
-rw-r--r--libavutil/md5.h8
-rw-r--r--libavutil/parseutils.c9
-rw-r--r--libavutil/sha.c8
-rw-r--r--libavutil/sha.h12
-rw-r--r--libavutil/tree.c9
-rw-r--r--libavutil/tree.h12
-rw-r--r--libavutil/version.h5
18 files changed, 99 insertions, 25 deletions
diff --git a/doc/APIchanges b/doc/APIchanges
index 7c298ee1c6..f0f1531215 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -97,6 +97,10 @@ API changes, most recent first:
2012-03-26 - a67d9cf - lavfi 2.66.100
Add avfilter_fill_frame_from_{audio_,}buffer_ref() functions.
+2012-10-xx - xxxxxxx - lavu 51.43.0 - aes.h, md5.h, sha.h, tree.h
+ Add functions for allocating the opaque contexts for the algorithms,
+ deprecate the context size variables.
+
2012-10-xx - xxxxxxx - lavf 54.18.0 - avio.h
Add avio_closep to complement avio_close.
diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c
index 070fb4db5e..ec6f2e075b 100644
--- a/libavcodec/flacenc.c
+++ b/libavcodec/flacenc.c
@@ -355,7 +355,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx)
s->channels, 16);
/* initialize MD5 context */
- s->md5ctx = av_malloc(av_md5_size);
+ s->md5ctx = av_md5_alloc();
if (!s->md5ctx)
return AVERROR(ENOMEM);
av_md5_init(s->md5ctx);
diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index c1c0102a45..2385eb0715 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -411,17 +411,17 @@ static inline int svq3_mc_dir(H264Context *h, int size, int mode, int dir,
int32_t mv = pack16to32(mx,my);
if (part_height == 8 && i < 8) {
- *(int32_t *) h->mv_cache[dir][scan8[k] + 1*8] = mv;
+ AV_WN32A(h->mv_cache[dir][scan8[k] + 1*8], mv);
if (part_width == 8 && j < 8) {
- *(int32_t *) h->mv_cache[dir][scan8[k] + 1 + 1*8] = mv;
+ AV_WN32A(h->mv_cache[dir][scan8[k] + 1 + 1*8], mv);
}
}
if (part_width == 8 && j < 8) {
- *(int32_t *) h->mv_cache[dir][scan8[k] + 1] = mv;
+ AV_WN32A(h->mv_cache[dir][scan8[k] + 1], mv);
}
if (part_width == 4 || part_height == 4) {
- *(int32_t *) h->mv_cache[dir][scan8[k]] = mv;
+ AV_WN32A(h->mv_cache[dir][scan8[k]], mv);
}
}
@@ -489,11 +489,11 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type)
for (m = 0; m < 2; m++) {
if (s->mb_x > 0 && h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1]+6] != -1) {
for (i = 0; i < 4; i++) {
- *(uint32_t *) h->mv_cache[m][scan8[0] - 1 + i*8] = *(uint32_t *) s->current_picture.f.motion_val[m][b_xy - 1 + i*h->b_stride];
+ AV_COPY32(h->mv_cache[m][scan8[0] - 1 + i*8], s->current_picture.f.motion_val[m][b_xy - 1 + i*h->b_stride]);
}
} else {
for (i = 0; i < 4; i++) {
- *(uint32_t *) h->mv_cache[m][scan8[0] - 1 + i*8] = 0;
+ AV_ZERO32(h->mv_cache[m][scan8[0] - 1 + i*8]);
}
}
if (s->mb_y > 0) {
@@ -501,14 +501,14 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type)
memset(&h->ref_cache[m][scan8[0] - 1*8], (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1, 4);
if (s->mb_x < (s->mb_width - 1)) {
- *(uint32_t *) h->mv_cache[m][scan8[0] + 4 - 1*8] = *(uint32_t *) s->current_picture.f.motion_val[m][b_xy - h->b_stride + 4];
+ AV_COPY32(h->mv_cache[m][scan8[0] + 4 - 1*8], s->current_picture.f.motion_val[m][b_xy - h->b_stride + 4]);
h->ref_cache[m][scan8[0] + 4 - 1*8] =
(h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride + 1]+6] == -1 ||
h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride ] ] == -1) ? PART_NOT_AVAILABLE : 1;
}else
h->ref_cache[m][scan8[0] + 4 - 1*8] = PART_NOT_AVAILABLE;
if (s->mb_x > 0) {
- *(uint32_t *) h->mv_cache[m][scan8[0] - 1 - 1*8] = *(uint32_t *) s->current_picture.f.motion_val[m][b_xy - h->b_stride - 1];
+ AV_COPY32(h->mv_cache[m][scan8[0] - 1 - 1*8], s->current_picture.f.motion_val[m][b_xy - h->b_stride - 1]);
h->ref_cache[m][scan8[0] - 1 - 1*8] = (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride - 1]+3] == -1) ? PART_NOT_AVAILABLE : 1;
}else
h->ref_cache[m][scan8[0] - 1 - 1*8] = PART_NOT_AVAILABLE;
@@ -660,7 +660,7 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type)
if (IS_INTRA16x16(mb_type)) {
AV_ZERO128(h->mb_luma_dc[0]+0);
AV_ZERO128(h->mb_luma_dc[0]+8);
- if (svq3_decode_block(&s->gb, *h->mb_luma_dc, 0, 1)){
+ if (svq3_decode_block(&s->gb, h->mb_luma_dc[0], 0, 1)){
av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding intra luma dc\n");
return -1;
}
diff --git a/libavformat/crypto.c b/libavformat/crypto.c
index 06c687e3fc..5d518beb01 100644
--- a/libavformat/crypto.c
+++ b/libavformat/crypto.c
@@ -87,7 +87,7 @@ static int crypto_open2(URLContext *h, const char *uri, int flags, AVDictionary
av_log(h, AV_LOG_ERROR, "Unable to open input\n");
goto err;
}
- c->aes = av_mallocz(av_aes_size);
+ c->aes = av_aes_alloc();
if (!c->aes) {
ret = AVERROR(ENOMEM);
goto err;
diff --git a/libavformat/httpauth.c b/libavformat/httpauth.c
index 646f909a0d..e97aee1f66 100644
--- a/libavformat/httpauth.c
+++ b/libavformat/httpauth.c
@@ -159,7 +159,7 @@ static char *make_digest_auth(HTTPAuthState *state, const char *username,
ff_data_to_hex(cnonce, (const uint8_t*) cnonce_buf, sizeof(cnonce_buf), 1);
cnonce[2*sizeof(cnonce_buf)] = 0;
- md5ctx = av_malloc(av_md5_size);
+ md5ctx = av_md5_alloc();
if (!md5ctx)
return NULL;
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index b7c082605a..1f583b8ad6 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -350,7 +350,7 @@ static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv
int index;
if (!mxf->aesc && s->key && s->keylen == 16) {
- mxf->aesc = av_malloc(av_aes_size);
+ mxf->aesc = av_aes_alloc();
if (!mxf->aesc)
return AVERROR(ENOMEM);
av_aes_init(mxf->aesc, s->key, 128, 1);
diff --git a/libavformat/nut.c b/libavformat/nut.c
index 30c0eb6179..02dd122b0a 100644
--- a/libavformat/nut.c
+++ b/libavformat/nut.c
@@ -139,7 +139,7 @@ int ff_nut_sp_pts_cmp(const Syncpoint *a, const Syncpoint *b){
void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts){
Syncpoint *sp= av_mallocz(sizeof(Syncpoint));
- struct AVTreeNode *node= av_mallocz(av_tree_node_size);
+ struct AVTreeNode *node = av_tree_node_alloc();
nut->sp_count++;
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index d76a5114dc..dbe987058a 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -859,7 +859,7 @@ int ff_rtmp_calc_digest(const uint8_t *src, int len, int gap,
uint8_t hmac_buf[64+32] = {0};
int i;
- sha = av_mallocz(av_sha_size);
+ sha = av_sha_alloc();
if (!sha)
return AVERROR(ENOMEM);
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
/**
* @}