Go to the documentation of this file.
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;
125 pic->argb = (uint32_t *)
frame->data[0];
126 pic->argb_stride =
frame->linesize[0] / 4;
128 if (
frame->linesize[1] !=
frame->linesize[2] ||
s->cr_threshold) {
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) {
164 for (y = 0; y <
frame->height; y+= bs) {
165 for (x = 0; x <
frame->width; x+= bs) {
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++) {
177 -
s->ref->data[p][
frame->linesize[p] * y2 + 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++) {
191 memcpy(&
s->ref->data[p][
frame->linesize[p] * y2 +
xs],
195 for (y2 = y; y2 <
FFMIN(y+bs,
frame->height); y2++) {
196 memset(&
frame->data[3][
frame->linesize[3] * y2 + x],
206 pic->y =
frame->data[0];
207 pic->u =
frame->data[1];
208 pic->v =
frame->data[2];
209 pic->y_stride =
frame->linesize[0];
210 pic->uv_stride =
frame->linesize[1];
212 pic->colorspace = WEBP_YUV420A;
213 pic->a =
frame->data[3];
214 pic->a_stride =
frame->linesize[3];
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 AV_LOG_WARNING
Something somehow does not look correct.
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)
static av_cold int end(AVCodecContext *avctx)
This structure describes decoded (raw) audio or video data.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
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)
static int sse(MpegEncContext *s, uint8_t *src1, uint8_t *src2, int w, int h, int stride)
#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.
#define xs(width, name, var, subs,...)
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,...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
main external API structure.
int ff_libwebp_get_frame(AVCodecContext *avctx, LibWebPContextCommon *s, const AVFrame *frame, AVFrame **alt_frame_ptr, WebPPicture **pic_ptr)
static av_always_inline int diff(const uint32_t a, const uint32_t b)
int width
picture width / height.
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda