forked from mirrorer/libbpg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5603437
Showing
263 changed files
with
106,824 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
# libbpg Makefile | ||
# | ||
# Compile options: | ||
# | ||
# Enable compilation of Javascript decoder with Emscripten | ||
#USE_EMCC=y | ||
# Enable x265 for the encoder (you must install it before) | ||
#USE_X265=y | ||
# Enable the JCTVC code (best quality but slow) for the encoder | ||
USE_JCTVC=y | ||
# Enable it to use bit depths > 12 (need more tests to validate encoder) | ||
#USE_JCTVC_HIGH_BIT_DEPTH=y | ||
# Enable the cross compilation for Windows | ||
#CONFIG_WIN32=y | ||
# Installation prefix | ||
prefix=/usr/local | ||
|
||
|
||
################################# | ||
|
||
ifdef CONFIG_WIN32 | ||
#CROSS_PREFIX:=x86_64-w64-mingw32- | ||
CROSS_PREFIX=i686-w64-mingw32- | ||
EXE:=.exe | ||
else | ||
CROSS_PREFIX:= | ||
EXE:= | ||
endif | ||
|
||
CC=$(CROSS_PREFIX)gcc | ||
CXX=$(CROSS_PREFIX)g++ | ||
AR=$(CROSS_PREFIX)ar | ||
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+=-I. | ||
CFLAGS+=-DCONFIG_BPG_VERSION=\"$(shell cat VERSION)\" | ||
ifdef USE_JCTVC_HIGH_BIT_DEPTH | ||
CFLAGS+=-DRExt__HIGH_BIT_DEPTH_SUPPORT | ||
endif | ||
|
||
# Emscriptem config | ||
EMLDFLAGS:=-s "EXPORTED_FUNCTIONS=['_bpg_decoder_open','_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+=-O1 --post-js post.js | ||
EMLDFLAGS+=-O3 --memory-init-file 0 --closure 1 --post-js post.js | ||
EMCFLAGS:=$(CFLAGS) | ||
|
||
LDFLAGS= -g -Wl,--gc-sections | ||
CFLAGS+=-g | ||
CXXFLAGS=$(CFLAGS) | ||
|
||
PROGS=bpgdec$(EXE) bpgenc$(EXE) | ||
ifdef USE_EMCC | ||
PROGS+=bpgdec.js | ||
endif | ||
|
||
all: $(PROGS) | ||
|
||
FFMPEG_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 ) | ||
|
||
FFMPEG_JSOBJS:=$(patsubst %.o, %.js.o, $(FFMPEG_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 | ||
|
||
$(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 | ||
|
||
BPGENC_OBJS:=bpgenc.o | ||
BPGENC_LIBS:= | ||
|
||
ifdef USE_X265 | ||
BPGENC_OBJS+=x265_glue.o | ||
BPGENC_LIBS+= -lx265 | ||
bpgenc.o: CFLAGS+=-DUSE_X265 | ||
endif # USE_X265 | ||
|
||
ifdef USE_JCTVC | ||
JCTVC_OBJS=$(addprefix jctvc/TLibEncoder/, SyntaxElementWriter.o TEncSbac.o \ | ||
TEncBinCoderCABACCounter.o TEncGOP.o\ | ||
TEncSampleAdaptiveOffset.o TEncBinCoderCABAC.o TEncAnalyze.o\ | ||
TEncEntropy.o TEncTop.o SEIwrite.o TEncPic.o TEncRateCtrl.o\ | ||
WeightPredAnalysis.o TEncSlice.o TEncCu.o NALwrite.o TEncCavlc.o\ | ||
TEncSearch.o TEncPreanalyzer.o) | ||
JCTVC_OBJS+=jctvc/TLibVideoIO/TVideoIOYuv.o | ||
JCTVC_OBJS+=$(addprefix jctvc/TLibCommon/, TComWeightPrediction.o TComLoopFilter.o\ | ||
TComBitStream.o TComMotionInfo.o TComSlice.o ContextModel3DBuffer.o\ | ||
TComPic.o TComRdCostWeightPrediction.o TComTU.o TComPicSym.o\ | ||
TComPicYuv.o TComYuv.o TComTrQuant.o TComInterpolationFilter.o\ | ||
ContextModel.o TComSampleAdaptiveOffset.o SEI.o TComPrediction.o\ | ||
TComDataCU.o TComChromaFormat.o Debug.o TComRom.o\ | ||
TComPicYuvMD5.o TComRdCost.o TComPattern.o TComCABACTables.o) | ||
JCTVC_OBJS+=jctvc/libmd5/libmd5.o | ||
JCTVC_OBJS+=jctvc/TAppEncCfg.o jctvc/TAppEncTop.o jctvc/program_options_lite.o | ||
|
||
$(JCTVC_OBJS) jctvc_glue.o: CFLAGS+=-I$(PWD)/jctvc -Wno-sign-compare | ||
|
||
jctvc/libjctvc.a: $(JCTVC_OBJS) | ||
$(AR) rcs $@ $^ | ||
|
||
BPGENC_OBJS+=jctvc_glue.o jctvc/libjctvc.a | ||
|
||
bpgenc.o: CFLAGS+=-DUSE_JCTVC | ||
endif # USE_JCTVC | ||
|
||
ifdef CONFIG_WIN32 | ||
LIBS:=-lz | ||
LDFLAGS+=-static | ||
else | ||
LIBS:=-lrt -lm -lpthread | ||
endif | ||
|
||
BPGENC_LIBS+=-lpng -ljpeg $(LIBS) | ||
|
||
bpgenc.o: CFLAGS+=-Wno-unused-but-set-variable | ||
|
||
libbpg.a: libbpg.o $(FFMPEG_OBJS) | ||
$(AR) rcs $@ $^ | ||
|
||
bpgdec$(EXE): bpgdec.o libbpg.a | ||
$(CC) $(LDFLAGS) -o $@ $^ -lpng $(LIBS) | ||
|
||
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) | ||
|
||
size: | ||
strip bpgdec | ||
size bpgdec libbpg.o libavcodec/*.o libavutil/*.o | sort -n | ||
gzip < bpgdec | wc | ||
|
||
install: bpgenc bpgdec | ||
install -s -m 755 $^ $(prefix)/bin | ||
|
||
CLEAN_DIRS=doc html libavcodec libavutil \ | ||
jctvc jctvc/TLibEncoder jctvc/TLibVideoIO jctvc/TLibCommon jctvc/libmd5 | ||
|
||
clean: | ||
rm -f $(PROGS) *.o *.a *.d *~ $(addsuffix /*.o, $(CLEAN_DIRS)) \ | ||
$(addsuffix /*.d, $(CLEAN_DIRS)) $(addsuffix /*~, $(CLEAN_DIRS)) \ | ||
$(addsuffix /*.a, $(CLEAN_DIRS)) | ||
|
||
%.o: %.c | ||
$(CC) $(CFLAGS) -c -o $@ $< | ||
|
||
%.o: %.cpp | ||
$(CXX) $(CXXFLAGS) -c -o $@ $< | ||
|
||
%.js.o: %.c | ||
$(EMCC) $(EMCFLAGS) -c -o $@ $< | ||
|
||
-include $(wildcard *.d) | ||
-include $(wildcard libavcodec/*.d) | ||
-include $(wildcard libavutil/*.d) | ||
-include $(wildcard jctvc/*.d) | ||
-include $(wildcard jctvc/TLibEncoder/*.d) | ||
-include $(wildcard jctvc/TLibVideoIO/*.d) | ||
-include $(wildcard jctvc/TLibCommon/*.d) | ||
-include $(wildcard jctvc/libmd5/*.d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
BPG Image Encoder and Decoder | ||
----------------------------- | ||
|
||
1) Quick introduction | ||
--------------------- | ||
|
||
- Edit the Makefile to change the compile options (the default compile | ||
options should be OK for Linux). Type 'make' to compile and 'make | ||
install' to install the compiled binaries. | ||
|
||
- 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'). | ||
|
||
- 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. | ||
|
||
- The BPG file format is specified in doc/bpg_spec.txt. | ||
|
||
2) BPG encoding tips | ||
-------------------- | ||
|
||
- 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. | ||
|
||
- 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. | ||
|
||
- 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. | ||
|
||
- There is a difference of interpreation of the quantizer parameter | ||
(-q option) between the x265 and JCTVC encoder. The default value is | ||
optimized for the JCTVC encoder, not for x265. We will try to align | ||
the x265 value to JCTVC in the future. | ||
|
||
- By default, the JCTVC encoder is limited to a precision of 12 | ||
bits. You can enable high bit depths (up to 14) by enabling the | ||
Makefile define: USE_JCTVC_HIGH_BIT_DEPTH. The encoder is sligthly | ||
slower in this case. | ||
|
||
3) FFmpeg modifications | ||
----------------------- | ||
|
||
- Completed support of chroma_format_idc = 0 (monochrome mode). | ||
|
||
- Fixed RDPCM support (intra predictions). | ||
|
||
- Added a 'dynamic bit depth' mode where all the bit depths from 8 to | ||
14 are supported without code duplication but slower decoding. | ||
|
||
- Added a modified SPS header to reduce the size of the BPG decoder | ||
(the solution instead is to generate standard VPS and SPS headers | ||
from the BPG header). | ||
|
||
- Added defines to keep only the HEVC intra code and suppress the | ||
parsing of all the irrelevant NAL units. | ||
|
||
- Stripped FFmpeg from all codecs except HEVC and the necessary | ||
support code. | ||
|
||
- Generated the IDCT coefficients dynamically to reduce the code size. | ||
|
||
4) 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). | ||
|
||
- 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.9 |
Oops, something went wrong.