2 * WebP encoding support via libwebp
3 * Copyright (c) 2013 Justin Ruggles <justin.ruggles@gmail.com>
5 * This file is part of FFmpeg.
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 * WebP encoder using libwebp (WebPEncode API)
43 WebPPicture *pic =
NULL;
45 WebPMemoryWriter mw = { 0 };
51 WebPMemoryWriterInit(&mw);
52 pic->custom_ptr = &mw;
53 pic->writer = WebPMemoryWrite;
55 ret = WebPEncode(&
s->config, pic);
66 memcpy(
pkt->data, mw.mem, mw.size);
71#if (WEBP_ENCODER_ABI_VERSION > 0x0203)
72 WebPMemoryWriterClear(&mw);
74 free(mw.mem);
/* must use free() according to libwebp documentation */
100 .p.wrapper_name =
"libwebp",
const FFCodec ff_libwebp_encoder
static const FFCodecDefault defaults[]
#define CODEC_PIXFMTS_ARRAY(array)
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
#define FF_CODEC_ENCODE_CB(func)
#define CODEC_LONG_NAME(str)
int(* init)(AVBSFContext *ctx)
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
LibWebPContextCommon LibWebPContext
static int libwebp_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
static int libwebp_encode_close(AVCodecContext *avctx)
static av_cold int libwebp_encode_init(AVCodecContext *avctx)
int ff_libwebp_get_frame(AVCodecContext *avctx, LibWebPContextCommon *s, const AVFrame *frame, AVFrame **alt_frame_ptr, WebPPicture **pic_ptr)
const AVClass ff_libwebpenc_class
enum AVPixelFormat ff_libwebpenc_pix_fmts[]
av_cold int ff_libwebp_encode_init_common(AVCodecContext *avctx)
int ff_libwebp_error_to_averror(int err)
const FFCodecDefault ff_libwebp_defaults[]
WebP encoder using libwebp: common structs and methods.
Memory handling functions.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
main external API structure.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.