forked from mirrorer/libbpg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.shared
278 lines (226 loc) · 7.01 KB
/
Makefile.shared
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# 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
# Compile bpgview (SDL and SDL_image libraries needed)
USE_BPGVIEW=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
# Enable for compilation on MacOS X
#CONFIG_APPLE=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 -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./src
CFLAGS+=-DCONFIG_BPG_VERSION=\"$(shell cat VERSION)\"
ifdef USE_JCTVC_HIGH_BIT_DEPTH
CFLAGS+=-DRExt__HIGH_BIT_DEPTH_SUPPORT
endif
ifneq ($(shell uname -m), i386)
CFLAGS += -fPIC
endif
# Emscriptem config
EMLDFLAGS:=-s "EXPORTED_FUNCTIONS=['_bpg_decoder_open','_bpg_decoder_decode','_bpg_decoder_get_info','_bpg_decoder_start','_bpg_decoder_get_frame_duration','_bpg_decoder_get_line','_bpg_decoder_close','_malloc','_free']"
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)
LDFLAGS=-g
ifdef CONFIG_APPLE
LDFLAGS+=-Wl,-dead_strip
else
LDFLAGS+=-Wl,--gc-sections
endif
CFLAGS+=-g
CXXFLAGS=$(CFLAGS)
PROGS=bpgdec$(EXE) bpgenc$(EXE)
ifdef USE_BPGVIEW
PROGS+=bpgview$(EXE)
endif
ifdef USE_EMCC
PROGS+=bpgdec.js bpgdec8.js bpgdec8a.js
endif
all: $(PROGS)
LIBBPG_OBJS:=$(addprefix src/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 \
golomb.o \
videodsp.o )
LIBBPG_OBJS+=$(addprefix src/libavutil/, \
mem.o \
buffer.o \
log2_tab.o \
frame.o \
pixdesc.o \
md5.o )
LIBBPG_OBJS+=src/libbpg.o
LIBBPG_JS_OBJS:=$(patsubst %.o, %.js.o, $(LIBBPG_OBJS)) src/tmalloc.js.o
LIBBPG_JS8_OBJS:=$(patsubst %.o, %.js8.o, $(LIBBPG_OBJS)) src/tmalloc.js8.o
LIBBPG_JS8A_OBJS:=$(patsubst %.o, %.js8a.o, $(LIBBPG_OBJS)) src/tmalloc.js8a.o
$(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 -DUSE_PRED
$(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
$(LIBBPG_JS8A_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_PRED
BPGENC_OBJS:=src/bpgenc.o
BPGENC_LIBS:=
ifdef USE_X265
BPGENC_OBJS+=src/x265_glue.o
BPGENC_LIBS+= -lx265
src/bpgenc.o: CFLAGS+=-DUSE_X265
endif # USE_X265
ifdef USE_JCTVC
JCTVC_OBJS=$(addprefix src/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+=src/jctvc/TLibVideoIO/TVideoIOYuv.o
JCTVC_OBJS+=$(addprefix src/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+=src/jctvc/libmd5/libmd5.o
JCTVC_OBJS+=src/jctvc/TAppEncCfg.o src/jctvc/TAppEncTop.o src/jctvc/program_options_lite.o
$(JCTVC_OBJS) src/jctvc_glue.o: CFLAGS+=-I$(PWD)/src/jctvc -Wno-sign-compare
src/jctvc/libjctvc.a: $(JCTVC_OBJS)
$(AR) rcs $@ $^
libbpgenc.so.0: $(JCTVC_OBJS)
$(CC) -shared -Wall -Wl,-soname,$@ $^ -o $@ $(BPGENC_LIBS)
BPGENC_OBJS+=src/jctvc_glue.o libbpgenc.so.0
src/bpgenc.o: CFLAGS+=-DUSE_JCTVC
endif # USE_JCTVC
ifdef CONFIG_WIN32
LDFLAGS+=-static
BPGDEC_LIBS:=-Wl,-dy -lpng -lz -Wl,-dn
BPGENC_LIBS+=-Wl,-dy -lpng -ljpeg -lz -Wl,-dn
BPGVIEW_LIBS:=-lmingw32 -lSDLmain -Wl,-dy -lSDL_image -lSDL -Wl,-dn -mwindows
else
ifdef CONFIG_APPLE
LIBS:=
else
LIBS:=-lrt
endif # !CONFIG_APPLE
LIBS+=-lm -lpthread
BPGDEC_LIBS:=-lpng $(LIBS)
BPGENC_LIBS+=-lpng -ljpeg $(LIBS)
BPGVIEW_LIBS:=-lSDL_image -lSDL $(LIBS)
endif #!CONFIG_WIN32
src/bpgenc.o: CFLAGS+=-Wno-unused-but-set-variable
libbpg.a: $(LIBBPG_OBJS)
$(AR) rcs $@ $^
libbpgdec.so.0: $(LIBBPG_OBJS)
$(CC) -shared -Wall -Wl,-soname,$@ $^ -o $@ $(BPGDEC_LIBS)
bpgdec$(EXE): src/bpgdec.o libbpgdec.so.0
$(CC) $(LDFLAGS) -o $@ $^ $(BPGDEC_LIBS)
bpgenc$(EXE): $(BPGENC_OBJS) libbpgenc.so.0
$(CXX) $(LDFLAGS) -o $@ $^ $(BPGENC_LIBS)
bpgview$(EXE): src/bpgview.o libbpgdec.so.0
$(CC) $(LDFLAGS) -o $@ $^ $(BPGVIEW_LIBS)
bpgdec.js: $(LIBBPG_JS_OBJS) src/post.js
$(EMCC) $(EMLDFLAGS) -s TOTAL_MEMORY=33554432 -o $@ $(LIBBPG_JS_OBJS)
bpgdec8.js: $(LIBBPG_JS8_OBJS) src/post.js
$(EMCC) $(EMLDFLAGS) -s TOTAL_MEMORY=16777216 -o $@ $(LIBBPG_JS8_OBJS)
bpgdec8a.js: $(LIBBPG_JS8A_OBJS) src/post.js
$(EMCC) $(EMLDFLAGS) -s TOTAL_MEMORY=16777216 -o $@ $(LIBBPG_JS8A_OBJS)
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 src/libavcodec src/libavutil \
src/jctvc src/jctvc/TLibEncoder src/jctvc/TLibVideoIO \
src/jctvc/TLibCommon src/jctvc/libmd5
clean:
rm -f $(PROGS) libbpgenc.so.0 libbpgdec.so.0 $(BPGENC_OBJS) $(LIBBPG_OBJS) $(JCTVC_OBJS) \
src/*.o *.a src/*.d src/*~ $(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 $@ $<
%.js8.o: %.c
$(EMCC) $(EMCFLAGS) -c -o $@ $<
%.js8a.o: %.c
$(EMCC) $(EMCFLAGS) -c -o $@ $<
-include $(wildcard src/*.d)
-include $(wildcard src/libavcodec/*.d)
-include $(wildcard src/libavutil/*.d)
-include $(wildcard src/jctvc/*.d)
-include $(wildcard src/jctvc/TLibEncoder/*.d)
-include $(wildcard src/jctvc/TLibVideoIO/*.d)
-include $(wildcard src/jctvc/TLibCommon/*.d)
-include $(wildcard src/jctvc/libmd5/*.d)