Skip to content

Commit

Permalink
Add a libwebp encoder
Browse files Browse the repository at this point in the history
  • Loading branch information
justinruggles committed Dec 21, 2013
1 parent d307e40 commit be7c323
Show file tree
Hide file tree
Showing 9 changed files with 359 additions and 4 deletions.
1 change: 1 addition & 0 deletions Changelog
Expand Up @@ -52,6 +52,7 @@ version 10:
- remove mp3_header_(de)compress bitstream filters
- stereoscopic 3d metadata handling
- png standalone parser
- WebP encoding via libwebp


version 9:
Expand Down
4 changes: 4 additions & 0 deletions configure
Expand Up @@ -202,6 +202,7 @@ External library support:
--enable-libvorbis enable Vorbis encoding via libvorbis [no]
--enable-libvpx enable VP8 and VP9 de/encoding via libvpx [no]
--enable-libwavpack enable wavpack encoding via libwavpack [no]
--enable-libwebp enable WebP encoding via libwebp [no]
--enable-libx264 enable H.264 encoding via x264 [no]
--enable-libxavs enable AVS encoding via xavs [no]
--enable-libxvid enable Xvid encoding via xvidcore,
Expand Down Expand Up @@ -1116,6 +1117,7 @@ EXTERNAL_LIBRARY_LIST="
libvorbis
libvpx
libwavpack
libwebp
libx264
libxavs
libxvid
Expand Down Expand Up @@ -1867,6 +1869,7 @@ libvpx_vp8_encoder_deps="libvpx"
libvpx_vp9_decoder_deps="libvpx"
libvpx_vp9_encoder_deps="libvpx"
libwavpack_encoder_deps="libwavpack"
libwebp_encoder_deps="libwebp"
libx264_encoder_deps="libx264"
libxavs_encoder_deps="libxavs"
libxvid_encoder_deps="libxvid"
Expand Down Expand Up @@ -3926,6 +3929,7 @@ enabled libvpx && {
enabled libvpx_vp9_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_vp9_dx" -lvpx || disable libvpx_vp9_decoder; }
enabled libvpx_vp9_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx" -lvpx || disable libvpx_vp9_encoder; } }
enabled libwavpack && require libwavpack wavpack/wavpack.h WavpackOpenFileOutput -lwavpack
enabled libwebp && require_pkg_config libwebp webp/encode.h WebPGetEncoderVersion
enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 &&
{ check_cpp_condition x264.h "X264_BUILD >= 118" ||
die "ERROR: libx264 version must be >= 0.118."; }
Expand Down
61 changes: 61 additions & 0 deletions doc/encoders.texi
Expand Up @@ -446,6 +446,67 @@ Same as 3, but with extra processing enabled - corresponding to the wavpack
@chapter Video Encoders
@c man begin VIDEO ENCODERS

@section libwebp

libwebp WebP Image encoder wrapper

libwebp is Google's official encoder for WebP images. It can encode in either
lossy or lossless mode. Lossy images are essentially a wrapper around a VP8
frame. Lossless images are a separate codec developed by Google.

@subsection Pixel Format

Currently, libwebp only supports YUV420 for lossy and RGB for lossless due
to limitations of the format and libwebp. Alpha is supported for either mode.
Because of API limitations, if RGB is passed in when encoding lossy or YUV is
passed in for encoding lossless, the pixel format will automatically be
converted using functions from libwebp. This is not ideal and is done only for
convenience.

@subsection Options

@table @option

@item -lossless @var{boolean}
Enables/Disables use of lossless mode. Default is 0.

@item -compression_level @var{integer}
For lossy, this is a quality/speed tradeoff. Higher values give better quality
for a given size at the cost of increased encoding time. For lossless, this is
a size/speed tradeoff. Higher values give smaller size at the cost of increased
encoding time. More specifically, it controls the number of extra algorithms
and compression tools used, and varies the combination of these tools. This
maps to the @var{method} option in libwebp. The valid range is 0 to 6.
Default is 4.

@item -qscale @var{float}
For lossy encoding, this controls image quality, 0 to 100. For lossless
encoding, this controls the effort and time spent at compressing more. The
default value is 75. Note that for usage via libavcodec, this option is called
@var{global_quality} and must be multiplied by @var{FF_QP2LAMBDA}.

@item -preset @var{type}
Configuration preset. This does some automatic settings based on the general
type of the image.
@table @option
@item none
Do not use a preset.
@item default
Use the encoder default.
@item picture
Digital picture, like portrait, inner shot
@item photo
Outdoor photograph, with natural lighting
@item drawing
Hand or line drawing, with high-contrast details
@item icon
Small-sized colorful images
@item text
Text-like
@end table

@end table

@section libx264

x264 H.264/MPEG-4 AVC encoder wrapper
Expand Down
4 changes: 2 additions & 2 deletions doc/general.texi
Expand Up @@ -415,8 +415,8 @@ following image formats are supported:
@tab YUV, JPEG and some extension is not supported yet.
@item Truevision Targa @tab X @tab X
@tab Targa (.TGA) image format
@item WebP @tab @tab X
@tab WebP image format
@item WebP @tab E @tab X
@tab WebP image format, encoding supported through external library libwebp
@item XBM @tab X @tab
@tab X BitMap image format
@item XWD @tab X @tab X
Expand Down
1 change: 1 addition & 0 deletions libavcodec/Makefile
Expand Up @@ -612,6 +612,7 @@ OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o libvpx.o
OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o libvpx.o
OBJS-$(CONFIG_LIBWAVPACK_ENCODER) += libwavpackenc.o
OBJS-$(CONFIG_LIBWEBP_ENCODER) += libwebpenc.o
OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o
OBJS-$(CONFIG_LIBXAVS_ENCODER) += libxavs.o
OBJS-$(CONFIG_LIBXVID_ENCODER) += libxvid.o
Expand Down
1 change: 1 addition & 0 deletions libavcodec/allcodecs.c
Expand Up @@ -437,6 +437,7 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (LIBVPX_VP8, libvpx_vp8);
REGISTER_ENCDEC (LIBVPX_VP9, libvpx_vp9);
REGISTER_ENCODER(LIBWAVPACK, libwavpack);
REGISTER_ENCODER(LIBWEBP, libwebp);
REGISTER_ENCODER(LIBX264, libx264);
REGISTER_ENCODER(LIBXAVS, libxavs);
REGISTER_ENCODER(LIBXVID, libxvid);
Expand Down

0 comments on commit be7c323

Please sign in to comment.