[FFmpeg-cvslog] kgv1dec: make decoder independent of sizeof(AVFrame)
Paul B Mahol
git at videolan.org
Fri Aug 30 20:24:49 CEST 2013
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Aug 30 13:14:58 2013 +0000| [057dce5f21cd70db1ef6e3b67644a39f0d51aba5] | committer: Paul B Mahol
kgv1dec: make decoder independent of sizeof(AVFrame)
Signed-off-by: Paul B Mahol <onemda at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=057dce5f21cd70db1ef6e3b67644a39f0d51aba5
---
libavcodec/kgv1dec.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c
index 9c48239..9064897 100644
--- a/libavcodec/kgv1dec.c
+++ b/libavcodec/kgv1dec.c
@@ -32,14 +32,14 @@
typedef struct {
AVCodecContext *avctx;
- AVFrame prev;
+ AVFrame *prev;
} KgvContext;
static void decode_flush(AVCodecContext *avctx)
{
KgvContext * const c = avctx->priv_data;
- av_frame_unref(&c->prev);
+ av_frame_unref(c->prev);
}
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
@@ -65,7 +65,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
return res;
if (w != avctx->width || h != avctx->height) {
- av_frame_unref(&c->prev);
+ av_frame_unref(c->prev);
avcodec_set_dimensions(avctx, w, h);
}
@@ -74,8 +74,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if ((res = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
return res;
out = frame->data[0];
- if (c->prev.data[0]) {
- prev = c->prev.data[0];
+ if (c->prev->data[0]) {
+ prev = c->prev->data[0];
} else {
prev = NULL;
}
@@ -145,8 +145,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if (outcnt - maxcnt)
av_log(avctx, AV_LOG_DEBUG, "frame finished with %d diff\n", outcnt - maxcnt);
- av_frame_unref(&c->prev);
- if ((res = av_frame_ref(&c->prev, frame)) < 0)
+ av_frame_unref(c->prev);
+ if ((res = av_frame_ref(c->prev, frame)) < 0)
return res;
*got_frame = 1;
@@ -162,12 +162,17 @@ static av_cold int decode_init(AVCodecContext *avctx)
avctx->pix_fmt = AV_PIX_FMT_RGB555;
avctx->flags |= CODEC_FLAG_EMU_EDGE;
+ c->prev = av_frame_alloc();
+ if (!c->prev)
+ return AVERROR(ENOMEM);
+
return 0;
}
static av_cold int decode_end(AVCodecContext *avctx)
{
- decode_flush(avctx);
+ KgvContext * const c = avctx->priv_data;
+ av_frame_free(&c->prev);
return 0;
}
More information about the ffmpeg-cvslog
mailing list