Skip to content

Commit

Permalink
0.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-huet committed Dec 11, 2014
1 parent 0f4bd5b commit 40b937f
Show file tree
Hide file tree
Showing 24 changed files with 837 additions and 246 deletions.
10 changes: 10 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
version 0.9.2:

- Fixed encoding of paletted PNG.
- Reduced memory usage in the decoder.
- Added faster 8 bit only Javascript decoder.
- bpgenc: added '-e' option to explicitely select the encoder.
- bpgenc: set default bit depth to 8.
- bpgenc: added lossless support with x265.
- js decoder: handle width and height attributes.

version 0.9.1:

- Added new meta data tags: ICC profile, XMP and thumbnail.
Expand Down
35 changes: 23 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ EMCC=emcc

PWD:=$(shell pwd)

CFLAGS:=-Os -Wall -MMD -fno-asynchronous-unwind-tables -fdata-sections -ffunction-sections
CFLAGS+=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
CFLAGS:=-Os -Wall -MMD -fno-asynchronous-unwind-tables -fdata-sections -ffunction-sections -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -fomit-frame-pointer
CFLAGS+=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_REENTRANT
CFLAGS+=-I.
CFLAGS+=-DCONFIG_BPG_VERSION=\"$(shell cat VERSION)\"
ifdef USE_JCTVC_HIGH_BIT_DEPTH
Expand All @@ -46,7 +46,7 @@ endif

# Emscriptem config
EMLDFLAGS:=-s "EXPORTED_FUNCTIONS=['_bpg_decoder_open','_bpg_decoder_decode','_bpg_decoder_get_info','_bpg_decoder_start','_bpg_decoder_get_line','_bpg_decoder_close','_malloc','_free']"
EMLDFLAGS+=-s NO_FILESYSTEM=1 -s NO_BROWSER=1 -s TOTAL_MEMORY=33554432
EMLDFLAGS+=-s NO_FILESYSTEM=1 -s NO_BROWSER=1
#EMLDFLAGS+=-O1 --post-js post.js
EMLDFLAGS+=-O3 --memory-init-file 0 --closure 1 --post-js post.js
EMCFLAGS:=$(CFLAGS)
Expand All @@ -62,22 +62,27 @@ CXXFLAGS=$(CFLAGS)

PROGS=bpgdec$(EXE) bpgenc$(EXE)
ifdef USE_EMCC
PROGS+=bpgdec.js
PROGS+=bpgdec.js bpgdec8b.js
endif

all: $(PROGS)

FFMPEG_OBJS:=$(addprefix libavcodec/, \
LIBBPG_OBJS:=$(addprefix libavcodec/, \
hevc_cabac.o hevc_filter.o hevc.o hevcpred.o hevc_refs.o\
hevcdsp.o hevc_mvs.o hevc_ps.o hevc_sei.o\
utils.o cabac.o )
FFMPEG_OBJS+=$(addprefix libavutil/, mem.o buffer.o log2_tab.o frame.o pixdesc.o md5.o )
LIBBPG_OBJS+=$(addprefix libavutil/, mem.o buffer.o log2_tab.o frame.o pixdesc.o md5.o )
LIBBPG_OBJS+=libbpg.o

FFMPEG_JSOBJS:=$(patsubst %.o, %.js.o, $(FFMPEG_OBJS))
LIBBPG_JS_OBJS:=$(patsubst %.o, %.js.o, $(LIBBPG_OBJS))

$(FFMPEG_OBJS) libbpg.o: CFLAGS+=-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DHAVE_AV_CONFIG_H -std=c99 -fomit-frame-pointer -D_GNU_SOURCE=1 -D_REENTRANT -Wdeclaration-after-statement -Wall -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wno-pointer-to-int-cast -Wstrict-prototypes -Wempty-body -Wno-parentheses -Wno-switch -Wno-format-zero-length -Wno-pointer-sign -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=format-security -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=return-type -Werror=vla -Wformat -Wno-maybe-uninitialized
LIBBPG_JS8_OBJS:=$(patsubst %.o, %.js8.o, $(LIBBPG_OBJS))

$(FFMPEG_JSOBJS) libbpg.js.o: EMCFLAGS+=-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DHAVE_AV_CONFIG_H -std=c99 -fomit-frame-pointer -D_GNU_SOURCE=1 -D_REENTRANT -Wdeclaration-after-statement -Wall -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wno-pointer-to-int-cast -Wstrict-prototypes -Wempty-body -Wno-parentheses -Wno-switch -Wno-format-zero-length -Wno-pointer-sign -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=format-security -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=return-type -Werror=vla -Wformat
$(LIBBPG_OBJS): CFLAGS+=-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DHAVE_AV_CONFIG_H -std=c99 -D_GNU_SOURCE=1 -DUSE_VAR_BIT_DEPTH

$(LIBBPG_JS_OBJS): EMCFLAGS+=-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DHAVE_AV_CONFIG_H -std=c99 -D_GNU_SOURCE=1 -DUSE_VAR_BIT_DEPTH

$(LIBBPG_JS8_OBJS): EMCFLAGS+=-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DHAVE_AV_CONFIG_H -std=c99 -D_GNU_SOURCE=1

BPGENC_OBJS:=bpgenc.o
BPGENC_LIBS:=
Expand Down Expand Up @@ -132,7 +137,7 @@ BPGENC_LIBS+=-lpng -ljpeg $(LIBS)

bpgenc.o: CFLAGS+=-Wno-unused-but-set-variable

libbpg.a: libbpg.o $(FFMPEG_OBJS)
libbpg.a: $(LIBBPG_OBJS)
$(AR) rcs $@ $^

bpgdec$(EXE): bpgdec.o libbpg.a
Expand All @@ -141,8 +146,11 @@ bpgdec$(EXE): bpgdec.o libbpg.a
bpgenc$(EXE): $(BPGENC_OBJS)
$(CXX) $(LDFLAGS) -o $@ $^ $(BPGENC_LIBS)

bpgdec.js: libbpg.js.o $(FFMPEG_JSOBJS) post.js
$(EMCC) $(EMLDFLAGS) -o $@ libbpg.js.o $(FFMPEG_JSOBJS)
bpgdec.js: $(LIBBPG_JS_OBJS) post.js
$(EMCC) $(EMLDFLAGS) -s TOTAL_MEMORY=33554432 -o $@ $(LIBBPG_JS_OBJS)

bpgdec8b.js: $(LIBBPG_JS8_OBJS) post.js
$(EMCC) $(EMLDFLAGS) -s TOTAL_MEMORY=16777216 -o $@ $(LIBBPG_JS8_OBJS)

size:
strip bpgdec
Expand All @@ -169,6 +177,9 @@ clean:
%.js.o: %.c
$(EMCC) $(EMCFLAGS) -c -o $@ $<

%.js8.o: %.c
$(EMCC) $(EMCFLAGS) -c -o $@ $<

-include $(wildcard *.d)
-include $(wildcard libavcodec/*.d)
-include $(wildcard libavutil/*.d)
Expand Down
131 changes: 90 additions & 41 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,52 @@ BPG Image Encoder and Decoder

- x265 usage: for much increased compression speed (but lower
quality), you can compile and install x265 and then enable its use
in the Makefile. x265 is used when the compression level ('-m'
option of bpgenc) is < 9. Unfortunately, x265 does not support yet
the monochrome format or the lossless mode, so the JCTVC code is
still required in these cases. With a default x265 compilation, only
8 bit depth is supported (hence you must force a bit depth of 8 with
'-b 8').
in the Makefile. x265 supports by default only 8 bits per component
and does not support monochrome encoding yet (hence no alpha nor
grayscale images can be encoded with it).

- Emscripten usage: in order to generate the Javascript decoder, you
must install Emscripten and enable its use in the Makefile.

- An HTML demonstration (with a precompiled Javascript decoder) is
available in html/index.html. The Javascript decoder has a hardcoded
maximum memory usage of 32MB, which is enough for 1920x1080
pictures. You can modify it in the Makefile to optimize it for your
needs.
available in html/index.html (if you use Chrome and want to use
file:// to access it, launch Chrome with the option
--allow-file-access-from-files).

- The BPG file format is specified in doc/bpg_spec.txt.

2) BPG encoding tips
--------------------
2) BPG encoder
--------------

- bpgenc is slow because it uses by default the reference HEVC
encoder. It can also use x265 but currently x265 does not support
all the features (in particular the monochrome mode) and gives a
lower quality. It is expected that x265 (or another HEVC encoder)
will become quickly better.
The BPG command line encoder is 'bpgenc'. It takes JPEG or PNG images
as input.

- A bit depth of 10 is used by default in order to slightly increase
the compression ratio (rounding errors are reduced). You can still
force the wanted bit depth with the '-b' option.
- Speed: by default bpgenc uses the JCTVC encoder which has a high
quality but is slow. If you compiled with x265, you can have a much
faster encoding with the '-e x265' option. With x265 you can also
select the encoding speed with the '-m' option (1 = fast, but larger
image, 9 = slower but smaller image). Warning: x265 does not support
monochrome (and alpha) yet, so you must use the JCTVC encoder for
these cases.

- Bit depth: the default bit depth is 8. You can increase it to 10
('-b 10' option) to slightly increase the compression ratio. For web
publishing it is generally not a good idea because the Javascript
decoder uses more memory.

- Lossless compression is supported as a bonus thru the HEVC lossless
capabilities. Use a PNG input in this case unless you know what you
do ! In case of a JPEG input, the compression is lossless related to
the JPEG YCbCr data, not the RGB data. In any case, the bit depth
should match the one of your picture otherwise the file size
increases a lot. By default the lossless mode sets the bit depth to
8 bits. The prefered color space is set to "rgb". Note: lossless
mode is less tested that the lossy mode but it usually gives better
results that PNG on photographic images.
8 bits. The prefered color space is set to "rgb". Notes:

- lossless mode is less tested that the lossy mode but it usually
gives better results that PNG on photographic images.

- the JCTVC encoder gives smaller images than the x265 encoder
with lossless compression.

- There is a difference of interpretation of the quantizer parameter
(-q option) between the x265 and JCTVC encoder. The default value is
Expand All @@ -69,24 +75,69 @@ BPG Image Encoder and Decoder
option). Images with vertically subsampled chroma are currently
not supported.

* For PNG input, grayscale images are not modified. For RGB
images, the input image is converted to the preferred color
space ('-c' option). Its chroma is then subsampled according to
the preferred chroma format.
* For PNG input, the input image is converted to the preferred
color space ('-c' option). Its chroma is then subsampled
according to the preferred chroma format.

* grayscale images are kept unmodified.

- By default, bpgenc does not copy the metadata. You can copy them
with the '-keepmetadata' option. For JPEG input, EXIF, ICCP and XMP
are copied. For PNG input, ICCP is copied.

3) FFmpeg modifications
3) BPG decoder
--------------

The BPG command line decoder is bpgdec. It outputs a PNG or PPM
image. Use a PPM output to get the fastest speed.

- With the '-i' option, you have information about the BPG image (and
no decoded image is output).

- The '-b' option selects the bit depth (8 or 16) of the PNG
output. It is independent of the internal BPG bit depth.

4) BPG decoding library
-----------------------

BPG images can be decoded in any program with the libbpg
library.

The API is not considered stable yet so that the library is only
provided as a static one.

Currently there is no similar library for encoding so you should
invoke the bpgenc utility.

5) Javascript decoder
---------------------

bpgdec.js is a Javascript decoder supporting the BPG file
format. bpgdec8b.js is a specialized version limited to BPG images
using 8 bits per component. It is a little faster and consumes less
memory (16 MB instead of 32 MB by default, you can change the memory
configuration in the Makefile if you want to handle larger images).

The Javascript decoder substitutes all the <img> tags with a source
having a .bpg extension with a <canvas> tag and decodes the BPG image
into it. Stylesheets are supported (the 'id' and 'class' attributes
are preserved). The 'width' and 'height' attributes are supported only
with pixel units.

asm.js gives an interesting speed boost, so we hope that more browser
will support this Javascript subset.

6) FFmpeg modifications
-----------------------

- Completed support of chroma_format_idc = 0 (monochrome mode).

- Fixed RDPCM support (intra predictions).

- Reduced memory usage for the SAO loop filter.

- Generated the IDCT coefficients dynamically to reduce the code size.

- Added a 'dynamic bit depth' mode where all the bit depths from 8 to
14 are supported without code duplication but slower decoding.

Expand All @@ -100,20 +151,18 @@ BPG Image Encoder and Decoder
- Stripped FFmpeg from all codecs except HEVC and the necessary
support code.

- Generated the IDCT coefficients dynamically to reduce the code size.

4) Licensing
7) Licensing
------------

- libbpg and bpgenc are released under the LGPL license (the FFmpeg
part is under the LGPL, the BPG specific part is released under
the BSD license).
- libbpg and bpgenc are released under the LGPL license (the FFmpeg
part is under the LGPL, the BPG specific part is released under the
BSD license).

- bpgenc is released under the BSD license (it includes the JCTVC
code which is released under the BSD license. The BPG specific
part is released under the BSD license).
- bpgenc is released under the BSD license (it includes the JCTVC code
which is released under the BSD license. The BPG specific part is
released under the BSD license).

- BPG relies on the HEVC compression technology which may be
protected by patents in some countries. Most devices already
include or will include hardware HEVC support, so we suggest to
use it if patents are an issue.
- BPG relies on the HEVC compression technology which may be protected
by patents in some countries. Most devices already include or will
include hardware HEVC support, so we suggest to use it if patents
are an issue.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.1
0.9.2
Loading

0 comments on commit 40b937f

Please sign in to comment.