summaryrefslogtreecommitdiff
path: root/ffmpeg/libavcodec/yop.c
diff options
context:
space:
mode:
Diffstat (limited to 'ffmpeg/libavcodec/yop.c')
-rw-r--r--ffmpeg/libavcodec/yop.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/ffmpeg/libavcodec/yop.c b/ffmpeg/libavcodec/yop.c
index e1f5321..c6b19ec 100644
--- a/ffmpeg/libavcodec/yop.c
+++ b/ffmpeg/libavcodec/yop.c
@@ -31,6 +31,7 @@
typedef struct YopDecContext {
AVCodecContext *avctx;
+ AVFrame *frame;
int num_pal_colors;
int first_color[2];
@@ -78,6 +79,15 @@ static const int8_t motion_vector[16][2] =
{ 4, -2}, {-2, 0},
};
+static av_cold int yop_decode_close(AVCodecContext *avctx)
+{
+ YopDecContext *s = avctx->priv_data;
+
+ av_frame_free(&s->frame);
+
+ return 0;
+}
+
static av_cold int yop_decode_init(AVCodecContext *avctx)
{
YopDecContext *s = avctx->priv_data;
@@ -107,6 +117,10 @@ static av_cold int yop_decode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
}
+ s->frame = av_frame_alloc();
+ if (!s->frame)
+ return AVERROR(ENOMEM);
+
return 0;
}
@@ -178,7 +192,7 @@ static int yop_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
YopDecContext *s = avctx->priv_data;
- AVFrame *frame = data;
+ AVFrame *frame = s->frame;
int tag, firstcolor, is_odd_frame;
int ret, i, x, y;
uint32_t *palette;
@@ -188,7 +202,7 @@ static int yop_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
return AVERROR_INVALIDDATA;
}
- if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
+ if ((ret = ff_reget_buffer(avctx, frame)) < 0)
return ret;
if (!avctx->frame_number)
@@ -242,16 +256,20 @@ static int yop_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
s->dstptr += 2*frame->linesize[0] - x;
}
+ if ((ret = av_frame_ref(data, s->frame)) < 0)
+ return ret;
+
*got_frame = 1;
return avpkt->size;
}
AVCodec ff_yop_decoder = {
.name = "yop",
+ .long_name = NULL_IF_CONFIG_SMALL("Psygnosis YOP Video"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_YOP,
.priv_data_size = sizeof(YopDecContext),
.init = yop_decode_init,
+ .close = yop_decode_close,
.decode = yop_decode_frame,
- .long_name = NULL_IF_CONFIG_SMALL("Psygnosis YOP Video"),
};