You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-07-16 22:42:38 +02:00
kgv1: use the AVFrame API properly.
This commit is contained in:
@ -32,14 +32,14 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
AVCodecContext *avctx;
|
AVCodecContext *avctx;
|
||||||
AVFrame prev;
|
AVFrame *prev;
|
||||||
} KgvContext;
|
} KgvContext;
|
||||||
|
|
||||||
static void decode_flush(AVCodecContext *avctx)
|
static void decode_flush(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
KgvContext * const c = avctx->priv_data;
|
KgvContext * const c = avctx->priv_data;
|
||||||
|
|
||||||
av_frame_unref(&c->prev);
|
av_frame_free(&c->prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
||||||
@ -62,7 +62,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
|||||||
buf += 2;
|
buf += 2;
|
||||||
|
|
||||||
if (w != avctx->width || h != avctx->height) {
|
if (w != avctx->width || h != avctx->height) {
|
||||||
av_frame_unref(&c->prev);
|
av_frame_unref(c->prev);
|
||||||
if ((res = ff_set_dimensions(avctx, w, h)) < 0)
|
if ((res = ff_set_dimensions(avctx, w, h)) < 0)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -72,8 +72,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)
|
if ((res = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
|
||||||
return res;
|
return res;
|
||||||
out = (uint16_t *) frame->data[0];
|
out = (uint16_t *) frame->data[0];
|
||||||
if (c->prev.data[0]) {
|
if (c->prev->data[0]) {
|
||||||
prev = (uint16_t *) c->prev.data[0];
|
prev = (uint16_t *) c->prev->data[0];
|
||||||
} else {
|
} else {
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
}
|
}
|
||||||
@ -152,8 +152,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
|||||||
if (outcnt - maxcnt)
|
if (outcnt - maxcnt)
|
||||||
av_log(avctx, AV_LOG_DEBUG, "frame finished with %d diff\n", outcnt - maxcnt);
|
av_log(avctx, AV_LOG_DEBUG, "frame finished with %d diff\n", outcnt - maxcnt);
|
||||||
|
|
||||||
av_frame_unref(&c->prev);
|
av_frame_unref(c->prev);
|
||||||
if ((res = av_frame_ref(&c->prev, frame)) < 0)
|
if ((res = av_frame_ref(c->prev, frame)) < 0)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
@ -165,6 +165,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
{
|
{
|
||||||
KgvContext * const c = avctx->priv_data;
|
KgvContext * const c = avctx->priv_data;
|
||||||
|
|
||||||
|
c->prev = av_frame_alloc();
|
||||||
|
if (!c->prev)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
c->avctx = avctx;
|
c->avctx = avctx;
|
||||||
avctx->pix_fmt = AV_PIX_FMT_RGB555;
|
avctx->pix_fmt = AV_PIX_FMT_RGB555;
|
||||||
avctx->flags |= CODEC_FLAG_EMU_EDGE;
|
avctx->flags |= CODEC_FLAG_EMU_EDGE;
|
||||||
|
Reference in New Issue
Block a user