32 case VP8_ENC_ERROR_OUT_OF_MEMORY:
33 case VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY:
35 case VP8_ENC_ERROR_NULL_PARAMETER:
36 case VP8_ENC_ERROR_INVALID_CONFIGURATION:
37 case VP8_ENC_ERROR_BAD_DIMENSION:
58 if (
s->preset >= WEBP_PRESET_DEFAULT) {
59 ret = WebPConfigPreset(&
s->config,
s->preset,
s->quality);
62 s->lossless =
s->config.lossless;
63 s->quality =
s->config.quality;
66 ret = WebPConfigInit(&
s->config);
70 s->config.lossless =
s->lossless;
71 s->config.quality =
s->quality;
74 ret = WebPValidateConfig(&
s->config);
80 s->lossless ?
"Lossless" :
"Lossy",
s->quality,
88 WebPPicture **pic_ptr) {
90 WebPPicture *pic =
NULL;
93 if (avctx->
width > WEBP_MAX_DIMENSION || avctx->
height > WEBP_MAX_DIMENSION) {
95 WEBP_MAX_DIMENSION, WEBP_MAX_DIMENSION);
104 ret = WebPPictureInit(pic);
109 pic->width = avctx->
width;
110 pic->height = avctx->
height;
116 if (!
s->conversion_warning) {
118 "Using libwebp for RGB-to-YUV conversion. You may want "
119 "to consider passing in YUV instead for lossy "
121 s->conversion_warning = 1;
129 if (!
s->chroma_warning && !
s->cr_threshold) {
131 "Copying frame due to differing chroma linesizes.\n");
132 s->chroma_warning = 1;
135 alt_frame = *alt_frame_ptr;
151 if (
s->cr_threshold) {
168 for (p = 0; p < 3; p++) {
174 for (y2 = ys; y2 <
FFMIN(ys + bs2,
h); y2++) {
175 for (x2 =
xs; x2 <
FFMIN(
xs + bs2,
w); x2++) {
182 skip =
sse <
s->cr_threshold &&
frame->
data[3] !=
s->ref->data[3];
184 for (p = 0; p < 3; p++) {
190 for (y2 = ys; y2 <
FFMIN(ys + bs2,
h); y2++) {
212 pic->colorspace = WEBP_YUV420A;
216 WebPCleanupTransparentArea(pic);
218 pic->colorspace = WEBP_YUV420;
226 if (!
s->conversion_warning) {
228 "Using libwebp for YUV-to-RGB conversion. You may want "
229 "to consider passing in RGB instead for lossless "
231 s->conversion_warning = 1;
234 #if (WEBP_ENCODER_ABI_VERSION <= 0x201)
239 pic->memory_ = (
void*)1;
240 ret = WebPPictureYUVAToARGB(pic);
243 "WebPPictureYUVAToARGB() failed with error: %d\n",
245 ret = libwebp_error_to_averror(pic->error_code);
#define xs(width, name, var, subs,...)
#define AV_CEIL_RSHIFT(a, b)
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int ff_libwebp_get_frame(AVCodecContext *avctx, LibWebPContextCommon *s, const AVFrame *frame, AVFrame **alt_frame_ptr, WebPPicture **pic_ptr)
av_cold int ff_libwebp_encode_init_common(AVCodecContext *avctx)
int ff_libwebp_error_to_averror(int err)
WebP encoder using libwebp: common structs and methods.
static int sse(MpegEncContext *s, uint8_t *src1, uint8_t *src2, int w, int h, int stride)
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
int global_quality
Global quality for codecs which cannot change it per frame.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
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 uint32_t a, const uint32_t b)