Unified · Split
| @@ -189,6 +189,7 @@ typedef struct WebPContext { · 188 unmodified lines | |||
| 189 | VP8Context v; /* VP8 Context used for lossy decoding */ | 189 | VP8Context v; /* VP8 Context used for lossy decoding */ |
| 190 | GetBitContext gb; /* bitstream reader for main image chunk */ | 190 | GetBitContext gb; /* bitstream reader for main image chunk */ |
| 191 | AVFrame *alpha_frame; /* AVFrame for alpha data decompressed from VP8L */ | 191 | AVFrame *alpha_frame; /* AVFrame for alpha data decompressed from VP8L */ |
| 192 | AVPacket *pkt; /* AVPacket to be passed to the underlying VP8 decoder */ | ||
| 192 | AVCodecContext *avctx; /* parent AVCodecContext */ | 193 | AVCodecContext *avctx; /* parent AVCodecContext */ |
| 193 | int initialized; /* set once the VP8 context is initialized */ | 194 | int initialized; /* set once the VP8 context is initialized */ |
| 194 | int has_alpha; /* has a separate alpha chunk */ | 195 | int has_alpha; /* has a separate alpha chunk */ |
| @@ -1290,7 +1291,6 @@ static int vp8_lossy_decode_frame(AVCodecContext *avctx, AVFrame *p, · 1095 unmodified lines | |||
| 1290 | unsigned int data_size) | 1291 | unsigned int data_size) |
| 1291 | { | 1292 | { |
| 1292 | WebPContext *s = avctx->priv_data; | 1293 | WebPContext *s = avctx->priv_data; |
| 1293 | AVPacket pkt; | ||
| 1294 | int ret; | 1294 | int ret; |
| 1295 | 1295 | ||
| 1296 | if (!s->initialized) { | 1296 | if (!s->initialized) { |
| @@ -1306,11 +1306,11 @@ static int vp8_lossy_decode_frame(AVCodecContext *avctx, AVFrame *p, · 9 unmodified lines | |||
| 1306 | return AVERROR_PATCHWELCOME; | 1306 | return AVERROR_PATCHWELCOME; |
| 1307 | } | 1307 | } |
| 1308 | 1308 | ||
| 1309 | av_init_packet(&pkt); | 1309 | av_packet_unref(s->pkt); |
| 1310 | pkt.data = data_start; | 1310 | s->pkt->data = data_start; |
| 1311 | pkt.size = data_size; | 1311 | s->pkt->size = data_size; |
| 1312 | 1312 | ||
| 1313 | ret = ff_vp8_decode_frame(avctx, p, got_frame, &pkt); | 1313 | ret = ff_vp8_decode_frame(avctx, p, got_frame, s->pkt); |
| 1314 | if (ret < 0) | 1314 | if (ret < 0) |
| 1315 | return ret; | 1315 | return ret; |
| 1316 | 1316 | ||
| @@ -1527,10 +1527,23 @@ exif_end: · 210 unmodified lines | |||
| 1527 | return avpkt->size; | 1527 | return avpkt->size; |
| 1528 | } | 1528 | } |
| 1529 | 1529 | ||
| 1530 | static av_cold int webp_decode_init(AVCodecContext *avctx) | ||
| 1531 | { | ||
| 1532 | WebPContext *s = avctx->priv_data; | ||
| 1533 | |||
| 1534 | s->pkt = av_packet_alloc(); | ||
| 1535 | if (!s->pkt) | ||
| 1536 | return AVERROR(ENOMEM); | ||
| 1537 | |||
| 1538 | return 0; | ||
| 1539 | } | ||
| 1540 | |||
| 1530 | static av_cold int webp_decode_close(AVCodecContext *avctx) | 1541 | static av_cold int webp_decode_close(AVCodecContext *avctx) |
| 1531 | { | 1542 | { |
| 1532 | WebPContext *s = avctx->priv_data; | 1543 | WebPContext *s = avctx->priv_data; |
| 1533 | 1544 | ||
| 1545 | av_packet_free(&s->pkt); | ||
| 1546 | |||
| 1534 | if (s->initialized) | 1547 | if (s->initialized) |
| 1535 | return ff_vp8_decode_free(avctx); | 1548 | return ff_vp8_decode_free(avctx); |
| 1536 | 1549 | ||
| @@ -1543,6 +1556,7 @@ AVCodec ff_webp_decoder = { · 6 unmodified lines | |||
| 1543 | .type = AVMEDIA_TYPE_VIDEO, | 1556 | .type = AVMEDIA_TYPE_VIDEO, |
| 1544 | .id = AV_CODEC_ID_WEBP, | 1557 | .id = AV_CODEC_ID_WEBP, |
| 1545 | .priv_data_size = sizeof(WebPContext), | 1558 | .priv_data_size = sizeof(WebPContext), |
| 1559 | .init = webp_decode_init, | ||
| 1546 | .decode = webp_decode_frame, | 1560 | .decode = webp_decode_frame, |
| 1547 | .close = webp_decode_close, | 1561 | .close = webp_decode_close, |
| 1548 | .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, | 1562 | .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, |