summaryrefslogtreecommitdiffstats
path: root/libavcodec/flicvideo.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-11-17 01:48:57 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-11-17 01:55:38 +0100
commitfe3808eddee81ce4712d1e729fa6fe619f1685c8 (patch)
treecedf1b912ffed79311b5beb8b8d9f4196fa261b6 /libavcodec/flicvideo.c
parent9f890a165666a73376c73b3c2bd920345b5c3b79 (diff)
parenta837c4f2df96a30bf9aa4115b426d608487c7101 (diff)
downloadffmpeg-streaming-fe3808eddee81ce4712d1e729fa6fe619f1685c8.zip
ffmpeg-streaming-fe3808eddee81ce4712d1e729fa6fe619f1685c8.tar.gz
Merge commit 'a837c4f2df96a30bf9aa4115b426d608487c7101'
* commit 'a837c4f2df96a30bf9aa4115b426d608487c7101': zmbvenc: use the AVFrame API properly. flicvideo: use the AVFrame API properly. smacker: use the AVFrame API properly. mmvideo: use the AVFrame API properly. Conflicts: libavcodec/flicvideo.c libavcodec/mmvideo.c libavcodec/smacker.c libavcodec/zmbvenc.c See: 76e27b1d0594199b4b1ff8520312069f42373944 See: 099e57bc38d7e53cf6823dfec349ff9fdaee99ba Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/flicvideo.c')
-rw-r--r--libavcodec/flicvideo.c61
1 files changed, 32 insertions, 29 deletions
diff --git a/libavcodec/flicvideo.c b/libavcodec/flicvideo.c
index 76a7976..a2d59e8 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;
@@ -141,7 +141,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;
@@ -185,11 +188,11 @@ 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)
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];
if (buf_size < 16 || buf_size > INT_MAX - (3 * 256 + FF_INPUT_BUFFER_PADDING_SIZE))
return AVERROR_INVALIDDATA;
frame_size = bytestream2_get_le32(&g2);
@@ -273,12 +276,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 {
@@ -313,7 +316,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
}
}
- y_ptr += s->frame.linesize[0];
+ y_ptr += s->frame->linesize[0];
}
}
break;
@@ -322,7 +325,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) {
@@ -359,7 +362,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
}
}
- y_ptr += s->frame.linesize[0];
+ y_ptr += s->frame->linesize[0];
compressed_lines--;
}
break;
@@ -367,7 +370,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:
@@ -414,7 +417,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
}
}
- y_ptr += s->frame.linesize[0];
+ y_ptr += s->frame->linesize[0];
}
break;
@@ -425,8 +428,8 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
"has incorrect size, 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);
}
@@ -457,13 +460,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;
@@ -504,11 +507,11 @@ 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)
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 */
@@ -556,7 +559,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;
@@ -589,7 +592,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
}
}
- y_ptr += s->frame.linesize[0];
+ y_ptr += s->frame->linesize[0];
}
}
break;
@@ -602,7 +605,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:
@@ -657,7 +660,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;
@@ -701,7 +704,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
}
}
- y_ptr += s->frame.linesize[0];
+ y_ptr += s->frame->linesize[0];
}
break;
@@ -714,8 +717,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;
@@ -748,7 +751,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;
@@ -797,7 +800,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;
}
OpenPOWER on IntegriCloud