mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-01-16 04:11:12 +00:00
avcodec/libwebpenc: Allow user-supplied buffers
Here the packet size is known before allocating the packet, so that supporting user-supplied buffers is trivial. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
e099a29f5a
commit
ad26efbf52
@ -24,6 +24,7 @@
|
||||
* WebP encoder using libwebp (WebPEncode API)
|
||||
*/
|
||||
|
||||
#include "encode.h"
|
||||
#include "libwebpenc_common.h"
|
||||
|
||||
typedef LibWebPContextCommon LibWebPContext;
|
||||
@ -57,7 +58,7 @@ static int libwebp_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = ff_alloc_packet2(avctx, pkt, mw.size, mw.size);
|
||||
ret = ff_get_encode_buffer(avctx, pkt, mw.size, 0);
|
||||
if (ret < 0)
|
||||
goto end;
|
||||
memcpy(pkt->data, mw.mem, mw.size);
|
||||
@ -98,6 +99,7 @@ const AVCodec ff_libwebp_encoder = {
|
||||
.long_name = NULL_IF_CONFIG_SMALL("libwebp WebP image"),
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.id = AV_CODEC_ID_WEBP,
|
||||
.capabilities = AV_CODEC_CAP_DR1,
|
||||
.priv_data_size = sizeof(LibWebPContext),
|
||||
.init = libwebp_encode_init,
|
||||
.encode2 = libwebp_encode_frame,
|
||||
|
Loading…
Reference in New Issue
Block a user