Avoid setting rate multiplier as 0
[aom.git] / examples.mk
blobdfa5a654e44d1a8ef0357382fa1c7739c6d78d93
1 ##
2 ## Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 ##
4 ## Use of this source code is governed by a BSD-style license
5 ## that can be found in the LICENSE file in the root of the source
6 ## tree. An additional intellectual property rights grant can be found
7 ## in the file PATENTS. All contributing project authors may
8 ## be found in the AUTHORS file in the root of the source tree.
9 ##
11 LIBYUV_SRCS += third_party/libyuv/include/libyuv/basic_types.h \
12 third_party/libyuv/include/libyuv/convert.h \
13 third_party/libyuv/include/libyuv/convert_argb.h \
14 third_party/libyuv/include/libyuv/convert_from.h \
15 third_party/libyuv/include/libyuv/cpu_id.h \
16 third_party/libyuv/include/libyuv/planar_functions.h \
17 third_party/libyuv/include/libyuv/rotate.h \
18 third_party/libyuv/include/libyuv/row.h \
19 third_party/libyuv/include/libyuv/scale.h \
20 third_party/libyuv/include/libyuv/scale_row.h \
21 third_party/libyuv/source/cpu_id.cc \
22 third_party/libyuv/source/planar_functions.cc \
23 third_party/libyuv/source/row_any.cc \
24 third_party/libyuv/source/row_common.cc \
25 third_party/libyuv/source/row_gcc.cc \
26 third_party/libyuv/source/row_mips.cc \
27 third_party/libyuv/source/row_neon.cc \
28 third_party/libyuv/source/row_neon64.cc \
29 third_party/libyuv/source/row_win.cc \
30 third_party/libyuv/source/scale.cc \
31 third_party/libyuv/source/scale_any.cc \
32 third_party/libyuv/source/scale_common.cc \
33 third_party/libyuv/source/scale_gcc.cc \
34 third_party/libyuv/source/scale_mips.cc \
35 third_party/libyuv/source/scale_neon.cc \
36 third_party/libyuv/source/scale_neon64.cc \
37 third_party/libyuv/source/scale_win.cc \
39 LIBWEBM_MUXER_SRCS += third_party/libwebm/mkvmuxer.cpp \
40 third_party/libwebm/mkvmuxerutil.cpp \
41 third_party/libwebm/mkvwriter.cpp \
42 third_party/libwebm/mkvmuxer.hpp \
43 third_party/libwebm/mkvmuxertypes.hpp \
44 third_party/libwebm/mkvmuxerutil.hpp \
45 third_party/libwebm/mkvparser.hpp \
46 third_party/libwebm/mkvwriter.hpp \
47 third_party/libwebm/webmids.hpp
49 LIBWEBM_PARSER_SRCS = third_party/libwebm/mkvparser.cpp \
50 third_party/libwebm/mkvreader.cpp \
51 third_party/libwebm/mkvparser.hpp \
52 third_party/libwebm/mkvreader.hpp
54 # List of examples to build. UTILS are tools meant for distribution
55 # while EXAMPLES demonstrate specific portions of the API.
56 UTILS-$(CONFIG_DECODERS) += vpxdec.c
57 vpxdec.SRCS += md5_utils.c md5_utils.h
58 vpxdec.SRCS += vpx_ports/mem_ops.h
59 vpxdec.SRCS += vpx_ports/mem_ops_aligned.h
60 vpxdec.SRCS += vpx_ports/msvc.h
61 vpxdec.SRCS += vpx_ports/vpx_timer.h
62 vpxdec.SRCS += vpx/vpx_integer.h
63 vpxdec.SRCS += args.c args.h
64 vpxdec.SRCS += ivfdec.c ivfdec.h
65 vpxdec.SRCS += tools_common.c tools_common.h
66 vpxdec.SRCS += y4menc.c y4menc.h
67 ifeq ($(CONFIG_LIBYUV),yes)
68 vpxdec.SRCS += $(LIBYUV_SRCS)
69 endif
70 ifeq ($(CONFIG_WEBM_IO),yes)
71 vpxdec.SRCS += $(LIBWEBM_PARSER_SRCS)
72 vpxdec.SRCS += webmdec.cc webmdec.h
73 endif
74 vpxdec.GUID = BA5FE66F-38DD-E034-F542-B1578C5FB950
75 vpxdec.DESCRIPTION = Full featured decoder
76 UTILS-$(CONFIG_ENCODERS) += vpxenc.c
77 vpxenc.SRCS += args.c args.h y4minput.c y4minput.h vpxenc.h
78 vpxenc.SRCS += ivfdec.c ivfdec.h
79 vpxenc.SRCS += ivfenc.c ivfenc.h
80 vpxenc.SRCS += rate_hist.c rate_hist.h
81 vpxenc.SRCS += tools_common.c tools_common.h
82 vpxenc.SRCS += warnings.c warnings.h
83 vpxenc.SRCS += vpx_ports/mem_ops.h
84 vpxenc.SRCS += vpx_ports/mem_ops_aligned.h
85 vpxenc.SRCS += vpx_ports/msvc.h
86 vpxenc.SRCS += vpx_ports/vpx_timer.h
87 vpxenc.SRCS += vpxstats.c vpxstats.h
88 ifeq ($(CONFIG_LIBYUV),yes)
89 vpxenc.SRCS += $(LIBYUV_SRCS)
90 endif
91 ifeq ($(CONFIG_WEBM_IO),yes)
92 vpxenc.SRCS += $(LIBWEBM_MUXER_SRCS)
93 vpxenc.SRCS += webmenc.cc webmenc.h
94 endif
95 vpxenc.GUID = 548DEC74-7A15-4B2B-AFC3-AA102E7C25C1
96 vpxenc.DESCRIPTION = Full featured encoder
97 ifeq ($(CONFIG_SPATIAL_SVC),yes)
98 EXAMPLES-$(CONFIG_VP9_ENCODER) += vp9_spatial_svc_encoder.c
99 vp9_spatial_svc_encoder.SRCS += args.c args.h
100 vp9_spatial_svc_encoder.SRCS += ivfenc.c ivfenc.h
101 vp9_spatial_svc_encoder.SRCS += tools_common.c tools_common.h
102 vp9_spatial_svc_encoder.SRCS += video_common.h
103 vp9_spatial_svc_encoder.SRCS += video_writer.h video_writer.c
104 vp9_spatial_svc_encoder.SRCS += vpx_ports/msvc.h
105 vp9_spatial_svc_encoder.SRCS += vpxstats.c vpxstats.h
106 vp9_spatial_svc_encoder.GUID = 4A38598D-627D-4505-9C7B-D4020C84100D
107 vp9_spatial_svc_encoder.DESCRIPTION = VP9 Spatial SVC Encoder
108 endif
110 ifneq ($(CONFIG_SHARED),yes)
111 EXAMPLES-$(CONFIG_VP9_ENCODER) += resize_util.c
112 endif
114 EXAMPLES-$(CONFIG_ENCODERS) += vpx_temporal_svc_encoder.c
115 vpx_temporal_svc_encoder.SRCS += ivfenc.c ivfenc.h
116 vpx_temporal_svc_encoder.SRCS += tools_common.c tools_common.h
117 vpx_temporal_svc_encoder.SRCS += video_common.h
118 vpx_temporal_svc_encoder.SRCS += video_writer.h video_writer.c
119 vpx_temporal_svc_encoder.SRCS += vpx_ports/msvc.h
120 vpx_temporal_svc_encoder.GUID = B18C08F2-A439-4502-A78E-849BE3D60947
121 vpx_temporal_svc_encoder.DESCRIPTION = Temporal SVC Encoder
122 EXAMPLES-$(CONFIG_DECODERS) += simple_decoder.c
123 simple_decoder.GUID = D3BBF1E9-2427-450D-BBFF-B2843C1D44CC
124 simple_decoder.SRCS += ivfdec.h ivfdec.c
125 simple_decoder.SRCS += tools_common.h tools_common.c
126 simple_decoder.SRCS += video_common.h
127 simple_decoder.SRCS += video_reader.h video_reader.c
128 simple_decoder.SRCS += vpx_ports/mem_ops.h
129 simple_decoder.SRCS += vpx_ports/mem_ops_aligned.h
130 simple_decoder.SRCS += vpx_ports/msvc.h
131 simple_decoder.DESCRIPTION = Simplified decoder loop
132 EXAMPLES-$(CONFIG_DECODERS) += postproc.c
133 postproc.SRCS += ivfdec.h ivfdec.c
134 postproc.SRCS += tools_common.h tools_common.c
135 postproc.SRCS += video_common.h
136 postproc.SRCS += video_reader.h video_reader.c
137 postproc.SRCS += vpx_ports/mem_ops.h
138 postproc.SRCS += vpx_ports/mem_ops_aligned.h
139 postproc.SRCS += vpx_ports/msvc.h
140 postproc.GUID = 65E33355-F35E-4088-884D-3FD4905881D7
141 postproc.DESCRIPTION = Decoder postprocessor control
142 EXAMPLES-$(CONFIG_DECODERS) += decode_to_md5.c
143 decode_to_md5.SRCS += md5_utils.h md5_utils.c
144 decode_to_md5.SRCS += ivfdec.h ivfdec.c
145 decode_to_md5.SRCS += tools_common.h tools_common.c
146 decode_to_md5.SRCS += video_common.h
147 decode_to_md5.SRCS += video_reader.h video_reader.c
148 decode_to_md5.SRCS += vpx_ports/mem_ops.h
149 decode_to_md5.SRCS += vpx_ports/mem_ops_aligned.h
150 decode_to_md5.SRCS += vpx_ports/msvc.h
151 decode_to_md5.GUID = 59120B9B-2735-4BFE-B022-146CA340FE42
152 decode_to_md5.DESCRIPTION = Frame by frame MD5 checksum
153 EXAMPLES-$(CONFIG_ENCODERS) += simple_encoder.c
154 simple_encoder.SRCS += ivfenc.h ivfenc.c
155 simple_encoder.SRCS += tools_common.h tools_common.c
156 simple_encoder.SRCS += video_common.h
157 simple_encoder.SRCS += video_writer.h video_writer.c
158 simple_encoder.SRCS += vpx_ports/msvc.h
159 simple_encoder.GUID = 4607D299-8A71-4D2C-9B1D-071899B6FBFD
160 simple_encoder.DESCRIPTION = Simplified encoder loop
161 EXAMPLES-$(CONFIG_VP9_ENCODER) += vp9_lossless_encoder.c
162 vp9_lossless_encoder.SRCS += ivfenc.h ivfenc.c
163 vp9_lossless_encoder.SRCS += tools_common.h tools_common.c
164 vp9_lossless_encoder.SRCS += video_common.h
165 vp9_lossless_encoder.SRCS += video_writer.h video_writer.c
166 vp9_lossless_encoder.SRCS += vpx_ports/msvc.h
167 vp9_lossless_encoder.GUID = B63C7C88-5348-46DC-A5A6-CC151EF93366
168 vp9_lossless_encoder.DESCRIPTION = Simplified lossless VP9 encoder
169 EXAMPLES-$(CONFIG_ENCODERS) += twopass_encoder.c
170 twopass_encoder.SRCS += ivfenc.h ivfenc.c
171 twopass_encoder.SRCS += tools_common.h tools_common.c
172 twopass_encoder.SRCS += video_common.h
173 twopass_encoder.SRCS += video_writer.h video_writer.c
174 twopass_encoder.SRCS += vpx_ports/msvc.h
175 twopass_encoder.GUID = 73494FA6-4AF9-4763-8FBB-265C92402FD8
176 twopass_encoder.DESCRIPTION = Two-pass encoder loop
177 EXAMPLES-$(CONFIG_DECODERS) += decode_with_drops.c
178 decode_with_drops.SRCS += ivfdec.h ivfdec.c
179 decode_with_drops.SRCS += tools_common.h tools_common.c
180 decode_with_drops.SRCS += video_common.h
181 decode_with_drops.SRCS += video_reader.h video_reader.c
182 decode_with_drops.SRCS += vpx_ports/mem_ops.h
183 decode_with_drops.SRCS += vpx_ports/mem_ops_aligned.h
184 decode_with_drops.SRCS += vpx_ports/msvc.h
185 decode_with_drops.GUID = CE5C53C4-8DDA-438A-86ED-0DDD3CDB8D26
186 decode_with_drops.DESCRIPTION = Drops frames while decoding
187 EXAMPLES-$(CONFIG_ENCODERS) += set_maps.c
188 set_maps.SRCS += ivfenc.h ivfenc.c
189 set_maps.SRCS += tools_common.h tools_common.c
190 set_maps.SRCS += video_common.h
191 set_maps.SRCS += video_writer.h video_writer.c
192 set_maps.SRCS += vpx_ports/msvc.h
193 set_maps.GUID = ECB2D24D-98B8-4015-A465-A4AF3DCC145F
194 set_maps.DESCRIPTION = Set active and ROI maps
195 EXAMPLES-$(CONFIG_VP8_ENCODER) += vp8cx_set_ref.c
196 vp8cx_set_ref.SRCS += ivfenc.h ivfenc.c
197 vp8cx_set_ref.SRCS += tools_common.h tools_common.c
198 vp8cx_set_ref.SRCS += video_common.h
199 vp8cx_set_ref.SRCS += video_writer.h video_writer.c
200 vp8cx_set_ref.SRCS += vpx_ports/msvc.h
201 vp8cx_set_ref.GUID = C5E31F7F-96F6-48BD-BD3E-10EBF6E8057A
202 vp8cx_set_ref.DESCRIPTION = VP8 set encoder reference frame
205 ifeq ($(CONFIG_MULTI_RES_ENCODING),yes)
206 ifeq ($(CONFIG_LIBYUV),yes)
207 EXAMPLES-$(CONFIG_VP8_ENCODER) += vp8_multi_resolution_encoder.c
208 vp8_multi_resolution_encoder.SRCS += ivfenc.h ivfenc.c
209 vp8_multi_resolution_encoder.SRCS += tools_common.h tools_common.c
210 vp8_multi_resolution_encoder.SRCS += video_writer.h video_writer.c
211 vp8_multi_resolution_encoder.SRCS += vpx_ports/msvc.h
212 vp8_multi_resolution_encoder.SRCS += $(LIBYUV_SRCS)
213 vp8_multi_resolution_encoder.GUID = 04f8738e-63c8-423b-90fa-7c2703a374de
214 vp8_multi_resolution_encoder.DESCRIPTION = VP8 Multiple-resolution Encoding
215 endif
216 endif
218 # Handle extra library flags depending on codec configuration
220 # We should not link to math library (libm) on RVCT
221 # when building for bare-metal targets
222 ifeq ($(CONFIG_OS_SUPPORT), yes)
223 CODEC_EXTRA_LIBS-$(CONFIG_VP8) += m
224 CODEC_EXTRA_LIBS-$(CONFIG_VP9) += m
225 else
226 ifeq ($(CONFIG_GCC), yes)
227 CODEC_EXTRA_LIBS-$(CONFIG_VP8) += m
228 CODEC_EXTRA_LIBS-$(CONFIG_VP9) += m
229 endif
230 endif
232 # End of specified files. The rest of the build rules should happen
233 # automagically from here.
237 # Examples need different flags based on whether we're building
238 # from an installed tree or a version controlled tree. Determine
239 # the proper paths.
240 ifeq ($(HAVE_ALT_TREE_LAYOUT),yes)
241 LIB_PATH-yes := $(SRC_PATH_BARE)/../lib
242 INC_PATH-yes := $(SRC_PATH_BARE)/../include
243 else
244 LIB_PATH-yes += $(if $(BUILD_PFX),$(BUILD_PFX),.)
245 INC_PATH-$(CONFIG_VP8_DECODER) += $(SRC_PATH_BARE)/vp8
246 INC_PATH-$(CONFIG_VP8_ENCODER) += $(SRC_PATH_BARE)/vp8
247 INC_PATH-$(CONFIG_VP9_DECODER) += $(SRC_PATH_BARE)/vp9
248 INC_PATH-$(CONFIG_VP9_ENCODER) += $(SRC_PATH_BARE)/vp9
249 endif
250 INC_PATH-$(CONFIG_LIBYUV) += $(SRC_PATH_BARE)/third_party/libyuv/include
251 LIB_PATH := $(call enabled,LIB_PATH)
252 INC_PATH := $(call enabled,INC_PATH)
253 INTERNAL_CFLAGS = $(addprefix -I,$(INC_PATH))
254 INTERNAL_LDFLAGS += $(addprefix -L,$(LIB_PATH))
257 # Expand list of selected examples to build (as specified above)
258 UTILS = $(call enabled,UTILS)
259 EXAMPLES = $(addprefix examples/,$(call enabled,EXAMPLES))
260 ALL_EXAMPLES = $(UTILS) $(EXAMPLES)
261 UTIL_SRCS = $(foreach ex,$(UTILS),$($(ex:.c=).SRCS))
262 ALL_SRCS = $(foreach ex,$(ALL_EXAMPLES),$($(notdir $(ex:.c=)).SRCS))
263 CODEC_EXTRA_LIBS=$(sort $(call enabled,CODEC_EXTRA_LIBS))
266 # Expand all example sources into a variable containing all sources
267 # for that example (not just them main one specified in UTILS/EXAMPLES)
268 # and add this file to the list (for MSVS workspace generation)
269 $(foreach ex,$(ALL_EXAMPLES),$(eval $(notdir $(ex:.c=)).SRCS += $(ex) examples.mk))
272 # Create build/install dependencies for all examples. The common case
273 # is handled here. The MSVS case is handled below.
274 NOT_MSVS = $(if $(CONFIG_MSVS),,yes)
275 DIST-BINS-$(NOT_MSVS) += $(addprefix bin/,$(ALL_EXAMPLES:.c=$(EXE_SFX)))
276 INSTALL-BINS-$(NOT_MSVS) += $(addprefix bin/,$(UTILS:.c=$(EXE_SFX)))
277 DIST-SRCS-yes += $(ALL_SRCS)
278 INSTALL-SRCS-yes += $(UTIL_SRCS)
279 OBJS-$(NOT_MSVS) += $(call objs,$(ALL_SRCS))
280 BINS-$(NOT_MSVS) += $(addprefix $(BUILD_PFX),$(ALL_EXAMPLES:.c=$(EXE_SFX)))
283 # Instantiate linker template for all examples.
284 CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx)
285 ifneq ($(filter darwin%,$(TGT_OS)),)
286 SHARED_LIB_SUF=.dylib
287 else
288 ifneq ($(filter os2%,$(TGT_OS)),)
289 SHARED_LIB_SUF=_dll.a
290 else
291 SHARED_LIB_SUF=.so
292 endif
293 endif
294 CODEC_LIB_SUF=$(if $(CONFIG_SHARED),$(SHARED_LIB_SUF),.a)
295 $(foreach bin,$(BINS-yes),\
296 $(eval $(bin):$(LIB_PATH)/lib$(CODEC_LIB)$(CODEC_LIB_SUF))\
297 $(eval $(call linker_template,$(bin),\
298 $(call objs,$($(notdir $(bin:$(EXE_SFX)=)).SRCS)) \
299 -l$(CODEC_LIB) $(addprefix -l,$(CODEC_EXTRA_LIBS))\
302 # The following pairs define a mapping of locations in the distribution
303 # tree to locations in the source/build trees.
304 INSTALL_MAPS += src/%.c %.c
305 INSTALL_MAPS += src/% $(SRC_PATH_BARE)/%
306 INSTALL_MAPS += bin/% %
307 INSTALL_MAPS += % %
310 # Set up additional MSVS environment
311 ifeq ($(CONFIG_MSVS),yes)
312 CODEC_LIB=$(if $(CONFIG_SHARED),vpx,$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd))
313 # This variable uses deferred expansion intentionally, since the results of
314 # $(wildcard) may change during the course of the Make.
315 VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d))))
316 INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),bin/$(p)/% $(p)/Release/%)
317 endif
319 # Build Visual Studio Projects. We use a template here to instantiate
320 # explicit rules rather than using an implicit rule because we want to
321 # leverage make's VPATH searching rather than specifying the paths on
322 # each file in ALL_EXAMPLES. This has the unfortunate side effect that
323 # touching the source files trigger a rebuild of the project files
324 # even though there is no real dependency there (the dependency is on
325 # the makefiles). We may want to revisit this.
326 define vcproj_template
327 $(1): $($(1:.$(VCPROJ_SFX)=).SRCS) vpx.$(VCPROJ_SFX)
328 $(if $(quiet),@echo " [vcproj] $$@")
329 $(qexec)$$(GEN_VCPROJ)\
330 --exe\
331 --target=$$(TOOLCHAIN)\
332 --name=$$(@:.$(VCPROJ_SFX)=)\
333 --ver=$$(CONFIG_VS_VERSION)\
334 --proj-guid=$$($$(@:.$(VCPROJ_SFX)=).GUID)\
335 --src-path-bare="$(SRC_PATH_BARE)" \
336 $$(if $$(CONFIG_STATIC_MSVCRT),--static-crt) \
337 --out=$$@ $$(INTERNAL_CFLAGS) $$(CFLAGS) \
338 $$(INTERNAL_LDFLAGS) $$(LDFLAGS) -l$$(CODEC_LIB) $$^
339 endef
340 ALL_EXAMPLES_BASENAME := $(notdir $(ALL_EXAMPLES))
341 PROJECTS-$(CONFIG_MSVS) += $(ALL_EXAMPLES_BASENAME:.c=.$(VCPROJ_SFX))
342 INSTALL-BINS-$(CONFIG_MSVS) += $(foreach p,$(VS_PLATFORMS),\
343 $(addprefix bin/$(p)/,$(ALL_EXAMPLES_BASENAME:.c=.exe)))
344 $(foreach proj,$(call enabled,PROJECTS),\
345 $(eval $(call vcproj_template,$(proj))))
348 # Documentation Rules
350 %.dox: %.c
351 @echo " [DOXY] $@"
352 @mkdir -p $(dir $@)
353 @echo "/*!\page example_$(@F:.dox=) $(@F:.dox=)" > $@
354 @echo " \includelineno $(<F)" >> $@
355 @echo "*/" >> $@
357 samples.dox: examples.mk
358 @echo " [DOXY] $@"
359 @echo "/*!\page samples Sample Code" > $@
360 @echo " This SDK includes a number of sample applications."\
361 "Each sample documents a feature of the SDK in both prose"\
362 "and the associated C code."\
363 "The following samples are included: ">>$@
364 @$(foreach ex,$(sort $(notdir $(EXAMPLES:.c=))),\
365 echo " - \subpage example_$(ex) $($(ex).DESCRIPTION)" >> $@;)
366 @echo >> $@
367 @echo " In addition, the SDK contains a number of utilities."\
368 "Since these utilities are built upon the concepts described"\
369 "in the sample code listed above, they are not documented in"\
370 "pieces like the samples are. Their source is included here"\
371 "for reference. The following utilities are included:" >> $@
372 @$(foreach ex,$(sort $(UTILS:.c=)),\
373 echo " - \subpage example_$(ex) $($(ex).DESCRIPTION)" >> $@;)
374 @echo "*/" >> $@
376 CLEAN-OBJS += examples.doxy samples.dox $(ALL_EXAMPLES:.c=.dox)
377 DOCS-yes += examples.doxy samples.dox
378 examples.doxy: samples.dox $(ALL_EXAMPLES:.c=.dox)
379 @echo "INPUT += $^" > $@