1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-04-24 17:12:34 +02:00

avcodec/bintext: Use ff_get_buffer instead of ff_reget_buffer and simplify

reget seems unneeded and it is slower

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2018-09-12 02:14:47 +02:00
parent 8db9097308
commit db6af88cd0

View File

@ -96,11 +96,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
if (avctx->width < FONT_WIDTH || avctx->height < s->font_height) if (avctx->width < FONT_WIDTH || avctx->height < s->font_height)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
s->frame = av_frame_alloc();
if (!s->frame)
return AVERROR(ENOMEM);
return 0; return 0;
} }
@ -149,8 +144,9 @@ static int decode_frame(AVCodecContext *avctx,
if ((avctx->width / FONT_WIDTH) * (avctx->height / s->font_height) / 256 > buf_size) if ((avctx->width / FONT_WIDTH) * (avctx->height / s->font_height) / 256 > buf_size)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
s->frame = data;
s->x = s->y = 0; s->x = s->y = 0;
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) if ((ret = ff_get_buffer(avctx, s->frame, 0)) < 0)
return ret; return ret;
s->frame->pict_type = AV_PICTURE_TYPE_I; s->frame->pict_type = AV_PICTURE_TYPE_I;
s->frame->palette_has_changed = 1; s->frame->palette_has_changed = 1;
@ -208,21 +204,10 @@ static int decode_frame(AVCodecContext *avctx,
} }
} }
if ((ret = av_frame_ref(data, s->frame)) < 0)
return ret;
*got_frame = 1; *got_frame = 1;
return buf_size; return buf_size;
} }
static av_cold int decode_end(AVCodecContext *avctx)
{
XbinContext *s = avctx->priv_data;
av_frame_free(&s->frame);
return 0;
}
#if CONFIG_BINTEXT_DECODER #if CONFIG_BINTEXT_DECODER
AVCodec ff_bintext_decoder = { AVCodec ff_bintext_decoder = {
.name = "bintext", .name = "bintext",
@ -231,7 +216,6 @@ AVCodec ff_bintext_decoder = {
.id = AV_CODEC_ID_BINTEXT, .id = AV_CODEC_ID_BINTEXT,
.priv_data_size = sizeof(XbinContext), .priv_data_size = sizeof(XbinContext),
.init = decode_init, .init = decode_init,
.close = decode_end,
.decode = decode_frame, .decode = decode_frame,
.capabilities = AV_CODEC_CAP_DR1, .capabilities = AV_CODEC_CAP_DR1,
}; };
@ -244,7 +228,6 @@ AVCodec ff_xbin_decoder = {
.id = AV_CODEC_ID_XBIN, .id = AV_CODEC_ID_XBIN,
.priv_data_size = sizeof(XbinContext), .priv_data_size = sizeof(XbinContext),
.init = decode_init, .init = decode_init,
.close = decode_end,
.decode = decode_frame, .decode = decode_frame,
.capabilities = AV_CODEC_CAP_DR1, .capabilities = AV_CODEC_CAP_DR1,
}; };
@ -257,7 +240,6 @@ AVCodec ff_idf_decoder = {
.id = AV_CODEC_ID_IDF, .id = AV_CODEC_ID_IDF,
.priv_data_size = sizeof(XbinContext), .priv_data_size = sizeof(XbinContext),
.init = decode_init, .init = decode_init,
.close = decode_end,
.decode = decode_frame, .decode = decode_frame,
.capabilities = AV_CODEC_CAP_DR1, .capabilities = AV_CODEC_CAP_DR1,
}; };