You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avcodec/libwebpenc_animencoder: 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:
@@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "encode.h"
|
||||||
#include "libwebpenc_common.h"
|
#include "libwebpenc_common.h"
|
||||||
|
|
||||||
#include <webp/mux.h>
|
#include <webp/mux.h>
|
||||||
@@ -67,7 +68,7 @@ static int libwebp_anim_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
|||||||
WebPData assembled_data = { 0 };
|
WebPData assembled_data = { 0 };
|
||||||
ret = WebPAnimEncoderAssemble(s->enc, &assembled_data);
|
ret = WebPAnimEncoderAssemble(s->enc, &assembled_data);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ret = ff_alloc_packet2(avctx, pkt, assembled_data.size, assembled_data.size);
|
ret = ff_get_encode_buffer(avctx, pkt, assembled_data.size, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
memcpy(pkt->data, assembled_data.bytes, assembled_data.size);
|
memcpy(pkt->data, assembled_data.bytes, assembled_data.size);
|
||||||
@@ -136,11 +137,11 @@ const AVCodec ff_libwebp_anim_encoder = {
|
|||||||
.long_name = NULL_IF_CONFIG_SMALL("libwebp WebP image"),
|
.long_name = NULL_IF_CONFIG_SMALL("libwebp WebP image"),
|
||||||
.type = AVMEDIA_TYPE_VIDEO,
|
.type = AVMEDIA_TYPE_VIDEO,
|
||||||
.id = AV_CODEC_ID_WEBP,
|
.id = AV_CODEC_ID_WEBP,
|
||||||
|
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
|
||||||
.priv_data_size = sizeof(LibWebPAnimContext),
|
.priv_data_size = sizeof(LibWebPAnimContext),
|
||||||
.init = libwebp_anim_encode_init,
|
.init = libwebp_anim_encode_init,
|
||||||
.encode2 = libwebp_anim_encode_frame,
|
.encode2 = libwebp_anim_encode_frame,
|
||||||
.close = libwebp_anim_encode_close,
|
.close = libwebp_anim_encode_close,
|
||||||
.capabilities = AV_CODEC_CAP_DELAY,
|
|
||||||
.pix_fmts = (const enum AVPixelFormat[]) {
|
.pix_fmts = (const enum AVPixelFormat[]) {
|
||||||
AV_PIX_FMT_RGB32,
|
AV_PIX_FMT_RGB32,
|
||||||
AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P,
|
AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P,
|
||||||
|
Reference in New Issue
Block a user