mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-02-04 06:08:26 +02:00
avcodec/sgirledec: simplify, no need to use reget buffer
Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
parent
a3eb5a3cdd
commit
ccc3f4e710
@ -31,17 +31,9 @@
|
|||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
typedef struct SGIRLEContext {
|
|
||||||
AVFrame *frame;
|
|
||||||
} SGIRLEContext;
|
|
||||||
|
|
||||||
static av_cold int sgirle_decode_init(AVCodecContext *avctx)
|
static av_cold int sgirle_decode_init(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
SGIRLEContext *s = avctx->priv_data;
|
|
||||||
avctx->pix_fmt = AV_PIX_FMT_BGR8;
|
avctx->pix_fmt = AV_PIX_FMT_BGR8;
|
||||||
s->frame = av_frame_alloc();
|
|
||||||
if (!s->frame)
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,41 +112,31 @@ static int decode_sgirle8(AVCodecContext *avctx, uint8_t *dst,
|
|||||||
static int sgirle_decode_frame(AVCodecContext *avctx, void *data,
|
static int sgirle_decode_frame(AVCodecContext *avctx, void *data,
|
||||||
int *got_frame, AVPacket *avpkt)
|
int *got_frame, AVPacket *avpkt)
|
||||||
{
|
{
|
||||||
SGIRLEContext *s = avctx->priv_data;
|
AVFrame *frame = data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
|
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = decode_sgirle8(avctx, s->frame->data[0], avpkt->data, avpkt->size,
|
ret = decode_sgirle8(avctx, frame->data[0], avpkt->data, avpkt->size,
|
||||||
avctx->width, avctx->height, s->frame->linesize[0]);
|
avctx->width, avctx->height, frame->linesize[0]);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
frame->pict_type = AV_PICTURE_TYPE_I;
|
||||||
|
frame->key_frame = 1;
|
||||||
|
|
||||||
*got_frame = 1;
|
*got_frame = 1;
|
||||||
if ((ret = av_frame_ref(data, s->frame)) < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return avpkt->size;
|
return avpkt->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_cold int sgirle_decode_end(AVCodecContext *avctx)
|
|
||||||
{
|
|
||||||
SGIRLEContext *s = avctx->priv_data;
|
|
||||||
|
|
||||||
av_frame_free(&s->frame);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
AVCodec ff_sgirle_decoder = {
|
AVCodec ff_sgirle_decoder = {
|
||||||
.name = "sgirle",
|
.name = "sgirle",
|
||||||
.long_name = NULL_IF_CONFIG_SMALL("Silicon Graphics RLE 8-bit video"),
|
.long_name = NULL_IF_CONFIG_SMALL("Silicon Graphics RLE 8-bit video"),
|
||||||
.type = AVMEDIA_TYPE_VIDEO,
|
.type = AVMEDIA_TYPE_VIDEO,
|
||||||
.id = AV_CODEC_ID_SGIRLE,
|
.id = AV_CODEC_ID_SGIRLE,
|
||||||
.priv_data_size = sizeof(SGIRLEContext),
|
|
||||||
.init = sgirle_decode_init,
|
.init = sgirle_decode_init,
|
||||||
.close = sgirle_decode_end,
|
|
||||||
.decode = sgirle_decode_frame,
|
.decode = sgirle_decode_frame,
|
||||||
.capabilities = AV_CODEC_CAP_DR1,
|
.capabilities = AV_CODEC_CAP_DR1,
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user