History

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

Michael Niedermayer committed 14 years ago

Commit f391e402 parents d6135a8 e002e3218 files · +99 −25Browse files

Unified · Split

18 files
  1. doc/APIchanges +4 −0
  2. libavcodec/flacenc.c +1 −1
  3. libavcodec/svq3.c +9 −9
  4. libavformat/crypto.c +1 −1
  5. libavformat/httpauth.c +1 −1
  6. libavformat/mxfdec.c +1 −1
  7. libavformat/nut.c +1 −1
  8. libavformat/rtmpproto.c +1 −1
  9. libavutil/aes.c +7 −0
  10. libavutil/aes.h +11 −1
  11. libavutil/md5.c +8 −0
  12. libavutil/md5.h +7 −1
  13. libavutil/parseutils.c +5 −4
  14. libavutil/sha.c +8 −0
  15. libavutil/sha.h +11 −1
  16. libavutil/tree.c +8 −1
  17. libavutil/tree.h +11 −1
  18. libavutil/version.h +4 −1
doc/APIchanges+4−0
@@ -97,6 +97,10 @@ API changes, most recent first: · 96 unmodified lines
9797 2012-03-26 - a67d9cf - lavfi 2.66.100
9898 Add avfilter_fill_frame_from_{audio_,}buffer_ref() functions.
9999
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+
100104 2012-10-xx - xxxxxxx - lavf 54.18.0 - avio.h
101105 Add avio_closep to complement avio_close.
102106
libavcodec/flacenc.c+1−1
@@ -355,7 +355,7 @@ static av_cold int flac_encode_init(AVCodecContext *avctx) · 354 unmodified lines
355355 s->channels, 16);
356356
357357 /* initialize MD5 context */
358− s->md5ctx = av_malloc(av_md5_size);
358+ s->md5ctx = av_md5_alloc();
359359 if (!s->md5ctx)
360360 return AVERROR(ENOMEM);
361361 av_md5_init(s->md5ctx);
libavcodec/svq3.c+9−9
@@ -411,17 +411,17 @@ static inline int svq3_mc_dir(H264Context *h, int size, int mode, int dir, · 410 unmodified lines
411411 int32_t mv = pack16to32(mx,my);
412412
413413 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);
415415
416416 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);
418418 }
419419 }
420420 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);
422422 }
423423 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);
425425 }
426426 }
427427
@@ -489,11 +489,11 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type) · 61 unmodified lines
489489 for (m = 0; m < 2; m++) {
490490 if (s->mb_x > 0 && h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1]+6] != -1) {
491491 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]);
493493 }
494494 } else {
495495 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]);
497497 }
498498 }
499499 if (s->mb_y > 0) {
@@ -501,14 +501,14 @@ static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type) · 1 unmodified line
501501 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);
502502
503503 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]);
505505 h->ref_cache[m][scan8[0] + 4 - 1*8] =
506506 (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride + 1]+6] == -1 ||
507507 h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride ] ] == -1) ? PART_NOT_AVAILABLE : 1;
508508 }else
509509 h->ref_cache[m][scan8[0] + 4 - 1*8] = PART_NOT_AVAILABLE;
510510 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]);
512512 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;
513513 }else
514514 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
660660 if (IS_INTRA16x16(mb_type)) {
661661 AV_ZERO128(h->mb_luma_dc[0]+0);
662662 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)){
664664 av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding intra luma dc\n");
665665 return -1;
666666 }
libavformat/crypto.c+1−1
@@ -87,7 +87,7 @@ static int crypto_open2(URLContext *h, const char *uri, int flags, AVDictionary · 86 unmodified lines
8787 av_log(h, AV_LOG_ERROR, "Unable to open input\n");
8888 goto err;
8989 }
90− c->aes = av_mallocz(av_aes_size);
90+ c->aes = av_aes_alloc();
9191 if (!c->aes) {
9292 ret = AVERROR(ENOMEM);
9393 goto err;
libavformat/httpauth.c+1−1
@@ -159,7 +159,7 @@ static char *make_digest_auth(HTTPAuthState *state, const char *username, · 158 unmodified lines
159159 ff_data_to_hex(cnonce, (const uint8_t*) cnonce_buf, sizeof(cnonce_buf), 1);
160160 cnonce[2*sizeof(cnonce_buf)] = 0;
161161
162− md5ctx = av_malloc(av_md5_size);
162+ md5ctx = av_md5_alloc();
163163 if (!md5ctx)
164164 return NULL;
165165
libavformat/mxfdec.c+1−1
@@ -350,7 +350,7 @@ static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv · 349 unmodified lines
350350 int index;
351351
352352 if (!mxf->aesc && s->key && s->keylen == 16) {
353− mxf->aesc = av_malloc(av_aes_size);
353+ mxf->aesc = av_aes_alloc();
354354 if (!mxf->aesc)
355355 return AVERROR(ENOMEM);
356356 av_aes_init(mxf->aesc, s->key, 128, 1);
libavformat/nut.c+1−1
@@ -139,7 +139,7 @@ int ff_nut_sp_pts_cmp(const Syncpoint *a, const Syncpoint *b){ · 138 unmodified lines
139139
140140 void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts){
141141 Syncpoint *sp= av_mallocz(sizeof(Syncpoint));
142− struct AVTreeNode *node= av_mallocz(av_tree_node_size);
142+ struct AVTreeNode *node = av_tree_node_alloc();
143143
144144 nut->sp_count++;
145145
libavformat/rtmpproto.c+1−1
@@ -859,7 +859,7 @@ int ff_rtmp_calc_digest(const uint8_t *src, int len, int gap, · 858 unmodified lines
859859 uint8_t hmac_buf[64+32] = {0};
860860 int i;
861861
862− sha = av_mallocz(av_sha_size);
862+ sha = av_sha_alloc();
863863 if (!sha)
864864 return AVERROR(ENOMEM);
865865
libavutil/aes.c+7−0
@@ -39,7 +39,14 @@ typedef struct AVAES { · 38 unmodified lines
3939 int rounds;
4040 } AVAES;
4141
42+#if FF_API_CONTEXT_SIZE
4243 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+}
4350
4451 static const uint8_t rcon[10] = {
4552 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36
libavutil/aes.h+11−1
@@ -23,16 +23,26 @@ · 22 unmodified lines
2323
2424 #include <stdint.h>
2525
26+#include "attributes.h"
27+#include "version.h"
28+
2629 /**
2730 * @defgroup lavu_aes AES
2831 * @ingroup lavu_crypto
2932 * @{
3033 */
3134
32−extern const int av_aes_size;
35+#if FF_API_CONTEXT_SIZE
36+extern attribute_deprecated const int av_aes_size;
37+#endif
3338
3439 struct AVAES;
3540
41+/**
42+ * Allocate an AVAES context.
43+ */
44+struct AVAES *av_aes_alloc(void);
45+
3646 /**
3747 * Initialize an AVAES context.
3848 * @param key_bits 128, 192 or 256
libavutil/md5.c+8−0
@@ -34,6 +34,7 @@ · 33 unmodified lines
3434 #include "bswap.h"
3535 #include "intreadwrite.h"
3636 #include "md5.h"
37+#include "mem.h"
3738
3839 typedef struct AVMD5{
3940 uint64_t len;
@@ -41,7 +42,14 @@ typedef struct AVMD5{ · 1 unmodified line
4142 uint32_t ABCD[4];
4243 } AVMD5;
4344
45+#if FF_API_CONTEXT_SIZE
4446 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+}
4553
4654 static const uint8_t S[4][4] = {
4755 { 7, 12, 17, 22 }, /* round 1 */
libavutil/md5.h+7−1
@@ -23,16 +23,22 @@ · 22 unmodified lines
2323
2424 #include <stdint.h>
2525
26+#include "attributes.h"
27+#include "version.h"
28+
2629 /**
2730 * @defgroup lavu_md5 MD5
2831 * @ingroup lavu_crypto
2932 * @{
3033 */
3134
32−extern const int av_md5_size;
35+#if FF_API_CONTEXT_SIZE
36+extern attribute_deprecated const int av_md5_size;
37+#endif
3338
3439 struct AVMD5;
3540
41+struct AVMD5 *av_md5_alloc(void);
3642 void av_md5_init(struct AVMD5 *ctx);
3743 void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, const int len);
3844 void av_md5_final(struct AVMD5 *ctx, uint8_t *dst);
libavutil/parseutils.c+5−4
@@ -690,7 +690,7 @@ int main(void) · 689 unmodified lines
690690 printf("Testing av_parse_video_rate()\n");
691691 {
692692 int i;
693− const char *rates[] = {
693+ static const char *const rates[] = {
694694 "-inf",
695695 "inf",
696696 "nan",
@@ -720,7 +720,7 @@ int main(void) · 23 unmodified lines
720720
721721 for (i = 0; i < FF_ARRAY_ELEMS(rates); i++) {
722722 int ret;
723− AVRational q = (AVRational){0, 0};
723+ AVRational q = { 0, 0 };
724724 ret = av_parse_video_rate(&q, rates[i]);
725725 printf("'%s' -> %d/%d %s\n",
726726 rates[i], q.num, q.den, ret ? "ERROR" : "OK");
@@ -731,7 +731,7 @@ int main(void) · 4 unmodified lines
731731 {
732732 int i;
733733 uint8_t rgba[4];
734− const char *color_names[] = {
734+ static const char *const color_names[] = {
735735 "bikeshed",
736736 "RaNdOm",
737737 "foo",
@@ -774,7 +774,8 @@ int main(void) · 36 unmodified lines
774774
775775 for (i = 0; i < FF_ARRAY_ELEMS(color_names); i++) {
776776 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]);
778779 else
779780 printf("%s -> error\n", color_names[i]);
780781 }
libavutil/sha.c+8−0
@@ -26,6 +26,7 @@ · 25 unmodified lines
2626 #include "bswap.h"
2727 #include "sha.h"
2828 #include "intreadwrite.h"
29+#include "mem.h"
2930
3031 /** hash context */
3132 typedef struct AVSHA {
@@ -37,7 +38,14 @@ typedef struct AVSHA { · 5 unmodified lines
3738 void (*transform)(uint32_t *state, const uint8_t buffer[64]);
3839 } AVSHA;
3940
41+#if FF_API_CONTEXT_SIZE
4042 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+}
4149
4250 #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
4351
libavutil/sha.h+11−1
@@ -23,16 +23,26 @@ · 22 unmodified lines
2323
2424 #include <stdint.h>
2525
26+#include "attributes.h"
27+#include "version.h"
28+
2629 /**
2730 * @defgroup lavu_sha SHA
2831 * @ingroup lavu_crypto
2932 * @{
3033 */
3134
32−extern const int av_sha_size;
35+#if FF_API_CONTEXT_SIZE
36+extern attribute_deprecated const int av_sha_size;
37+#endif
3338
3439 struct AVSHA;
3540
41+/**
42+ * Allocate an AVSHA context.
43+ */
44+struct AVSHA *av_sha_alloc(void);
45+
3646 /**
3747 * Initialize SHA-1 or SHA-2 hashing.
3848 *
libavutil/tree.c+8−1
@@ -28,7 +28,14 @@ typedef struct AVTreeNode { · 27 unmodified lines
2828 int state;
2929 } AVTreeNode;
3030
31+#if FF_API_CONTEXT_SIZE
3132 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+}
3239
3340 void *av_tree_find(const AVTreeNode *t, void *key,
3441 int (*cmp)(void *key, const void *b), void *next[2])
@@ -213,7 +220,7 @@ int main (void) · 178 unmodified lines
213220 }
214221 av_log(NULL, AV_LOG_ERROR, "inserting %4d\n", j);
215222 if (!node)
216− node = av_mallocz(av_tree_node_size);
223+ node = av_tree_node_alloc();
217224 av_tree_insert(&root, (void *) (j + 1), cmp, &node);
218225
219226 j = av_lfg_get(&prng) % 86294;
libavutil/tree.h+11−1
@@ -27,6 +27,9 @@ · 26 unmodified lines
2727 #ifndef AVUTIL_TREE_H
2828 #define AVUTIL_TREE_H
2929
30+#include "attributes.h"
31+#include "version.h"
32+
3033 /**
3134 * @addtogroup lavu_tree AVTree
3235 * @ingroup lavu_data
@@ -40,7 +43,14 @@ · 7 unmodified lines
4043
4144
4245 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);
4454
4555 /**
4656 * Find an element.
libavutil/version.h+4−1
@@ -39,7 +39,7 @@ · 38 unmodified lines
3939 */
4040
4141 #define LIBAVUTIL_VERSION_MAJOR 51
42−#define LIBAVUTIL_VERSION_MINOR 74
42+#define LIBAVUTIL_VERSION_MINOR 75
4343 #define LIBAVUTIL_VERSION_MICRO 100
4444
4545 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
@@ -84,6 +84,9 @@ · 38 unmodified lines
8484 #ifndef FF_API_PIX_FMT
8585 #define FF_API_PIX_FMT (LIBAVUTIL_VERSION_MAJOR < 52)
8686 #endif
87+#ifndef FF_API_CONTEXT_SIZE
88+#define FF_API_CONTEXT_SIZE (LIBAVUTIL_VERSION_MAJOR < 52)
89+#endif
8790
8891 /**
8992 * @}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t