aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-11-09 10:14:46 +0100
committerAnton Khirnov <anton@khirnov.net>2013-11-16 13:23:59 +0100
commitd100f9e7cd6d3508359c76bdcffcab4dff4d6bc6 (patch)
treecd7bd109a8bae7a813d749c2aec2a8856056f17f
parent84099f51f397fb1105c543193785c959f9d3901d (diff)
downloadffmpeg-d100f9e7cd6d3508359c76bdcffcab4dff4d6bc6.tar.gz
flicvideo: use the AVFrame API properly.
-rw-r--r--libavcodec/flicvideo.c61
1 files changed, 32 insertions, 29 deletions
diff --git a/libavcodec/flicvideo.c b/libavcodec/flicvideo.c
index ff1d8201ac..68f45b4c65 100644
--- a/libavcodec/flicvideo.c
+++ b/libavcodec/flicvideo.c
@@ -71,7 +71,7 @@
typedef struct FlicDecodeContext {
AVCodecContext *avctx;
- AVFrame frame;
+ AVFrame *frame;
unsigned int palette[256];
int new_palette;
@@ -123,7 +123,10 @@ static av_cold int flic_decode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
}
- avcodec_get_frame_defaults(&s->frame);
+ s->frame = av_frame_alloc();
+ if (!s->frame)
+ return AVERROR(ENOMEM);
+
s->new_palette = 0;
return 0;
@@ -168,13 +171,13 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
bytestream2_init(&g2, buf, buf_size);
- if ((ret = ff_reget_buffer(avctx, &s->frame)) < 0) {
+ if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
return ret;
}
- pixels = s->frame.data[0];
- pixel_limit = s->avctx->height * s->frame.linesize[0];
+ pixels = s->frame->data[0];
+ pixel_limit = s->avctx->height * s->frame->linesize[0];
frame_size = bytestream2_get_le32(&g2);
bytestream2_skip(&g2, 2); /* skip the magic number */
num_chunks = bytestream2_get_le16(&g2);
@@ -248,12 +251,12 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
if ((line_packets & 0xC000) == 0xC000) {
// line skip opcode
line_packets = -line_packets;
- y_ptr += line_packets * s->frame.linesize[0];
+ y_ptr += line_packets * s->frame->linesize[0];
} else if ((line_packets & 0xC000) == 0x4000) {
av_log(avctx, AV_LOG_ERROR, "Undefined opcode (%x) in DELTA_FLI\n", line_packets);
} else if ((line_packets & 0xC000) == 0x8000) {
// "last byte" opcode
- pixel_ptr= y_ptr + s->frame.linesize[0] - 1;
+ pixel_ptr= y_ptr + s->frame->linesize[0] - 1;
CHECK_PIXEL_PTR(0);
pixels[pixel_ptr] = line_packets & 0xff;
} else {
@@ -284,7 +287,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
}
}
- y_ptr += s->frame.linesize[0];
+ y_ptr += s->frame->linesize[0];
}
}
break;
@@ -293,7 +296,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
/* line compressed */
starting_line = bytestream2_get_le16(&g2);
y_ptr = 0;
- y_ptr += starting_line * s->frame.linesize[0];
+ y_ptr += starting_line * s->frame->linesize[0];
compressed_lines = bytestream2_get_le16(&g2);
while (compressed_lines > 0) {
@@ -324,7 +327,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
}
}
- y_ptr += s->frame.linesize[0];
+ y_ptr += s->frame->linesize[0];
compressed_lines--;
}
break;
@@ -332,7 +335,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
case FLI_BLACK:
/* set the whole frame to color 0 (which is usually black) */
memset(pixels, 0,
- s->frame.linesize[0] * s->avctx->height);
+ s->frame->linesize[0] * s->avctx->height);
break;
case FLI_BRUN:
@@ -375,7 +378,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
}
}
- y_ptr += s->frame.linesize[0];
+ y_ptr += s->frame->linesize[0];
}
break;
@@ -386,8 +389,8 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
"bigger than image, skipping chunk\n", chunk_size - 6);
bytestream2_skip(&g2, chunk_size - 6);
} else {
- for (y_ptr = 0; y_ptr < s->frame.linesize[0] * s->avctx->height;
- y_ptr += s->frame.linesize[0]) {
+ for (y_ptr = 0; y_ptr < s->frame->linesize[0] * s->avctx->height;
+ y_ptr += s->frame->linesize[0]) {
bytestream2_get_buffer(&g2, &pixels[y_ptr],
s->avctx->width);
}
@@ -417,13 +420,13 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
buf_size - bytestream2_get_bytes_left(&g2));
/* make the palette available on the way out */
- memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE);
+ memcpy(s->frame->data[1], s->palette, AVPALETTE_SIZE);
if (s->new_palette) {
- s->frame.palette_has_changed = 1;
+ s->frame->palette_has_changed = 1;
s->new_palette = 0;
}
- if ((ret = av_frame_ref(data, &s->frame)) < 0)
+ if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
*got_frame = 1;
@@ -464,13 +467,13 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
bytestream2_init(&g2, buf, buf_size);
- if ((ret = ff_reget_buffer(avctx, &s->frame)) < 0) {
+ if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
return ret;
}
- pixels = s->frame.data[0];
- pixel_limit = s->avctx->height * s->frame.linesize[0];
+ pixels = s->frame->data[0];
+ pixel_limit = s->avctx->height * s->frame->linesize[0];
frame_size = bytestream2_get_le32(&g2);
bytestream2_skip(&g2, 2); /* skip the magic number */
@@ -504,7 +507,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
line_packets = bytestream2_get_le16(&g2);
if (line_packets < 0) {
line_packets = -line_packets;
- y_ptr += line_packets * s->frame.linesize[0];
+ y_ptr += line_packets * s->frame->linesize[0];
} else {
compressed_lines--;
pixel_ptr = y_ptr;
@@ -533,7 +536,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
}
}
- y_ptr += s->frame.linesize[0];
+ y_ptr += s->frame->linesize[0];
}
}
break;
@@ -546,7 +549,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
case FLI_BLACK:
/* set the whole frame to 0x0000 which is black in both 15Bpp and 16Bpp modes. */
memset(pixels, 0x0000,
- s->frame.linesize[0] * s->avctx->height);
+ s->frame->linesize[0] * s->avctx->height);
break;
case FLI_BRUN:
@@ -597,7 +600,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
pixel_ptr += 2;
}
#endif
- y_ptr += s->frame.linesize[0];
+ y_ptr += s->frame->linesize[0];
}
break;
@@ -637,7 +640,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
}
}
- y_ptr += s->frame.linesize[0];
+ y_ptr += s->frame->linesize[0];
}
break;
@@ -650,8 +653,8 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
bytestream2_skip(&g2, chunk_size - 6);
} else {
- for (y_ptr = 0; y_ptr < s->frame.linesize[0] * s->avctx->height;
- y_ptr += s->frame.linesize[0]) {
+ for (y_ptr = 0; y_ptr < s->frame->linesize[0] * s->avctx->height;
+ y_ptr += s->frame->linesize[0]) {
pixel_countdown = s->avctx->width;
pixel_ptr = 0;
@@ -684,7 +687,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
av_log(avctx, AV_LOG_ERROR, "Processed FLI chunk where chunk size = %d " \
"and final chunk ptr = %d\n", buf_size, bytestream2_tell(&g2));
- if ((ret = av_frame_ref(data, &s->frame)) < 0)
+ if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
*got_frame = 1;
@@ -733,7 +736,7 @@ static av_cold int flic_decode_end(AVCodecContext *avctx)
{
FlicDecodeContext *s = avctx->priv_data;
- av_frame_unref(&s->frame);
+ av_frame_free(&s->frame);
return 0;
}