0
|
1 BPG Image library and utilities
|
|
2 -------------------------------
|
|
3
|
|
4 1) Quick introduction
|
|
5 ---------------------
|
|
6
|
|
7 - Edit the Makefile to change the compile options (the default compile
|
|
8 options should be OK for Linux). Type 'make' to compile and 'make
|
|
9 install' to install the compiled binaries.
|
|
10
|
|
11 - bpgview: in order to compile it you need to install the SDL and
|
|
12 SDL_image libraries.
|
|
13
|
|
14 - Emscripten usage: in order to generate the Javascript decoder, you
|
|
15 must install Emscripten and enable its use in the Makefile.
|
|
16
|
|
17 - An HTML demonstration (with a precompiled Javascript decoder) is
|
|
18 available in html/index.html (if you use Chrome and want to use
|
|
19 file:// to access it, launch Chrome with the option
|
|
20 --allow-file-access-from-files).
|
|
21
|
|
22 - The BPG file format is specified in doc/bpg_spec.txt.
|
|
23
|
|
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
|
|
57 --------------
|
|
58
|
|
59 The BPG command line encoder is 'bpgenc'. It takes JPEG or PNG images
|
|
60 as input.
|
|
61
|
|
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).
|
|
67
|
|
68 - Bit depth: the default bit depth is 8. You can increase it to 10
|
|
69 ('-b 10' option) to slightly increase the compression ratio. For web
|
|
70 publishing it is generally not a good idea because the Javascript
|
|
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.
|
|
75
|
|
76 - Lossless compression is supported as a bonus thru the HEVC lossless
|
|
77 capabilities. Use a PNG input in this case unless you know what you
|
|
78 do ! In case of a JPEG input, the compression is lossless related to
|
|
79 the JPEG YCbCr data, not the RGB data. In any case, the bit depth
|
|
80 should match the one of your picture otherwise the file size
|
|
81 increases a lot. By default the lossless mode sets the bit depth to
|
|
82 8 bits. The prefered color space is set to "rgb". Notes:
|
|
83
|
|
84 - lossless mode is less tested that the lossy mode but it usually
|
|
85 gives better results that PNG on photographic images.
|
|
86
|
|
87 - the JCTVC encoder gives smaller images than the x265 encoder
|
|
88 with lossless compression.
|
|
89
|
|
90 - There is a small difference of interpretation of the quantizer
|
|
91 parameter (-q option) between the x265 and JCTVC encoder.
|
|
92
|
|
93 - Color space and chroma format:
|
|
94
|
|
95 * For JPEG input, the color space of the input image is not
|
|
96 modified (it is YCbCr, RGB, YCbCrK or CMYK). The chroma is
|
|
97 subsampled according to the preferred chroma format ('-f'
|
|
98 option).
|
|
99
|
|
100 * For PNG input, the input image is converted to the preferred
|
|
101 color space ('-c' option). Its chroma is then subsampled
|
|
102 according to the preferred chroma format.
|
|
103
|
|
104 * grayscale images are kept unmodified.
|
|
105
|
|
106 - Premultiplied alpha: by default bpgenc uses non-premultiplied alpha
|
|
107 to preserve the color components. However, premultiplied alpha
|
|
108 ('-premul' option) usually gives a better compression at the expense
|
|
109 of a loss in the color components. This loss is not an issue if the
|
|
110 image is not edited.
|
|
111
|
|
112 - Animations: with the '-a' option, animations can be encoded from a
|
|
113 sequence of PNG or JPEG images, indexed from 1 or 0. For example:
|
|
114
|
|
115 ./bpgenc -a anim%2d.png -fps 25 -loop 0 -o anim.bpg
|
|
116
|
|
117 generates an animation from anim01.png, anim02.png, etc... The frame
|
|
118 rate is specified with '-fps' and the number of loops with '-loop'
|
|
119 (0 = infinite). If a different delay per image is needed as in some
|
|
120 animated GIFs, a text file can be specified with the '-delayfile'
|
|
121 option. It contains one number per image giving its duration in
|
|
122 centiseconds. All durations are rounded to a multiple of '1/fps', so
|
|
123 it is important to set a consistent frame rate.
|
|
124
|
|
125 The necessary frames and delay file can be generated from animated
|
|
126 GIFs with the ImageMagick tools:
|
|
127
|
|
128 convert -coalesce anim.gif anim%d.png
|
|
129
|
|
130 identify -format "%T\n" anim.gif > anim.txt
|
|
131
|
|
132 In order to reduce the file size, the frame rate can be choosen so
|
|
133 that most frames have a frame period of 1 (hence if anim.txt
|
|
134 contains only frame durations of 5 centiseconds, then choose a frame
|
|
135 rate of 20 frames/s).
|
|
136
|
|
137 As GIFs use paletted colors and 1 bit transparency, it is always
|
|
138 better to start from the source material (e.g. PNG files) to have
|
|
139 the best quality.
|
|
140
|
|
141 A BPG decoder not supporting animations only displays the first
|
|
142 frame.
|
|
143
|
|
144 - By default, bpgenc does not copy the metadata. You can copy them
|
|
145 with the '-keepmetadata' option. For JPEG input, EXIF, ICCP and XMP
|
|
146 are copied. For PNG input, ICCP is copied.
|
|
147
|
|
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.
|
|
151
|
|
152 4) BPG decoder
|
|
153 --------------
|
|
154
|
|
155 The BPG command line decoder is bpgdec. It outputs a PNG or PPM
|
|
156 image. Use a PPM output to get the fastest speed.
|
|
157
|
|
158 - With the '-i' option, you have information about the BPG image (and
|
|
159 no decoded image is output).
|
|
160
|
|
161 - The '-b' option selects the bit depth (8 or 16) of the PNG
|
|
162 output. It is independent of the internal BPG bit depth.
|
|
163
|
|
164 5) BPG viewer
|
|
165 -------------
|
|
166
|
|
167 The BPG image viewer uses the SDL library to display BPG images and
|
|
168 other image formats supported by the SDL_image library. The available
|
|
169 keys are displayed by launching bpgview without parameters. bpgview
|
|
170 supports BPG animations.
|
|
171
|
|
172 6) BPG decoding library
|
|
173 -----------------------
|
|
174
|
|
175 BPG images can be decoded in any program with the libbpg
|
|
176 library.
|
|
177
|
|
178 The API is not considered stable yet so that the library is only
|
|
179 provided as a static one.
|
|
180
|
|
181 Currently there is no similar library for encoding so you should
|
|
182 invoke the bpgenc utility.
|
|
183
|
|
184 7) Javascript decoder
|
|
185 ---------------------
|
|
186
|
|
187 The following Javascript decoders are available, sorted by increasing size:
|
|
188
|
|
189 > 8 bits animations
|
|
190 bpgdec8.js no no
|
|
191 bpgdec.js yes no
|
|
192 bpgdec8a.js no yes
|
|
193
|
|
194
|
|
195 The 8 bit only decoders are a little faster and consumes less memory
|
|
196 (16 MB instead of 32 MB by default, you can change the memory
|
|
197 configuration in the Makefile if you want to handle larger images).
|
|
198
|
|
199 The Javascript decoder substitutes all the <img> tags with a source
|
|
200 having a .bpg extension with a <canvas> tag and decodes the BPG image
|
|
201 into it. Stylesheets are supported (the 'id' and 'class' attributes
|
|
202 are preserved). The 'width' and 'height' attributes are supported only
|
|
203 with pixel units.
|
|
204
|
|
205 The image data is downloaded with the XMLHttpRequest object. So the
|
|
206 BPG images and the BPG Javascript decoder must be in the same domain
|
|
207 unless Cross-Origin Resource Sharing is used.
|
|
208
|
|
209 When animations are displayed, all the frames are stored in memory, so
|
|
210 animations with a large number of frames and large resolutions should
|
|
211 be avoided, as with animated GIFs.
|
|
212
|
|
213 asm.js gives an interesting speed boost, so we hope that more browsers
|
|
214 will support this Javascript subset.
|
|
215
|
|
216 8) FFmpeg modifications
|
|
217 -----------------------
|
|
218
|
|
219 - Completed support of chroma_format_idc = 0 (monochrome mode).
|
|
220
|
|
221 - Fixed RDPCM support (intra predictions).
|
|
222
|
|
223 - Reduced memory usage for the SAO loop filter.
|
|
224
|
|
225 - Generated the IDCT coefficients dynamically to reduce the code size.
|
|
226
|
|
227 - Added a 'dynamic bit depth' mode where all the bit depths from 8 to
|
|
228 14 are supported without code duplication but slower decoding.
|
|
229
|
|
230 - Added a modified SPS header to reduce the size of the BPG decoder
|
|
231 (an alternate solution is to generate standard VPS and SPS headers
|
|
232 from the BPG header).
|
|
233
|
|
234 - Added defines to keep only the HEVC intra code and suppress the
|
|
235 parsing of all the irrelevant NAL units.
|
|
236
|
|
237 - Stripped FFmpeg from all codecs except HEVC and the necessary
|
|
238 support code.
|
|
239
|
|
240 9) x265 modifications
|
|
241 ---------------------
|
|
242
|
|
243 - Support of monochrome format (some parts not used by BPG may be
|
|
244 missing).
|
|
245
|
|
246 - Support of static build.
|
|
247
|
|
248 10) Licensing
|
|
249 -------------
|
|
250
|
|
251 - libbpg and bpgdec are released under the LGPL license (the FFmpeg
|
|
252 part is under the LGPL, the BPG specific part is released under the
|
|
253 BSD license).
|
|
254
|
|
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.
|
|
259
|
|
260 - BPG relies on the HEVC compression technology which may be protected
|
|
261 by patents in some countries. Most devices already include or will
|
|
262 include hardware HEVC support, so we suggest to use it if patents
|
|
263 are an issue.
|