#include "libavutil/attributes.h"
#include "libavutil/crc.h"
+#include "libavutil/mem_internal.h"
#include "internal.h"
#include "avcodec.h"
typedef struct SVQ3Frame {
AVFrame *f;
- AVBufferRef *motion_val_buf[2];
+ int16_t (*motion_val_buf[2])[2];
int16_t (*motion_val[2])[2];
- AVBufferRef *mb_type_buf;
- uint32_t *mb_type;
-
-
- AVBufferRef *ref_index_buf[2];
- int8_t *ref_index[2];
+ uint32_t *mb_type_buf, *mb_type;
} SVQ3Frame;
typedef struct SVQ3Context {
{
int i;
for (i = 0; i < 2; i++) {
- av_buffer_unref(&pic->motion_val_buf[i]);
- av_buffer_unref(&pic->ref_index_buf[i]);
+ av_freep(&pic->motion_val_buf[i]);
}
- av_buffer_unref(&pic->mb_type_buf);
+ av_freep(&pic->mb_type_buf);
av_frame_unref(pic->f);
}
{
SVQ3Context *s = avctx->priv_data;
const int big_mb_num = s->mb_stride * (s->mb_height + 1) + 1;
- const int mb_array_size = s->mb_stride * s->mb_height;
const int b4_stride = s->mb_width * 4 + 1;
const int b4_array_size = b4_stride * s->mb_height * 4;
int ret;
if (!pic->motion_val_buf[0]) {
int i;
- pic->mb_type_buf = av_buffer_allocz((big_mb_num + s->mb_stride) * sizeof(uint32_t));
+ pic->mb_type_buf = av_calloc(big_mb_num + s->mb_stride, sizeof(uint32_t));
if (!pic->mb_type_buf)
return AVERROR(ENOMEM);
- pic->mb_type = (uint32_t*)pic->mb_type_buf->data + 2 * s->mb_stride + 1;
+ pic->mb_type = pic->mb_type_buf + 2 * s->mb_stride + 1;
for (i = 0; i < 2; i++) {
- pic->motion_val_buf[i] = av_buffer_allocz(2 * (b4_array_size + 4) * sizeof(int16_t));
- pic->ref_index_buf[i] = av_buffer_allocz(4 * mb_array_size);
- if (!pic->motion_val_buf[i] || !pic->ref_index_buf[i]) {
+ pic->motion_val_buf[i] = av_calloc(b4_array_size + 4, 2 * sizeof(int16_t));
+ if (!pic->motion_val_buf[i]) {
ret = AVERROR(ENOMEM);
goto fail;
}
- pic->motion_val[i] = (int16_t (*)[2])pic->motion_val_buf[i]->data + 4;
- pic->ref_index[i] = pic->ref_index_buf[i]->data;
+ pic->motion_val[i] = pic->motion_val_buf[i] + 4;
}
}