Go to the documentation of this file.
31 {
"compression_level",
"4" },
32 {
"global_quality",
"-1" },
36 #define OFFSET(x) offsetof(LibWebPContextCommon, x)
37 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
41 {
"none",
"do not use a preset", 0,
AV_OPT_TYPE_CONST, { .i64 = -1 }, 0, 0,
VE, .unit =
"preset" },
42 {
"default",
"default preset", 0,
AV_OPT_TYPE_CONST, { .i64 = WEBP_PRESET_DEFAULT }, 0, 0,
VE, .unit =
"preset" },
43 {
"picture",
"digital picture, like portrait, inner shot", 0,
AV_OPT_TYPE_CONST, { .i64 = WEBP_PRESET_PICTURE }, 0, 0,
VE, .unit =
"preset" },
44 {
"photo",
"outdoor photograph, with natural lighting", 0,
AV_OPT_TYPE_CONST, { .i64 = WEBP_PRESET_PHOTO }, 0, 0,
VE, .unit =
"preset" },
45 {
"drawing",
"hand or line drawing, with high-contrast details", 0,
AV_OPT_TYPE_CONST, { .i64 = WEBP_PRESET_DRAWING }, 0, 0,
VE, .unit =
"preset" },
46 {
"icon",
"small-sized colorful images", 0,
AV_OPT_TYPE_CONST, { .i64 = WEBP_PRESET_ICON }, 0, 0,
VE, .unit =
"preset" },
47 {
"text",
"text-like", 0,
AV_OPT_TYPE_CONST, { .i64 = WEBP_PRESET_TEXT }, 0, 0,
VE, .unit =
"preset" },
48 {
"cr_threshold",
"Conditional replenishment threshold",
OFFSET(cr_threshold),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX,
VE },
49 {
"cr_size" ,
"Conditional replenishment block size",
OFFSET(cr_size) ,
AV_OPT_TYPE_INT, { .i64 = 16 }, 0, 256,
VE },
70 case VP8_ENC_ERROR_OUT_OF_MEMORY:
71 case VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY:
73 case VP8_ENC_ERROR_NULL_PARAMETER:
74 case VP8_ENC_ERROR_INVALID_CONFIGURATION:
75 case VP8_ENC_ERROR_BAD_DIMENSION:
96 if (
s->preset >= WEBP_PRESET_DEFAULT) {
97 ret = WebPConfigPreset(&
s->config,
s->preset,
s->quality);
100 s->lossless =
s->config.lossless;
101 s->quality =
s->config.quality;
104 ret = WebPConfigInit(&
s->config);
108 s->config.lossless =
s->lossless;
109 s->config.quality =
s->quality;
112 ret = WebPValidateConfig(&
s->config);
118 s->lossless ?
"Lossless" :
"Lossy",
s->quality,
126 WebPPicture **pic_ptr) {
128 WebPPicture *pic =
NULL;
131 if (avctx->
width > WEBP_MAX_DIMENSION || avctx->
height > WEBP_MAX_DIMENSION) {
133 WEBP_MAX_DIMENSION, WEBP_MAX_DIMENSION);
142 ret = WebPPictureInit(pic);
147 pic->width = avctx->
width;
148 pic->height = avctx->
height;
154 if (!
s->conversion_warning) {
156 "Using libwebp for RGB-to-YUV conversion. You may want "
157 "to consider passing in YUV instead for lossy "
159 s->conversion_warning = 1;
167 if (!
s->chroma_warning && !
s->cr_threshold) {
169 "Copying frame due to differing chroma linesizes.\n");
170 s->chroma_warning = 1;
173 alt_frame = *alt_frame_ptr;
189 if (
s->cr_threshold) {
206 for (p = 0; p < 3; p++) {
212 for (y2 = ys; y2 <
FFMIN(ys + bs2,
h); y2++) {
213 for (x2 =
xs; x2 <
FFMIN(
xs + bs2,
w); x2++) {
222 for (p = 0; p < 3; p++) {
228 for (y2 = ys; y2 <
FFMIN(ys + bs2,
h); y2++) {
250 pic->colorspace = WEBP_YUV420A;
254 WebPCleanupTransparentArea(pic);
256 pic->colorspace = WEBP_YUV420;
264 if (!
s->conversion_warning) {
266 "Using libwebp for YUV-to-RGB conversion. You may want "
267 "to consider passing in RGB instead for lossless "
269 s->conversion_warning = 1;
272 #if (WEBP_ENCODER_ABI_VERSION <= 0x201)
277 pic->memory_ = (
void*)1;
278 ret = WebPPictureYUVAToARGB(pic);
281 "WebPPictureYUVAToARGB() failed with error: %d\n",
283 ret = libwebp_error_to_averror(pic->error_code);
#define AV_LOG_WARNING
Something somehow does not look correct.
AVPixelFormat
Pixel format.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int ff_libwebp_error_to_averror(int err)
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
av_cold int ff_libwebp_encode_init_common(AVCodecContext *avctx)
This structure describes decoded (raw) audio or video data.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about quality
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int global_quality
Global quality for codecs which cannot change it per frame.
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
#define AV_CEIL_RSHIFT(a, b)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define LIBAVUTIL_VERSION_INT
#define xs(width, name, var, subs,...)
Describe the class of an AVClass context structure.
const FFCodecDefault ff_libwebp_defaults[]
const char * av_default_item_name(void *ptr)
Return the context name.
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
main external API structure.
int ff_libwebp_get_frame(AVCodecContext *avctx, LibWebPContextCommon *s, const AVFrame *frame, AVFrame **alt_frame_ptr, WebPPicture **pic_ptr)
static const AVOption options[]
enum AVPixelFormat ff_libwebpenc_pix_fmts[]
int width
picture width / height.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
static int sse(MpegEncContext *s, const uint8_t *src1, const uint8_t *src2, int w, int h, int stride)
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
static void BS_FUNC() skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
const AVClass ff_libwebpenc_class