avcodec/webp: use av_packet_alloc() to allocate packets
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
fc2e022a14
commit
4ab7670762
@ -189,6 +189,7 @@ typedef struct WebPContext {
|
|||||||
VP8Context v; /* VP8 Context used for lossy decoding */
|
VP8Context v; /* VP8 Context used for lossy decoding */
|
||||||
GetBitContext gb; /* bitstream reader for main image chunk */
|
GetBitContext gb; /* bitstream reader for main image chunk */
|
||||||
AVFrame *alpha_frame; /* AVFrame for alpha data decompressed from VP8L */
|
AVFrame *alpha_frame; /* AVFrame for alpha data decompressed from VP8L */
|
||||||
|
AVPacket *pkt; /* AVPacket to be passed to the underlying VP8 decoder */
|
||||||
AVCodecContext *avctx; /* parent AVCodecContext */
|
AVCodecContext *avctx; /* parent AVCodecContext */
|
||||||
int initialized; /* set once the VP8 context is initialized */
|
int initialized; /* set once the VP8 context is initialized */
|
||||||
int has_alpha; /* has a separate alpha chunk */
|
int has_alpha; /* has a separate alpha chunk */
|
||||||
@ -1290,7 +1291,6 @@ static int vp8_lossy_decode_frame(AVCodecContext *avctx, AVFrame *p,
|
|||||||
unsigned int data_size)
|
unsigned int data_size)
|
||||||
{
|
{
|
||||||
WebPContext *s = avctx->priv_data;
|
WebPContext *s = avctx->priv_data;
|
||||||
AVPacket pkt;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!s->initialized) {
|
if (!s->initialized) {
|
||||||
@ -1306,11 +1306,11 @@ static int vp8_lossy_decode_frame(AVCodecContext *avctx, AVFrame *p,
|
|||||||
return AVERROR_PATCHWELCOME;
|
return AVERROR_PATCHWELCOME;
|
||||||
}
|
}
|
||||||
|
|
||||||
av_init_packet(&pkt);
|
av_packet_unref(s->pkt);
|
||||||
pkt.data = data_start;
|
s->pkt->data = data_start;
|
||||||
pkt.size = data_size;
|
s->pkt->size = data_size;
|
||||||
|
|
||||||
ret = ff_vp8_decode_frame(avctx, p, got_frame, &pkt);
|
ret = ff_vp8_decode_frame(avctx, p, got_frame, s->pkt);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@ -1527,10 +1527,23 @@ exif_end:
|
|||||||
return avpkt->size;
|
return avpkt->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static av_cold int webp_decode_init(AVCodecContext *avctx)
|
||||||
|
{
|
||||||
|
WebPContext *s = avctx->priv_data;
|
||||||
|
|
||||||
|
s->pkt = av_packet_alloc();
|
||||||
|
if (!s->pkt)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static av_cold int webp_decode_close(AVCodecContext *avctx)
|
static av_cold int webp_decode_close(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
WebPContext *s = avctx->priv_data;
|
WebPContext *s = avctx->priv_data;
|
||||||
|
|
||||||
|
av_packet_free(&s->pkt);
|
||||||
|
|
||||||
if (s->initialized)
|
if (s->initialized)
|
||||||
return ff_vp8_decode_free(avctx);
|
return ff_vp8_decode_free(avctx);
|
||||||
|
|
||||||
@ -1543,6 +1556,7 @@ AVCodec ff_webp_decoder = {
|
|||||||
.type = AVMEDIA_TYPE_VIDEO,
|
.type = AVMEDIA_TYPE_VIDEO,
|
||||||
.id = AV_CODEC_ID_WEBP,
|
.id = AV_CODEC_ID_WEBP,
|
||||||
.priv_data_size = sizeof(WebPContext),
|
.priv_data_size = sizeof(WebPContext),
|
||||||
|
.init = webp_decode_init,
|
||||||
.decode = webp_decode_frame,
|
.decode = webp_decode_frame,
|
||||||
.close = webp_decode_close,
|
.close = webp_decode_close,
|
||||||
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
|
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user