Commit 5ce1d089 authored by Paul B Mahol's avatar Paul B Mahol

avcodec/mvcdec: simplify, no need to use reget buffer

Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent 566be4f9
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "internal.h" #include "internal.h"
typedef struct MvcContext { typedef struct MvcContext {
AVFrame *frame;
int vflip; int vflip;
} MvcContext; } MvcContext;
...@@ -53,10 +52,6 @@ static av_cold int mvc_decode_init(AVCodecContext *avctx) ...@@ -53,10 +52,6 @@ static av_cold int mvc_decode_init(AVCodecContext *avctx)
avctx->pix_fmt = (avctx->codec_id == AV_CODEC_ID_MVC1) ? AV_PIX_FMT_RGB555 avctx->pix_fmt = (avctx->codec_id == AV_CODEC_ID_MVC1) ? AV_PIX_FMT_RGB555
: AV_PIX_FMT_RGB32; : AV_PIX_FMT_RGB32;
s->frame = av_frame_alloc();
if (!s->frame)
return AVERROR(ENOMEM);
s->vflip = avctx->extradata_size >= 9 && s->vflip = avctx->extradata_size >= 9 &&
!memcmp(avctx->extradata + avctx->extradata_size - 9, "BottomUp", 9); !memcmp(avctx->extradata + avctx->extradata_size - 9, "BottomUp", 9);
return 0; return 0;
...@@ -231,39 +226,32 @@ static int mvc_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -231,39 +226,32 @@ static int mvc_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt) AVPacket *avpkt)
{ {
MvcContext *s = avctx->priv_data; MvcContext *s = avctx->priv_data;
AVFrame *frame = data;
GetByteContext gb; GetByteContext gb;
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;
bytestream2_init(&gb, avpkt->data, avpkt->size); bytestream2_init(&gb, avpkt->data, avpkt->size);
if (avctx->codec_id == AV_CODEC_ID_MVC1) if (avctx->codec_id == AV_CODEC_ID_MVC1)
ret = decode_mvc1(avctx, &gb, s->frame->data[0], ret = decode_mvc1(avctx, &gb, frame->data[0],
avctx->width, avctx->height, s->frame->linesize[0]); avctx->width, avctx->height, frame->linesize[0]);
else else
ret = decode_mvc2(avctx, &gb, s->frame->data[0], ret = decode_mvc2(avctx, &gb, frame->data[0],
avctx->width, avctx->height, s->frame->linesize[0], avctx->width, avctx->height, frame->linesize[0],
s->vflip); s->vflip);
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 mvc_decode_end(AVCodecContext *avctx)
{
MvcContext *s = avctx->priv_data;
av_frame_free(&s->frame);
return 0;
}
#if CONFIG_MVC1_DECODER #if CONFIG_MVC1_DECODER
AVCodec ff_mvc1_decoder = { AVCodec ff_mvc1_decoder = {
.name = "mvc1", .name = "mvc1",
...@@ -272,7 +260,6 @@ AVCodec ff_mvc1_decoder = { ...@@ -272,7 +260,6 @@ AVCodec ff_mvc1_decoder = {
.id = AV_CODEC_ID_MVC1, .id = AV_CODEC_ID_MVC1,
.priv_data_size = sizeof(MvcContext), .priv_data_size = sizeof(MvcContext),
.init = mvc_decode_init, .init = mvc_decode_init,
.close = mvc_decode_end,
.decode = mvc_decode_frame, .decode = mvc_decode_frame,
.capabilities = AV_CODEC_CAP_DR1, .capabilities = AV_CODEC_CAP_DR1,
}; };
...@@ -286,7 +273,6 @@ AVCodec ff_mvc2_decoder = { ...@@ -286,7 +273,6 @@ AVCodec ff_mvc2_decoder = {
.id = AV_CODEC_ID_MVC2, .id = AV_CODEC_ID_MVC2,
.priv_data_size = sizeof(MvcContext), .priv_data_size = sizeof(MvcContext),
.init = mvc_decode_init, .init = mvc_decode_init,
.close = mvc_decode_end,
.decode = mvc_decode_frame, .decode = mvc_decode_frame,
.capabilities = AV_CODEC_CAP_DR1, .capabilities = AV_CODEC_CAP_DR1,
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment