FFmpeg  4.0
libwebpenc_common.h
Go to the documentation of this file.
1 /*
2  * WebP encoding support via libwebp
3  * Copyright (c) 2013 Justin Ruggles <justin.ruggles@gmail.com>
4  *
5  * This file is part of FFmpeg.
6  *
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.
11  *
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.
16  *
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
20  */
21 
22 /**
23  * @file
24  * WebP encoder using libwebp: common structs and methods.
25  */
26 
27 #ifndef AVCODEC_LIBWEBPENC_COMMON_H
28 #define AVCODEC_LIBWEBPENC_COMMON_H
29 
30 #include <webp/encode.h>
31 
32 #include "libavutil/common.h"
33 #include "libavutil/frame.h"
34 #include "libavutil/imgutils.h"
35 #include "libavutil/opt.h"
36 #include "avcodec.h"
37 #include "internal.h"
38 
39 typedef struct LibWebPContextCommon {
40  AVClass *class; // class for AVOptions
41  float quality; // lossy quality 0 - 100
42  int lossless; // use lossless encoding
43  int preset; // configuration preset
44  int chroma_warning; // chroma linesize mismatch warning has been printed
45  int conversion_warning; // pixel format conversion warning has been printed
46  WebPConfig config; // libwebp configuration
48  int cr_size;
51 
52 int ff_libwebp_error_to_averror(int err);
53 
55 
57  const AVFrame *frame, AVFrame **alt_frame_ptr,
58  WebPPicture **pic_ptr);
59 
60 #define OFFSET(x) offsetof(LibWebPContextCommon, x)
61 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
62 static const AVOption options[] = {
63  { "lossless", "Use lossless mode", OFFSET(lossless), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
64  { "preset", "Configuration preset", OFFSET(preset), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, WEBP_PRESET_TEXT, VE, "preset" },
65  { "none", "do not use a preset", 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, 0, 0, VE, "preset" },
66  { "default", "default preset", 0, AV_OPT_TYPE_CONST, { .i64 = WEBP_PRESET_DEFAULT }, 0, 0, VE, "preset" },
67  { "picture", "digital picture, like portrait, inner shot", 0, AV_OPT_TYPE_CONST, { .i64 = WEBP_PRESET_PICTURE }, 0, 0, VE, "preset" },
68  { "photo", "outdoor photograph, with natural lighting", 0, AV_OPT_TYPE_CONST, { .i64 = WEBP_PRESET_PHOTO }, 0, 0, VE, "preset" },
69  { "drawing", "hand or line drawing, with high-contrast details", 0, AV_OPT_TYPE_CONST, { .i64 = WEBP_PRESET_DRAWING }, 0, 0, VE, "preset" },
70  { "icon", "small-sized colorful images", 0, AV_OPT_TYPE_CONST, { .i64 = WEBP_PRESET_ICON }, 0, 0, VE, "preset" },
71  { "text", "text-like", 0, AV_OPT_TYPE_CONST, { .i64 = WEBP_PRESET_TEXT }, 0, 0, VE, "preset" },
72  { "cr_threshold","Conditional replenishment threshold", OFFSET(cr_threshold), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
73  { "cr_size" ,"Conditional replenishment block size", OFFSET(cr_size) , AV_OPT_TYPE_INT, { .i64 = 16 }, 0, 256, VE },
74  { "quality" ,"Quality", OFFSET(quality), AV_OPT_TYPE_FLOAT, { .dbl = 75 }, 0, 100, VE },
75  { NULL },
76 };
77 
78 static const AVCodecDefault libwebp_defaults[] = {
79  { "compression_level", "4" },
80  { "global_quality", "-1" },
81  { NULL },
82 };
83 
84 #endif /* AVCODEC_LIBWEBPENC_COMMON_H */
#define NULL
Definition: coverity.c:32
const char * s
Definition: avisynth_c.h:768
This structure describes decoded (raw) audio or video data.
Definition: frame.h:218
AVOption.
Definition: opt.h:246
misc image utilities
#define VE
#define av_cold
Definition: attributes.h:82
AVOptions.
static AVFrame * frame
int ff_libwebp_error_to_averror(int err)
int ff_libwebp_get_frame(AVCodecContext *avctx, LibWebPContextCommon *s, const AVFrame *frame, AVFrame **alt_frame_ptr, WebPPicture **pic_ptr)
reference-counted frame API
#define OFFSET(x)
static const AVCodecDefault libwebp_defaults[]
Libavcodec external API header.
main external API structure.
Definition: avcodec.h:1518
Describe the class of an AVClass context structure.
Definition: log.h:67
static const AVOption options[]
preset
Definition: vf_curves.c:46
common internal api header.
common internal and external API header
av_cold int ff_libwebp_encode_init_common(AVCodecContext *avctx)