Skip to content

Commit 47f4357

Browse files
committed
0.9.6
1 parent 1d26361 commit 47f4357

File tree

248 files changed

+232891
-100
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

248 files changed

+232891
-100
lines changed

ChangeLog

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
version 0.9.6:
2+
3+
- Faster encoding (x265 is the default encoder and is built in bpgenc).
4+
- Added monochrome support to x265.
5+
- Fixed metadata handling.
6+
17
version 0.9.5:
2-
8+
39
- Added animation support.
410
- added bpgview utility.
511
- bpgenc: fixed support of some JPEG parameter combinations

Makefile

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
#
55
# Enable compilation of Javascript decoder with Emscripten
66
#USE_EMCC=y
7-
# Enable x265 for the encoder (you must install it before)
8-
#USE_X265=y
7+
# Enable x265 for the encoder
8+
USE_X265=y
99
# Enable the JCTVC code (best quality but slow) for the encoder
10-
USE_JCTVC=y
10+
#USE_JCTVC=y
1111
# Compile bpgview (SDL and SDL_image libraries needed)
1212
USE_BPGVIEW=y
1313
# Enable it to use bit depths > 12 (need more tests to validate encoder)
@@ -23,8 +23,8 @@ prefix=/usr/local
2323
#################################
2424

2525
ifdef CONFIG_WIN32
26-
#CROSS_PREFIX:=x86_64-w64-mingw32-
27-
CROSS_PREFIX=i686-w64-mingw32-
26+
CROSS_PREFIX:=x86_64-w64-mingw32-
27+
#CROSS_PREFIX=i686-w64-mingw32-
2828
EXE:=.exe
2929
else
3030
CROSS_PREFIX:=
@@ -97,9 +97,41 @@ BPGENC_OBJS:=bpgenc.o
9797
BPGENC_LIBS:=
9898

9999
ifdef USE_X265
100-
BPGENC_OBJS+=x265_glue.o
101-
BPGENC_LIBS+= -lx265
100+
101+
X265_LIBS:=./x265.out/8bit/libx265.a ./x265.out/10bit/libx265.a ./x265.out/12bit/libx265.a
102+
BPGENC_OBJS+=x265_glue.o $(X265_LIBS)
103+
102104
bpgenc.o: CFLAGS+=-DUSE_X265
105+
x265_glue.o: CFLAGS+=-I./x265/source -I./x265.out/8bit
106+
x265_glue.o: $(X265_LIBS)
107+
108+
ifdef CONFIG_WIN32
109+
CMAKE_OPTS:=-DCMAKE_TOOLCHAIN_FILE=../../x265/build/msys/toolchain-x86_64-w64-mingw32.cmake
110+
else
111+
CMAKE_OPTS:=
112+
endif
113+
114+
x265.out:
115+
mkdir -p x265.out/8bit x265.out/10bit x265.out/12bit
116+
cd x265.out/12bit && cmake ../../x265/source $(CMAKE_OPTS) -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN12=ON
117+
cd x265.out/10bit && cmake ../../x265/source $(CMAKE_OPTS) -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN10=ON
118+
cd x265.out/8bit && cmake ../../x265/source $(CMAKE_OPTS) -DLINKED_10BIT=ON -DLINKED_12BIT=ON -DENABLE_SHARED=OFF -DENABLE_CLI=OFF
119+
120+
# use this target to manually rebuild x265
121+
x265_make: | x265.out
122+
$(MAKE) -C x265.out/12bit
123+
$(MAKE) -C x265.out/10bit
124+
$(MAKE) -C x265.out/8bit
125+
126+
x265_clean:
127+
rm -rf x265.out
128+
129+
$(X265_LIBS): x265_make
130+
131+
else
132+
133+
x265_clean:
134+
103135
endif # USE_X265
104136

105137
ifdef USE_JCTVC
@@ -133,10 +165,9 @@ endif # USE_JCTVC
133165

134166
ifdef CONFIG_WIN32
135167

136-
LDFLAGS+=-static
137-
BPGDEC_LIBS:=-Wl,-dy -lpng -lz -Wl,-dn
138-
BPGENC_LIBS+=-Wl,-dy -lpng -ljpeg -lz -Wl,-dn
139-
BPGVIEW_LIBS:=-lmingw32 -lSDLmain -Wl,-dy -lSDL_image -lSDL -Wl,-dn -mwindows
168+
BPGDEC_LIBS:=-lpng -lz
169+
BPGENC_LIBS+=-lpng -ljpeg -lz
170+
BPGVIEW_LIBS:=-lmingw32 -lSDLmain -lSDL_image -lSDL -mwindows
140171

141172
else
142173

@@ -171,10 +202,10 @@ bpgdec.js: $(LIBBPG_JS_OBJS) post.js
171202
$(EMCC) $(EMLDFLAGS) -s TOTAL_MEMORY=33554432 -o $@ $(LIBBPG_JS_OBJS)
172203

173204
bpgdec8.js: $(LIBBPG_JS8_OBJS) post.js
174-
$(EMCC) $(EMLDFLAGS) -s TOTAL_MEMORY=16777216 -o $@ $(LIBBPG_JS8_OBJS)
205+
$(EMCC) $(EMLDFLAGS) -s TOTAL_MEMORY=33554432 -o $@ $(LIBBPG_JS8_OBJS)
175206

176207
bpgdec8a.js: $(LIBBPG_JS8A_OBJS) post.js
177-
$(EMCC) $(EMLDFLAGS) -s TOTAL_MEMORY=16777216 -o $@ $(LIBBPG_JS8A_OBJS)
208+
$(EMCC) $(EMLDFLAGS) -s TOTAL_MEMORY=33554432 -o $@ $(LIBBPG_JS8A_OBJS)
178209

179210
size:
180211
strip bpgdec
@@ -187,7 +218,7 @@ install: bpgenc bpgdec
187218
CLEAN_DIRS=doc html libavcodec libavutil \
188219
jctvc jctvc/TLibEncoder jctvc/TLibVideoIO jctvc/TLibCommon jctvc/libmd5
189220

190-
clean:
221+
clean: x265_clean
191222
rm -f $(PROGS) *.o *.a *.d *~ $(addsuffix /*.o, $(CLEAN_DIRS)) \
192223
$(addsuffix /*.d, $(CLEAN_DIRS)) $(addsuffix /*~, $(CLEAN_DIRS)) \
193224
$(addsuffix /*.a, $(CLEAN_DIRS))

README

Lines changed: 66 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ BPG Image library and utilities
88
options should be OK for Linux). Type 'make' to compile and 'make
99
install' to install the compiled binaries.
1010

11-
- x265 usage: for much increased compression speed (but lower
12-
quality), you can compile and install x265 and then enable its use
13-
in the Makefile. x265 supports by default only 8 bits per component
14-
and does not support monochrome encoding yet (hence no alpha nor
15-
grayscale images can be encoded with it).
16-
1711
- bpgview: in order to compile it you need to install the SDL and
1812
SDL_image libraries.
1913

@@ -27,24 +21,57 @@ BPG Image library and utilities
2721

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

30-
2) BPG encoder
24+
2) Compilation and Installation Notes
25+
-------------------------------------
26+
27+
2.1) Linux
28+
----------
29+
30+
- Edit the Makefile to change the compile options (the default
31+
compile options should be OK). Type 'make' to compile and 'make
32+
install' to install the compiled binaries.
33+
34+
- Use 'make -j N' where N is the number of CPU cores to compile faster.
35+
36+
- The following packages must be installed: SDL-devel
37+
SDL_image-devel yasm. It is recommended to use yasm version >= 1.3.0
38+
to have a faster compilation.
39+
40+
- Only a 64 bit target is supported because x265 needs it for bit
41+
depths > 8.
42+
43+
2.2) Windows
44+
------------
45+
46+
- Only cross-compilation from Linux is supported.
47+
48+
- The following packages need to be installed: mingw64-gcc
49+
mingw64-libpng mingw64-libjpeg-turbo mingw64-SDL mingw64-SDL_image
50+
yasm. It is recommended to use yasm version >= 1.3.0 to have a
51+
faster compilation.
52+
53+
- Only a 64 bit target is supported because x265 needs it for bit
54+
depths > 8.
55+
56+
3) BPG encoder
3157
--------------
3258

3359
The BPG command line encoder is 'bpgenc'. It takes JPEG or PNG images
3460
as input.
3561

36-
- Speed: by default bpgenc uses the JCTVC encoder which has a high
37-
quality but is slow. If you compiled with x265, you can have a much
38-
faster encoding with the '-e x265' option. With x265 you can also
39-
select the encoding speed with the '-m' option (1 = fast, but larger
40-
image, 9 = slower but smaller image). Warning: x265 does not support
41-
monochrome (and alpha) yet, so you must use the JCTVC encoder for
42-
these cases.
62+
- Speed: by default bpgenc uses the x265. You can compile the much
63+
slower but more efficient JCTVC encoder and select it with the '-e
64+
jctvc' option. With x265 you can select the encoding speed with the
65+
'-m' option (1 = fast, but larger image, 9 = slower but smaller
66+
image).
4367

4468
- Bit depth: the default bit depth is 8. You can increase it to 10
4569
('-b 10' option) to slightly increase the compression ratio. For web
4670
publishing it is generally not a good idea because the Javascript
47-
decoder uses more memory.
71+
decoder uses more memory. The compiled x265 encoder supports the bit
72+
depth of 8, 10 and 12. The slower JCTVC encoder can be compiled to
73+
support higher bit depths (up to 14) by enabling the Makefile
74+
define: USE_JCTVC_HIGH_BIT_DEPTH.
4875

4976
- Lossless compression is supported as a bonus thru the HEVC lossless
5077
capabilities. Use a PNG input in this case unless you know what you
@@ -60,15 +87,8 @@ as input.
6087
- the JCTVC encoder gives smaller images than the x265 encoder
6188
with lossless compression.
6289

63-
- There is a difference of interpretation of the quantizer parameter
64-
(-q option) between the x265 and JCTVC encoder. The default value is
65-
optimized for the JCTVC encoder, not for x265. We will try to align
66-
the x265 value to JCTVC in the future.
67-
68-
- By default, the JCTVC encoder is limited to a precision of 12
69-
bits. You can enable high bit depths (up to 14) by enabling the
70-
Makefile define: USE_JCTVC_HIGH_BIT_DEPTH. The encoder is sligthly
71-
slower in this case.
90+
- There is a small difference of interpretation of the quantizer
91+
parameter (-q option) between the x265 and JCTVC encoder.
7292

7393
- Color space and chroma format:
7494

@@ -125,11 +145,11 @@ as input.
125145
with the '-keepmetadata' option. For JPEG input, EXIF, ICCP and XMP
126146
are copied. For PNG input, ICCP is copied.
127147

128-
- Objective comparisons: the JCTVC encoder is tuned for PSNR only, not
129-
for SSIM, so you should use PSNR when making objective comparison
130-
with other formats. x265 is tuned by default for SSIM.
148+
- Objective comparisons: x265 is tuned by default for SSIM. the JCTVC
149+
encoder is tuned for PSNR only, not for SSIM, so you should use PSNR
150+
when making objective comparison with other formats.
131151

132-
3) BPG decoder
152+
4) BPG decoder
133153
--------------
134154

135155
The BPG command line decoder is bpgdec. It outputs a PNG or PPM
@@ -141,15 +161,15 @@ no decoded image is output).
141161
- The '-b' option selects the bit depth (8 or 16) of the PNG
142162
output. It is independent of the internal BPG bit depth.
143163

144-
4) BPG viewer
164+
5) BPG viewer
145165
-------------
146166

147167
The BPG image viewer uses the SDL library to display BPG images and
148168
other image formats supported by the SDL_image library. The available
149169
keys are displayed by launching bpgview without parameters. bpgview
150170
supports BPG animations.
151171

152-
5) BPG decoding library
172+
6) BPG decoding library
153173
-----------------------
154174

155175
BPG images can be decoded in any program with the libbpg
@@ -161,7 +181,7 @@ provided as a static one.
161181
Currently there is no similar library for encoding so you should
162182
invoke the bpgenc utility.
163183

164-
6) Javascript decoder
184+
7) Javascript decoder
165185
---------------------
166186

167187
The following Javascript decoders are available, sorted by increasing size:
@@ -193,7 +213,7 @@ be avoided, as with animated GIFs.
193213
asm.js gives an interesting speed boost, so we hope that more browsers
194214
will support this Javascript subset.
195215

196-
7) FFmpeg modifications
216+
8) FFmpeg modifications
197217
-----------------------
198218

199219
- Completed support of chroma_format_idc = 0 (monochrome mode).
@@ -217,16 +237,25 @@ will support this Javascript subset.
217237
- Stripped FFmpeg from all codecs except HEVC and the necessary
218238
support code.
219239

220-
8) Licensing
221-
------------
240+
9) x265 modifications
241+
---------------------
242+
243+
- Support of monochrome format (some part not used by BPG may be
244+
missing).
245+
246+
- Support of static build.
247+
248+
10) Licensing
249+
-------------
222250

223251
- libbpg and bpgdec are released under the LGPL license (the FFmpeg
224252
part is under the LGPL, the BPG specific part is released under the
225253
BSD license).
226254

227-
- bpgenc is released under the BSD license (it includes the JCTVC code
228-
which is released under the BSD license. The BPG specific part is
229-
released under the BSD license).
255+
- bpgenc is released under the GPL version 2 license. The BPG specific
256+
code is released under the BSD license. The JCTVC code is released
257+
under the BSD license. The x265 code is released under the GPL
258+
version 2 license.
230259

231260
- BPG relies on the HEVC compression technology which may be protected
232261
by patents in some countries. Most devices already include or will

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.9.5
1+
0.9.6

bpgenc.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,10 +1893,12 @@ static int build_modified_sps(uint8_t **pout_buf, int *pout_buf_len,
18931893
int vui_hrd_parameters_present_flag, bitstream_restriction_flag;
18941894

18951895
sar_present = get_bits(gb, 1);
1896-
sar_idx = get_bits(gb, 8);
1897-
if (sar_idx == 255) {
1898-
skip_bits(gb, 16); /* sar_num */
1899-
skip_bits(gb, 16); /* sar_den */
1896+
if (sar_present) {
1897+
sar_idx = get_bits(gb, 8);
1898+
if (sar_idx == 255) {
1899+
skip_bits(gb, 16); /* sar_num */
1900+
skip_bits(gb, 16); /* sar_den */
1901+
}
19001902
}
19011903

19021904
overscan_info_present_flag = get_bits(gb, 1);
@@ -2159,38 +2161,38 @@ static int build_modified_hevc(uint8_t **pout_buf,
21592161
}
21602162

21612163
typedef enum {
2162-
#if defined(USE_JCTVC)
2163-
HEVC_ENCODER_JCTVC,
2164-
#endif
21652164
#if defined(USE_X265)
21662165
HEVC_ENCODER_X265,
21672166
#endif
2167+
#if defined(USE_JCTVC)
2168+
HEVC_ENCODER_JCTVC,
2169+
#endif
21682170

21692171
HEVC_ENCODER_COUNT,
21702172
} HEVCEncoderEnum;
21712173

21722174
static char *hevc_encoder_name[HEVC_ENCODER_COUNT] = {
2173-
#if defined(USE_JCTVC)
2174-
"jctvc",
2175-
#endif
21762175
#if defined(USE_X265)
21772176
"x265",
21782177
#endif
2178+
#if defined(USE_JCTVC)
2179+
"jctvc",
2180+
#endif
21792181
};
21802182

21812183
static HEVCEncoder *hevc_encoder_tab[HEVC_ENCODER_COUNT] = {
2182-
#if defined(USE_JCTVC)
2183-
&jctvc_encoder,
2184-
#endif
21852184
#if defined(USE_X265)
21862185
&x265_hevc_encoder,
21872186
#endif
2187+
#if defined(USE_JCTVC)
2188+
&jctvc_encoder,
2189+
#endif
21882190
};
21892191

21902192
#define IMAGE_HEADER_MAGIC 0x425047fb
21912193

21922194
#define DEFAULT_OUTFILENAME "out.bpg"
2193-
#define DEFAULT_QP 28
2195+
#define DEFAULT_QP 29
21942196
#define DEFAULT_BIT_DEPTH 8
21952197

21962198
#ifdef RExt__HIGH_BIT_DEPTH_SUPPORT

doc/bpg_spec.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ heic_file() {
7979

8080
picture_data_length ue7(32)
8181
if (extension_present_flag)
82-
extension_data_length ue7(32)
83-
84-
if (extension_present_flag) {
82+
extension_data_length ue7(32)
8583
extension_data()
8684
}
8785

html/bpgdec.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

html/bpgdec8.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

html/bpgdec8a.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libbpg.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,7 @@ static int bpg_decode_header(BPGHeaderData *h,
17861786
md = av_malloc(sizeof(BPGExtensionData));
17871787
md->tag = tag;
17881788
md->buf_len = buf_len;
1789+
md->next = NULL;
17891790
*plast_md = md;
17901791
plast_md = &md->next;
17911792

0 commit comments

Comments
 (0)