* 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
Unified · Split
| @@ -97,6 +97,10 @@ API changes, most recent first: · 96 unmodified lines | ||
| 97 | 97 | 2012-03-26 - a67d9cf - lavfi 2.66.100 |
| 98 | 98 | Add avfilter_fill_frame_from_{audio_,}buffer_ref() functions. |
| 99 | 99 | |
| 100 | +2012-10-xx - xxxxxxx - lavu 51.43.0 - aes.h, md5.h, sha.h, tree.h | |
| 101 | + Add functions for allocating the opaque contexts for the algorithms, | |
| 102 | + deprecate the context size variables. | |
| 103 | + | |
| 100 | 104 | 2012-10-xx - xxxxxxx - lavf 54.18.0 - avio.h |
| 101 | 105 | Add avio_closep to complement avio_close. |
| 102 | 106 | |
| @@ -355,7 +355,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 354 unmodified lines | ||
| 355 | 355 | s->channels, 16); |
| 356 | 356 | |
| 357 | 357 | /* initialize MD5 context */ |
| 358 | − s->md5ctx = av_malloc(av_md5_size); | |
| 358 | + s->md5ctx = av_md5_alloc(); | |
| 359 | 359 | if (!s->md5ctx) |
| 360 | 360 | return AVERROR(ENOMEM); |
| 361 | 361 | av_md5_init(s->md5ctx); |
| @@ -411,17 +411,17 @@ static inline int svq3_mc_dir(H264Context *h, int size, int mode, int dir, · 410 unmodified lines | ||
| 411 | 411 | int32_t mv = pack16to32(mx,my); |
| 412 | 412 | |
| 413 | 413 | if (part_height == 8 && i < 8) { |
| 414 | − *(int32_t *) h->mv_cache[dir][scan8[k] + 1*8] = mv; | |
| 414 | + AV_WN32A(h->mv_cache[dir][scan8[k] + 1*8], mv); | |
| 415 | 415 | |
| 416 | 416 | if (part_width == 8 && j < 8) { |
| 417 | − *(int32_t *) h->mv_cache[dir][scan8[k] + 1 + 1*8] = mv; | |
| 417 | + AV_WN32A(h->mv_cache[dir][scan8[k] + 1 + 1*8], mv); | |
| 418 | 418 | } |
| 419 | 419 | } |
| 420 | 420 | if (part_width == 8 && j < 8) { |
| 421 | − *(int32_t *) h->mv_cache[dir][scan8[k] + 1] = mv; | |
| 421 | + AV_WN32A(h->mv_cache[dir][scan8[k] + 1], mv); | |
| 422 | 422 | } |
| 423 | 423 | if (part_width == 4 || part_height == 4) { |
| 424 | − *(int32_t *) h->mv_cache[dir][scan8[k]] = mv; | |
| 424 | + AV_WN32A(h->mv_cache[dir][scan8[k]], mv); | |
| 425 | 425 | } |
| 426 | 426 | } |
| 427 | 427 | |
| @@ -489,11 +489,11 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type) · 61 unmodified lines | ||
| 489 | 489 | for (m = 0; m < 2; m++) { |
| 490 | 490 | if (s->mb_x > 0 && h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1]+6] != -1) { |
| 491 | 491 | for (i = 0; i < 4; i++) { |
| 492 | − *(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]; | |
| 492 | + 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]); | |
| 493 | 493 | } |
| 494 | 494 | } else { |
| 495 | 495 | for (i = 0; i < 4; i++) { |
| 496 | − *(uint32_t *) h->mv_cache[m][scan8[0] - 1 + i*8] = 0; | |
| 496 | + AV_ZERO32(h->mv_cache[m][scan8[0] - 1 + i*8]); | |
| 497 | 497 | } |
| 498 | 498 | } |
| 499 | 499 | if (s->mb_y > 0) { |
| @@ -501,14 +501,14 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type) · 1 unmodified line | ||
| 501 | 501 | 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); |
| 502 | 502 | |
| 503 | 503 | if (s->mb_x < (s->mb_width - 1)) { |
| 504 | − *(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]; | |
| 504 | + AV_COPY32(h->mv_cache[m][scan8[0] + 4 - 1*8], s->current_picture.f.motion_val[m][b_xy - h->b_stride + 4]); | |
| 505 | 505 | h->ref_cache[m][scan8[0] + 4 - 1*8] = |
| 506 | 506 | (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride + 1]+6] == -1 || |
| 507 | 507 | h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride ] ] == -1) ? PART_NOT_AVAILABLE : 1; |
| 508 | 508 | }else |
| 509 | 509 | h->ref_cache[m][scan8[0] + 4 - 1*8] = PART_NOT_AVAILABLE; |
| 510 | 510 | if (s->mb_x > 0) { |
| 511 | − *(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]; | |
| 511 | + AV_COPY32(h->mv_cache[m][scan8[0] - 1 - 1*8], s->current_picture.f.motion_val[m][b_xy - h->b_stride - 1]); | |
| 512 | 512 | 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; |
| 513 | 513 | }else |
| 514 | 514 | 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) · 145 unmodified lines | ||
| 660 | 660 | if (IS_INTRA16x16(mb_type)) { |
| 661 | 661 | AV_ZERO128(h->mb_luma_dc[0]+0); |
| 662 | 662 | AV_ZERO128(h->mb_luma_dc[0]+8); |
| 663 | − if (svq3_decode_block(&s->gb, *h->mb_luma_dc, 0, 1)){ | |
| 663 | + if (svq3_decode_block(&s->gb, h->mb_luma_dc[0], 0, 1)){ | |
| 664 | 664 | av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding intra luma dc\n"); |
| 665 | 665 | return -1; |
| 666 | 666 | } |
| @@ -87,7 +87,7 @@ static int crypto_open2(URLContext *h, const char *uri, int flags, AVDictionary · 86 unmodified lines | ||
| 87 | 87 | av_log(h, AV_LOG_ERROR, "Unable to open input\n"); |
| 88 | 88 | goto err; |
| 89 | 89 | } |
| 90 | − c->aes = av_mallocz(av_aes_size); | |
| 90 | + c->aes = av_aes_alloc(); | |
| 91 | 91 | if (!c->aes) { |
| 92 | 92 | ret = AVERROR(ENOMEM); |
| 93 | 93 | goto err; |
| @@ -159,7 +159,7 @@ static char *make_digest_auth(HTTPAuthState *state, const char *username, · 158 unmodified lines | ||
| 159 | 159 | ff_data_to_hex(cnonce, (const uint8_t*) cnonce_buf, sizeof(cnonce_buf), 1); |
| 160 | 160 | cnonce[2*sizeof(cnonce_buf)] = 0; |
| 161 | 161 | |
| 162 | − md5ctx = av_malloc(av_md5_size); | |
| 162 | + md5ctx = av_md5_alloc(); | |
| 163 | 163 | if (!md5ctx) |
| 164 | 164 | return NULL; |
| 165 | 165 | |
| @@ -350,7 +350,7 @@ static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv · 349 unmodified lines | ||
| 350 | 350 | int index; |
| 351 | 351 | |
| 352 | 352 | if (!mxf->aesc && s->key && s->keylen == 16) { |
| 353 | − mxf->aesc = av_malloc(av_aes_size); | |
| 353 | + mxf->aesc = av_aes_alloc(); | |
| 354 | 354 | if (!mxf->aesc) |
| 355 | 355 | return AVERROR(ENOMEM); |
| 356 | 356 | av_aes_init(mxf->aesc, s->key, 128, 1); |
| @@ -139,7 +139,7 @@ int ff_nut_sp_pts_cmp(const Syncpoint *a, const Syncpoint *b){ · 138 unmodified lines | ||
| 139 | 139 | |
| 140 | 140 | void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts){ |
| 141 | 141 | Syncpoint *sp= av_mallocz(sizeof(Syncpoint)); |
| 142 | − struct AVTreeNode *node= av_mallocz(av_tree_node_size); | |
| 142 | + struct AVTreeNode *node = av_tree_node_alloc(); | |
| 143 | 143 | |
| 144 | 144 | nut->sp_count++; |
| 145 | 145 | |
| @@ -859,7 +859,7 @@ int ff_rtmp_calc_digest(const uint8_t *src, int len, int gap, · 858 unmodified lines | ||
| 859 | 859 | uint8_t hmac_buf[64+32] = {0}; |
| 860 | 860 | int i; |
| 861 | 861 | |
| 862 | − sha = av_mallocz(av_sha_size); | |
| 862 | + sha = av_sha_alloc(); | |
| 863 | 863 | if (!sha) |
| 864 | 864 | return AVERROR(ENOMEM); |
| 865 | 865 | |
| @@ -39,7 +39,14 @@ typedef struct AVAES { · 38 unmodified lines | ||
| 39 | 39 | int rounds; |
| 40 | 40 | } AVAES; |
| 41 | 41 | |
| 42 | +#if FF_API_CONTEXT_SIZE | |
| 42 | 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 | 51 | static const uint8_t rcon[10] = { |
| 45 | 52 | 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 |
| @@ -23,16 +23,26 @@ · 22 unmodified lines | ||
| 23 | 23 | |
| 24 | 24 | #include <stdint.h> |
| 25 | 25 | |
| 26 | +#include "attributes.h" | |
| 27 | +#include "version.h" | |
| 28 | + | |
| 26 | 29 | /** |
| 27 | 30 | * @defgroup lavu_aes AES |
| 28 | 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 | 39 | struct AVAES; |
| 35 | 40 | |
| 41 | +/** | |
| 42 | + * Allocate an AVAES context. | |
| 43 | + */ | |
| 44 | +struct AVAES *av_aes_alloc(void); | |
| 45 | + | |
| 36 | 46 | /** |
| 37 | 47 | * Initialize an AVAES context. |
| 38 | 48 | * @param key_bits 128, 192 or 256 |
| @@ -34,6 +34,7 @@ · 33 unmodified lines | ||
| 34 | 34 | #include "bswap.h" |
| 35 | 35 | #include "intreadwrite.h" |
| 36 | 36 | #include "md5.h" |
| 37 | +#include "mem.h" | |
| 37 | 38 | |
| 38 | 39 | typedef struct AVMD5{ |
| 39 | 40 | uint64_t len; |
| @@ -41,7 +42,14 @@ typedef struct AVMD5{ · 1 unmodified line | ||
| 41 | 42 | uint32_t ABCD[4]; |
| 42 | 43 | } AVMD5; |
| 43 | 44 | |
| 45 | +#if FF_API_CONTEXT_SIZE | |
| 44 | 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 | 54 | static const uint8_t S[4][4] = { |
| 47 | 55 | { 7, 12, 17, 22 }, /* round 1 */ |
| @@ -23,16 +23,22 @@ · 22 unmodified lines | ||
| 23 | 23 | |
| 24 | 24 | #include <stdint.h> |
| 25 | 25 | |
| 26 | +#include "attributes.h" | |
| 27 | +#include "version.h" | |
| 28 | + | |
| 26 | 29 | /** |
| 27 | 30 | * @defgroup lavu_md5 MD5 |
| 28 | 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 | 39 | struct AVMD5; |
| 35 | 40 | |
| 41 | +struct AVMD5 *av_md5_alloc(void); | |
| 36 | 42 | void av_md5_init(struct AVMD5 *ctx); |
| 37 | 43 | void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, const int len); |
| 38 | 44 | void av_md5_final(struct AVMD5 *ctx, uint8_t *dst); |
| @@ -690,7 +690,7 @@ int main(void) · 689 unmodified lines | ||
| 690 | 690 | printf("Testing av_parse_video_rate()\n"); |
| 691 | 691 | { |
| 692 | 692 | int i; |
| 693 | − const char *rates[] = { | |
| 693 | + static const char *const rates[] = { | |
| 694 | 694 | "-inf", |
| 695 | 695 | "inf", |
| 696 | 696 | "nan", |
| @@ -720,7 +720,7 @@ int main(void) · 23 unmodified lines | ||
| 720 | 720 | |
| 721 | 721 | for (i = 0; i < FF_ARRAY_ELEMS(rates); i++) { |
| 722 | 722 | int ret; |
| 723 | − AVRational q = (AVRational){0, 0}; | |
| 723 | + AVRational q = { 0, 0 }; | |
| 724 | 724 | ret = av_parse_video_rate(&q, rates[i]); |
| 725 | 725 | printf("'%s' -> %d/%d %s\n", |
| 726 | 726 | rates[i], q.num, q.den, ret ? "ERROR" : "OK"); |
| @@ -731,7 +731,7 @@ int main(void) · 4 unmodified lines | ||
| 731 | 731 | { |
| 732 | 732 | int i; |
| 733 | 733 | uint8_t rgba[4]; |
| 734 | − const char *color_names[] = { | |
| 734 | + static const char *const color_names[] = { | |
| 735 | 735 | "bikeshed", |
| 736 | 736 | "RaNdOm", |
| 737 | 737 | "foo", |
| @@ -774,7 +774,8 @@ int main(void) · 36 unmodified lines | ||
| 774 | 774 | |
| 775 | 775 | for (i = 0; i < FF_ARRAY_ELEMS(color_names); i++) { |
| 776 | 776 | if (av_parse_color(rgba, color_names[i], -1, NULL) >= 0) |
| 777 | − printf("%s -> R(%d) G(%d) B(%d) A(%d)\n", color_names[i], rgba[0], rgba[1], rgba[2], rgba[3]); | |
| 777 | + printf("%s -> R(%d) G(%d) B(%d) A(%d)\n", | |
| 778 | + color_names[i], rgba[0], rgba[1], rgba[2], rgba[3]); | |
| 778 | 779 | else |
| 779 | 780 | printf("%s -> error\n", color_names[i]); |
| 780 | 781 | } |
| @@ -26,6 +26,7 @@ · 25 unmodified lines | ||
| 26 | 26 | #include "bswap.h" |
| 27 | 27 | #include "sha.h" |
| 28 | 28 | #include "intreadwrite.h" |
| 29 | +#include "mem.h" | |
| 29 | 30 | |
| 30 | 31 | /** hash context */ |
| 31 | 32 | typedef struct AVSHA { |
| @@ -37,7 +38,14 @@ typedef struct AVSHA { · 5 unmodified lines | ||
| 37 | 38 | void (*transform)(uint32_t *state, const uint8_t buffer[64]); |
| 38 | 39 | } AVSHA; |
| 39 | 40 | |
| 41 | +#if FF_API_CONTEXT_SIZE | |
| 40 | 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 | 50 | #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) |
| 43 | 51 | |
| @@ -23,16 +23,26 @@ · 22 unmodified lines | ||
| 23 | 23 | |
| 24 | 24 | #include <stdint.h> |
| 25 | 25 | |
| 26 | +#include "attributes.h" | |
| 27 | +#include "version.h" | |
| 28 | + | |
| 26 | 29 | /** |
| 27 | 30 | * @defgroup lavu_sha SHA |
| 28 | 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 | 39 | struct AVSHA; |
| 35 | 40 | |
| 41 | +/** | |
| 42 | + * Allocate an AVSHA context. | |
| 43 | + */ | |
| 44 | +struct AVSHA *av_sha_alloc(void); | |
| 45 | + | |
| 36 | 46 | /** |
| 37 | 47 | * Initialize SHA-1 or SHA-2 hashing. |
| 38 | 48 | * |
| @@ -28,7 +28,14 @@ typedef struct AVTreeNode { · 27 unmodified lines | ||
| 28 | 28 | int state; |
| 29 | 29 | } AVTreeNode; |
| 30 | 30 | |
| 31 | +#if FF_API_CONTEXT_SIZE | |
| 31 | 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 | 40 | void *av_tree_find(const AVTreeNode *t, void *key, |
| 34 | 41 | int (*cmp)(void *key, const void *b), void *next[2]) |
| @@ -213,7 +220,7 @@ int main (void) · 178 unmodified lines | ||
| 213 | 220 | } |
| 214 | 221 | av_log(NULL, AV_LOG_ERROR, "inserting %4d\n", j); |
| 215 | 222 | if (!node) |
| 216 | − node = av_mallocz(av_tree_node_size); | |
| 223 | + node = av_tree_node_alloc(); | |
| 217 | 224 | av_tree_insert(&root, (void *) (j + 1), cmp, &node); |
| 218 | 225 | |
| 219 | 226 | j = av_lfg_get(&prng) % 86294; |
| @@ -27,6 +27,9 @@ · 26 unmodified lines | ||
| 27 | 27 | #ifndef AVUTIL_TREE_H |
| 28 | 28 | #define AVUTIL_TREE_H |
| 29 | 29 | |
| 30 | +#include "attributes.h" | |
| 31 | +#include "version.h" | |
| 32 | + | |
| 30 | 33 | /** |
| 31 | 34 | * @addtogroup lavu_tree AVTree |
| 32 | 35 | * @ingroup lavu_data |
| @@ -40,7 +43,14 @@ · 7 unmodified lines | ||
| 40 | 43 | |
| 41 | 44 | |
| 42 | 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 | 56 | * Find an element. |
| @@ -39,7 +39,7 @@ · 38 unmodified lines | ||
| 39 | 39 | */ |
| 40 | 40 | |
| 41 | 41 | #define LIBAVUTIL_VERSION_MAJOR 51 |
| 42 | −#define LIBAVUTIL_VERSION_MINOR 74 | |
| 42 | +#define LIBAVUTIL_VERSION_MINOR 75 | |
| 43 | 43 | #define LIBAVUTIL_VERSION_MICRO 100 |
| 44 | 44 | |
| 45 | 45 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |
| @@ -84,6 +84,9 @@ · 38 unmodified lines | ||
| 84 | 84 | #ifndef FF_API_PIX_FMT |
| 85 | 85 | #define FF_API_PIX_FMT (LIBAVUTIL_VERSION_MAJOR < 52) |
| 86 | 86 | #endif |
| 87 | +#ifndef FF_API_CONTEXT_SIZE | |
| 88 | +#define FF_API_CONTEXT_SIZE (LIBAVUTIL_VERSION_MAJOR < 52) | |
| 89 | +#endif | |
| 87 | 90 | |
| 88 | 91 | /** |
| 89 | 92 | * @} |