Commit f391e405 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'e002e329'

* commit 'e002e329':
  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: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents d6135a88 e002e329
......@@ -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.
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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++;
......
......@@ -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);
......
......@@ -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
......
......@@ -23,16 +23,26 @@
#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
......
......@@ -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 */
......
......@@ -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);
......
......@@ -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]);
}
......
......@@ -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))))
......
......@@ -23,16 +23,26 @@
#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.
*
......
......@@ -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;
......
......@@ -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.
......
......@@ -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
/**
* @}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment