summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavcodec/smc.c22
-rw-r--r--libavcodec/tiertexseqv.c28
-rw-r--r--libavcodec/truemotion1.c22
-rw-r--r--libavcodec/truemotion2.c1
4 files changed, 40 insertions, 33 deletions
diff --git a/libavcodec/smc.c b/libavcodec/smc.c
index 3b836e7c7a..31e6c885bf 100644
--- a/libavcodec/smc.c
+++ b/libavcodec/smc.c
@@ -46,7 +46,7 @@
typedef struct SmcContext {
AVCodecContext *avctx;
- AVFrame frame;
+ AVFrame *frame;
GetByteContext gb;
@@ -81,7 +81,7 @@ static void smc_decode_stream(SmcContext *s)
{
int width = s->avctx->width;
int height = s->avctx->height;
- int stride = s->frame.linesize[0];
+ int stride = s->frame->linesize[0];
int i;
int chunk_size;
int buf_size = bytestream2_size(&s->gb);
@@ -92,9 +92,9 @@ static void smc_decode_stream(SmcContext *s)
unsigned int color_flags_b;
unsigned int flag_mask;
- unsigned char *pixels = s->frame.data[0];
+ unsigned char *pixels = s->frame->data[0];
- int image_size = height * s->frame.linesize[0];
+ int image_size = height * s->frame->linesize[0];
int row_ptr = 0;
int pixel_ptr = 0;
int pixel_x, pixel_y;
@@ -112,7 +112,7 @@ static void smc_decode_stream(SmcContext *s)
int color_octet_index = 0;
/* make the palette available */
- memcpy(s->frame.data[1], s->pal, AVPALETTE_SIZE);
+ memcpy(s->frame->data[1], s->pal, AVPALETTE_SIZE);
bytestream2_skip(&s->gb, 1);
chunk_size = bytestream2_get_be24(&s->gb);
@@ -417,7 +417,9 @@ static av_cold int smc_decode_init(AVCodecContext *avctx)
s->avctx = avctx;
avctx->pix_fmt = AV_PIX_FMT_PAL8;
- avcodec_get_frame_defaults(&s->frame);
+ s->frame = av_frame_alloc();
+ if (!s->frame)
+ return AVERROR(ENOMEM);
return 0;
}
@@ -434,18 +436,18 @@ static int smc_decode_frame(AVCodecContext *avctx,
bytestream2_init(&s->gb, buf, buf_size);
- if ((ret = ff_reget_buffer(avctx, &s->frame)) < 0)
+ if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
return ret;
if (pal) {
- s->frame.palette_has_changed = 1;
+ s->frame->palette_has_changed = 1;
memcpy(s->pal, pal, AVPALETTE_SIZE);
}
smc_decode_stream(s);
*got_frame = 1;
- if ((ret = av_frame_ref(data, &s->frame)) < 0)
+ if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
/* always report that the buffer was completely consumed */
@@ -456,7 +458,7 @@ static av_cold int smc_decode_end(AVCodecContext *avctx)
{
SmcContext *s = avctx->priv_data;
- av_frame_unref(&s->frame);
+ av_frame_free(&s->frame);
return 0;
}
diff --git a/libavcodec/tiertexseqv.c b/libavcodec/tiertexseqv.c
index 0da9afdaa3..7c62208dc5 100644
--- a/libavcodec/tiertexseqv.c
+++ b/libavcodec/tiertexseqv.c
@@ -32,7 +32,7 @@
typedef struct SeqVideoContext {
AVCodecContext *avctx;
- AVFrame frame;
+ AVFrame *frame;
} SeqVideoContext;
@@ -93,14 +93,14 @@ static const unsigned char *seq_decode_op1(SeqVideoContext *seq,
src = seq_unpack_rle_block(src, src_end, block, sizeof(block));
for (b = 0; b < 8; b++) {
memcpy(dst, &block[b * 8], 8);
- dst += seq->frame.linesize[0];
+ dst += seq->frame->linesize[0];
}
break;
case 2:
src = seq_unpack_rle_block(src, src_end, block, sizeof(block));
for (i = 0; i < 8; i++) {
for (b = 0; b < 8; b++)
- dst[b * seq->frame.linesize[0]] = block[i * 8 + b];
+ dst[b * seq->frame->linesize[0]] = block[i * 8 + b];
++dst;
}
break;
@@ -117,7 +117,7 @@ static const unsigned char *seq_decode_op1(SeqVideoContext *seq,
for (b = 0; b < 8; b++) {
for (i = 0; i < 8; i++)
dst[i] = color_table[get_bits(&gb, bits)];
- dst += seq->frame.linesize[0];
+ dst += seq->frame->linesize[0];
}
}
@@ -137,7 +137,7 @@ static const unsigned char *seq_decode_op2(SeqVideoContext *seq,
for (i = 0; i < 8; i++) {
memcpy(dst, src, 8);
src += 8;
- dst += seq->frame.linesize[0];
+ dst += seq->frame->linesize[0];
}
return src;
@@ -154,7 +154,7 @@ static const unsigned char *seq_decode_op3(SeqVideoContext *seq,
if (src_end - src < 2)
return NULL;
pos = *src++;
- offset = ((pos >> 3) & 7) * seq->frame.linesize[0] + (pos & 7);
+ offset = ((pos >> 3) & 7) * seq->frame->linesize[0] + (pos & 7);
dst[offset] = *src++;
} while (!(pos & 0x80));
@@ -173,7 +173,7 @@ static int seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int
flags = *data++;
if (flags & 1) {
- palette = (uint32_t *)seq->frame.data[1];
+ palette = (uint32_t *)seq->frame->data[1];
if (data_end - data < 256 * 3)
return AVERROR_INVALIDDATA;
for (i = 0; i < 256; i++) {
@@ -181,7 +181,7 @@ static int seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int
c[j] = (*data << 2) | (*data >> 4);
palette[i] = 0xFFU << 24 | AV_RB24(c);
}
- seq->frame.palette_has_changed = 1;
+ seq->frame->palette_has_changed = 1;
}
if (flags & 2) {
@@ -190,7 +190,7 @@ static int seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int
init_get_bits(&gb, data, 128 * 8); data += 128;
for (y = 0; y < 128; y += 8)
for (x = 0; x < 256; x += 8) {
- dst = &seq->frame.data[0][y * seq->frame.linesize[0] + x];
+ dst = &seq->frame->data[0][y * seq->frame->linesize[0] + x];
op = get_bits(&gb, 2);
switch (op) {
case 1:
@@ -217,7 +217,9 @@ static av_cold int seqvideo_decode_init(AVCodecContext *avctx)
seq->avctx = avctx;
avctx->pix_fmt = AV_PIX_FMT_PAL8;
- avcodec_get_frame_defaults(&seq->frame);
+ seq->frame = av_frame_alloc();
+ if (!seq->frame)
+ return AVERROR(ENOMEM);
return 0;
}
@@ -232,13 +234,13 @@ static int seqvideo_decode_frame(AVCodecContext *avctx,
SeqVideoContext *seq = avctx->priv_data;
- if ((ret = ff_reget_buffer(avctx, &seq->frame)) < 0)
+ if ((ret = ff_reget_buffer(avctx, seq->frame)) < 0)
return ret;
if (seqvideo_decode(seq, buf, buf_size))
return AVERROR_INVALIDDATA;
- if ((ret = av_frame_ref(data, &seq->frame)) < 0)
+ if ((ret = av_frame_ref(data, seq->frame)) < 0)
return ret;
*got_frame = 1;
@@ -249,7 +251,7 @@ static av_cold int seqvideo_decode_end(AVCodecContext *avctx)
{
SeqVideoContext *seq = avctx->priv_data;
- av_frame_unref(&seq->frame);
+ av_frame_free(&seq->frame);
return 0;
}
diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c
index b1de99b7ea..6e7d305aa4 100644
--- a/libavcodec/truemotion1.c
+++ b/libavcodec/truemotion1.c
@@ -44,7 +44,7 @@
typedef struct TrueMotion1Context {
AVCodecContext *avctx;
- AVFrame frame;
+ AVFrame *frame;
const uint8_t *buf;
int size;
@@ -400,7 +400,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s)
if (s->w != s->avctx->width || s->h != s->avctx->height ||
new_pix_fmt != s->avctx->pix_fmt) {
- av_frame_unref(&s->frame);
+ av_frame_unref(s->frame);
s->avctx->sample_aspect_ratio = (AVRational){ 1 << width_shift, 1 };
s->avctx->pix_fmt = new_pix_fmt;
@@ -471,7 +471,9 @@ static av_cold int truemotion1_decode_init(AVCodecContext *avctx)
// else
// avctx->pix_fmt = AV_PIX_FMT_RGB555;
- avcodec_get_frame_defaults(&s->frame);
+ s->frame = av_frame_alloc();
+ if (!s->frame)
+ return AVERROR(ENOMEM);
/* there is a vertical predictor for each pixel in a line; each vertical
* predictor is 0 to start with */
@@ -614,7 +616,7 @@ static void truemotion1_decode_16bit(TrueMotion1Context *s)
unsigned int horiz_pred;
unsigned int *vert_pred;
unsigned int *current_pixel_pair;
- unsigned char *current_line = s->frame.data[0];
+ unsigned char *current_line = s->frame->data[0];
int keyframe = s->flags & FLAG_KEYFRAME;
/* these variables are for managing the stream of macroblock change bits */
@@ -728,7 +730,7 @@ static void truemotion1_decode_16bit(TrueMotion1Context *s)
if (((y + 1) & 3) == 0)
mb_change_bits += s->mb_change_bits_row_size;
- current_line += s->frame.linesize[0];
+ current_line += s->frame->linesize[0];
}
}
@@ -740,7 +742,7 @@ static void truemotion1_decode_24bit(TrueMotion1Context *s)
unsigned int horiz_pred;
unsigned int *vert_pred;
unsigned int *current_pixel_pair;
- unsigned char *current_line = s->frame.data[0];
+ unsigned char *current_line = s->frame->data[0];
int keyframe = s->flags & FLAG_KEYFRAME;
/* these variables are for managing the stream of macroblock change bits */
@@ -854,7 +856,7 @@ static void truemotion1_decode_24bit(TrueMotion1Context *s)
if (((y + 1) & 3) == 0)
mb_change_bits += s->mb_change_bits_row_size;
- current_line += s->frame.linesize[0];
+ current_line += s->frame->linesize[0];
}
}
@@ -873,7 +875,7 @@ static int truemotion1_decode_frame(AVCodecContext *avctx,
if ((ret = truemotion1_decode_header(s)) < 0)
return ret;
- if ((ret = ff_reget_buffer(avctx, &s->frame)) < 0)
+ if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
return ret;
if (compression_types[s->compression].algorithm == ALGO_RGB24H) {
@@ -882,7 +884,7 @@ static int truemotion1_decode_frame(AVCodecContext *avctx,
truemotion1_decode_16bit(s);
}
- if ((ret = av_frame_ref(data, &s->frame)) < 0)
+ if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
*got_frame = 1;
@@ -895,7 +897,7 @@ static av_cold int truemotion1_decode_end(AVCodecContext *avctx)
{
TrueMotion1Context *s = avctx->priv_data;
- av_frame_unref(&s->frame);
+ av_frame_free(&s->frame);
av_freep(&s->vert_pred);
return 0;
diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c
index 42badcbf8e..a1683f5b1a 100644
--- a/libavcodec/truemotion2.c
+++ b/libavcodec/truemotion2.c
@@ -931,6 +931,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
l->avctx = avctx;
avctx->pix_fmt = AV_PIX_FMT_BGR24;
+
l->pic = av_frame_alloc();
if (!l->pic)
return AVERROR(ENOMEM);