]> granicus.if.org Git - libvpx/blob - examples.mk
Merge "Constrain encoder motion search range"
[libvpx] / examples.mk
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 ##
10
11 LIBYUV_SRCS +=  third_party/libyuv/include/libyuv/basic_types.h  \
12                 third_party/libyuv/include/libyuv/cpu_id.h  \
13                 third_party/libyuv/include/libyuv/scale.h  \
14                 third_party/libyuv/source/row.h \
15                 third_party/libyuv/source/scale.c  \
16                 third_party/libyuv/source/cpu_id.c
17
18 # List of examples to build. UTILS are files that are taken from the source
19 # tree directly, and GEN_EXAMPLES are files that are created from the
20 # examples folder.
21 UTILS-$(CONFIG_DECODERS)    += vpxdec.c
22 vpxdec.SRCS                 += md5_utils.c md5_utils.h
23 vpxdec.SRCS                 += vpx_ports/vpx_timer.h
24 vpxdec.SRCS                 += vpx/vpx_integer.h
25 vpxdec.SRCS                 += args.c args.h
26 vpxdec.SRCS                 += ivfdec.c ivfdec.h
27 vpxdec.SRCS                 += tools_common.c tools_common.h
28 vpxdec.SRCS                 += nestegg/halloc/halloc.h
29 vpxdec.SRCS                 += nestegg/halloc/src/align.h
30 vpxdec.SRCS                 += nestegg/halloc/src/halloc.c
31 vpxdec.SRCS                 += nestegg/halloc/src/hlist.h
32 vpxdec.SRCS                 += nestegg/halloc/src/macros.h
33 vpxdec.SRCS                 += nestegg/include/nestegg/nestegg.h
34 vpxdec.SRCS                 += nestegg/src/nestegg.c
35 vpxdec.SRCS                 += $(LIBYUV_SRCS)
36 vpxdec.GUID                  = BA5FE66F-38DD-E034-F542-B1578C5FB950
37 vpxdec.DESCRIPTION           = Full featured decoder
38 UTILS-$(CONFIG_ENCODERS)    += vpxenc.c
39 vpxenc.SRCS                 += args.c args.h y4minput.c y4minput.h
40 vpxenc.SRCS                 += ivfdec.c ivfdec.h
41 vpxenc.SRCS                 += ivfenc.c ivfenc.h
42 vpxenc.SRCS                 += tools_common.c tools_common.h
43 vpxenc.SRCS                 += webmenc.c webmenc.h
44 vpxenc.SRCS                 += vpx_ports/mem_ops.h
45 vpxenc.SRCS                 += vpx_ports/mem_ops_aligned.h
46 vpxenc.SRCS                 += vpx_ports/vpx_timer.h
47 vpxenc.SRCS                 += vpxstats.c vpxstats.h
48 vpxenc.SRCS                 += third_party/libmkv/EbmlIDs.h
49 vpxenc.SRCS                 += third_party/libmkv/EbmlWriter.c
50 vpxenc.SRCS                 += third_party/libmkv/EbmlWriter.h
51 vpxenc.SRCS                 += $(LIBYUV_SRCS)
52 vpxenc.GUID                  = 548DEC74-7A15-4B2B-AFC3-AA102E7C25C1
53 vpxenc.DESCRIPTION           = Full featured encoder
54 UTILS-$(CONFIG_VP8_ENCODER)    += vp8_scalable_patterns.c
55 vp8_scalable_patterns.GUID   = 0D6A210B-F482-4D6F-8570-4A9C01ACC88C
56 vp8_scalable_patterns.DESCRIPTION = Temporal Scalability Encoder
57 UTILS-$(CONFIG_VP9_ENCODER)    += vp9_spatial_scalable_encoder.c
58 vp9_spatial_scalable_encoder.SRCS += args.c args.h
59 vp9_spatial_scalable_encoder.SRCS += ivfenc.c ivfenc.h
60 vp9_spatial_scalable_encoder.SRCS += tools_common.c tools_common.h
61 vp9_spatial_scalable_encoder.GUID   = 4A38598D-627D-4505-9C7B-D4020C84100D
62 vp9_spatial_scalable_encoder.DESCRIPTION = Spatial Scalable Encoder
63
64 # XMA example disabled for now, not used in VP8
65 #UTILS-$(CONFIG_DECODERS)    += example_xma.c
66 #example_xma.GUID             = A955FC4A-73F1-44F7-135E-30D84D32F022
67 #example_xma.DESCRIPTION      = External Memory Allocation mode usage
68
69 GEN_EXAMPLES-$(CONFIG_VP8_DECODER) += simple_decoder.c
70 simple_decoder.GUID              = D3BBF1E9-2427-450D-BBFF-B2843C1D44CC
71 simple_decoder.DESCRIPTION       = Simplified decoder loop
72 GEN_EXAMPLES-$(CONFIG_VP8_DECODER) += postproc.c
73 postproc.GUID                    = 65E33355-F35E-4088-884D-3FD4905881D7
74 postproc.DESCRIPTION             = Decoder postprocessor control
75 GEN_EXAMPLES-$(CONFIG_VP8_DECODER) += decode_to_md5.c
76 decode_to_md5.SRCS              += md5_utils.h md5_utils.c
77 decode_to_md5.GUID               = 59120B9B-2735-4BFE-B022-146CA340FE42
78 decode_to_md5.DESCRIPTION        = Frame by frame MD5 checksum
79
80 GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += simple_encoder.c
81 simple_encoder.GUID              = 4607D299-8A71-4D2C-9B1D-071899B6FBFD
82 simple_encoder.DESCRIPTION       = Simplified encoder loop
83 GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += twopass_encoder.c
84 twopass_encoder.GUID             = 73494FA6-4AF9-4763-8FBB-265C92402FD8
85 twopass_encoder.DESCRIPTION      = Two-pass encoder loop
86 GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += force_keyframe.c
87 force_keyframe.GUID              = 3C67CADF-029F-4C86-81F5-D6D4F51177F0
88 force_keyframe.DESCRIPTION       = Force generation of keyframes
89 ifeq ($(CONFIG_DECODERS),yes)
90 GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += decode_with_drops.c
91 endif
92 decode_with_drops.GUID           = CE5C53C4-8DDA-438A-86ED-0DDD3CDB8D26
93 decode_with_drops.DESCRIPTION    = Drops frames while decoding
94 ifeq ($(CONFIG_VP8_DECODER),yes)
95 GEN_EXAMPLES-$(CONFIG_ERROR_CONCEALMENT) += decode_with_partial_drops.c
96 endif
97 decode_with_partial_drops.GUID           = 61C2D026-5754-46AC-916F-1343ECC5537E
98 decode_with_partial_drops.DESCRIPTION    = Drops parts of frames while decoding
99 GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += error_resilient.c
100 error_resilient.GUID             = DF5837B9-4145-4F92-A031-44E4F832E00C
101 error_resilient.DESCRIPTION      = Error Resiliency Feature
102
103 GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += vp8_set_maps.c
104 vp8_set_maps.GUID                   = ECB2D24D-98B8-4015-A465-A4AF3DCC145F
105 vp8_set_maps.DESCRIPTION            = VP8 set active and ROI maps
106 GEN_EXAMPLES-$(CONFIG_VP8_ENCODER) += vp8cx_set_ref.c
107 vp8cx_set_ref.GUID                  = C5E31F7F-96F6-48BD-BD3E-10EBF6E8057A
108 vp8cx_set_ref.DESCRIPTION           = VP8 set encoder reference frame
109
110 # C file is provided, not generated automatically.
111 UTILS-$(CONFIG_MULTI_RES_ENCODING) += vp8_multi_resolution_encoder.c
112 vp8_multi_resolution_encoder.SRCS         += $(LIBYUV_SRCS)
113 vp8_multi_resolution_encoder.GUID         = 04f8738e-63c8-423b-90fa-7c2703a374de
114 vp8_multi_resolution_encoder.DESCRIPTION  = VP8 Multiple-resolution Encoding
115
116 # Handle extra library flags depending on codec configuration
117
118 # We should not link to math library (libm) on RVCT
119 # when building for bare-metal targets
120 ifeq ($(CONFIG_OS_SUPPORT), yes)
121 CODEC_EXTRA_LIBS-$(CONFIG_VP8)         += m
122 CODEC_EXTRA_LIBS-$(CONFIG_VP9)         += m
123 else
124     ifeq ($(CONFIG_GCC), yes)
125     CODEC_EXTRA_LIBS-$(CONFIG_VP8)         += m
126     CODEC_EXTRA_LIBS-$(CONFIG_VP9)         += m
127     endif
128 endif
129 #
130 # End of specified files. The rest of the build rules should happen
131 # automagically from here.
132 #
133
134
135 # Examples need different flags based on whether we're building
136 # from an installed tree or a version controlled tree. Determine
137 # the proper paths.
138 ifeq ($(HAVE_ALT_TREE_LAYOUT),yes)
139     LIB_PATH := $(SRC_PATH_BARE)/../lib
140     INC_PATH := $(SRC_PATH_BARE)/../include
141 else
142     LIB_PATH-yes                     += $(if $(BUILD_PFX),$(BUILD_PFX),.)
143     INC_PATH-$(CONFIG_VP8_DECODER)   += $(SRC_PATH_BARE)/vp8
144     INC_PATH-$(CONFIG_VP8_ENCODER)   += $(SRC_PATH_BARE)/vp8
145     INC_PATH-$(CONFIG_VP9_DECODER)   += $(SRC_PATH_BARE)/vp9
146     INC_PATH-$(CONFIG_VP9_ENCODER)   += $(SRC_PATH_BARE)/vp9
147     LIB_PATH := $(call enabled,LIB_PATH)
148     INC_PATH := $(call enabled,INC_PATH)
149 endif
150 INTERNAL_CFLAGS = $(addprefix -I,$(INC_PATH))
151 INTERNAL_LDFLAGS += $(addprefix -L,$(LIB_PATH))
152
153
154 # Expand list of selected examples to build (as specified above)
155 UTILS           = $(call enabled,UTILS)
156 GEN_EXAMPLES    = $(call enabled,GEN_EXAMPLES)
157 ALL_EXAMPLES    = $(UTILS) $(GEN_EXAMPLES)
158 UTIL_SRCS       = $(foreach ex,$(UTILS),$($(ex:.c=).SRCS))
159 ALL_SRCS        = $(foreach ex,$(ALL_EXAMPLES),$($(ex:.c=).SRCS))
160 CODEC_EXTRA_LIBS=$(sort $(call enabled,CODEC_EXTRA_LIBS))
161
162
163 # Expand all example sources into a variable containing all sources
164 # for that example (not just them main one specified in UTILS/GEN_EXAMPLES)
165 # and add this file to the list (for MSVS workspace generation)
166 $(foreach ex,$(ALL_EXAMPLES),$(eval $(ex:.c=).SRCS += $(ex) examples.mk))
167
168
169 # If this is a universal (fat) binary, then all the subarchitectures have
170 # already been built and our job is to stitch them together. The
171 # BUILD_OBJS variable indicates whether we should be building
172 # (compiling, linking) the library. The LIPO_OBJS variable indicates
173 # that we're stitching.
174 $(eval $(if $(filter universal%,$(TOOLCHAIN)),LIPO_OBJS,BUILD_OBJS):=yes)
175
176
177 # Create build/install dependencies for all examples. The common case
178 # is handled here. The MSVS case is handled below.
179 NOT_MSVS = $(if $(CONFIG_MSVS),,yes)
180 DIST-BINS-$(NOT_MSVS)      += $(addprefix bin/,$(ALL_EXAMPLES:.c=$(EXE_SFX)))
181 INSTALL-BINS-$(NOT_MSVS)   += $(addprefix bin/,$(UTILS:.c=$(EXE_SFX)))
182 DIST-SRCS-yes              += $(ALL_SRCS)
183 INSTALL-SRCS-yes           += $(UTIL_SRCS)
184 OBJS-$(NOT_MSVS)           += $(if $(BUILD_OBJS),$(call objs,$(ALL_SRCS)))
185 BINS-$(NOT_MSVS)           += $(addprefix $(BUILD_PFX),$(ALL_EXAMPLES:.c=$(EXE_SFX)))
186
187
188 # Instantiate linker template for all examples.
189 CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx)
190 SHARED_LIB_SUF=$(if $(filter darwin%,$(TGT_OS)),.dylib,.so)
191 CODEC_LIB_SUF=$(if $(CONFIG_SHARED),$(SHARED_LIB_SUF),.a)
192 $(foreach bin,$(BINS-yes),\
193     $(if $(BUILD_OBJS),$(eval $(bin):\
194         $(LIB_PATH)/lib$(CODEC_LIB)$(CODEC_LIB_SUF)))\
195     $(if $(BUILD_OBJS),$(eval $(call linker_template,$(bin),\
196         $(call objs,$($(notdir $(bin:$(EXE_SFX)=)).SRCS)) \
197         -l$(CODEC_LIB) $(addprefix -l,$(CODEC_EXTRA_LIBS))\
198         )))\
199     $(if $(LIPO_OBJS),$(eval $(call lipo_bin_template,$(bin))))\
200     )
201
202
203 # Rules to generate the GEN_EXAMPLES sources
204 .PRECIOUS: %.c
205 CLEAN-OBJS += $(GEN_EXAMPLES)
206 %.c: examples/%.txt
207         @echo "    [EXAMPLE] $@"
208         @$(SRC_PATH_BARE)/examples/gen_example_code.sh $< > $@
209
210
211 # The following pairs define a mapping of locations in the distribution
212 # tree to locations in the source/build trees.
213 INSTALL_MAPS += src/%.c   %.c
214 INSTALL_MAPS += src/%     $(SRC_PATH_BARE)/%
215 INSTALL_MAPS += bin/%     %
216 INSTALL_MAPS += %         %
217
218
219 # Set up additional MSVS environment
220 ifeq ($(CONFIG_MSVS),yes)
221 CODEC_LIB=$(if $(CONFIG_SHARED),vpx,$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd))
222 # This variable uses deferred expansion intentionally, since the results of
223 # $(wildcard) may change during the course of the Make.
224 VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d))))
225 INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),bin/$(p)/%  $(p)/Release/%)
226 endif
227
228 # Build Visual Studio Projects. We use a template here to instantiate
229 # explicit rules rather than using an implicit rule because we want to
230 # leverage make's VPATH searching rather than specifying the paths on
231 # each file in ALL_EXAMPLES. This has the unfortunate side effect that
232 # touching the source files trigger a rebuild of the project files
233 # even though there is no real dependency there (the dependency is on
234 # the makefiles). We may want to revisit this.
235 define vcproj_template
236 $(1): $($(1:.$(VCPROJ_SFX)=).SRCS) vpx.$(VCPROJ_SFX)
237         @echo "    [vcproj] $$@"
238         $$(GEN_VCPROJ)\
239             --exe\
240             --target=$$(TOOLCHAIN)\
241             --name=$$(@:.$(VCPROJ_SFX)=)\
242             --ver=$$(CONFIG_VS_VERSION)\
243             --proj-guid=$$($$(@:.$(VCPROJ_SFX)=).GUID)\
244             $$(if $$(CONFIG_STATIC_MSVCRT),--static-crt) \
245             --out=$$@ $$(INTERNAL_CFLAGS) $$(CFLAGS) \
246             $$(INTERNAL_LDFLAGS) $$(LDFLAGS) -l$$(CODEC_LIB) $$^
247 endef
248 PROJECTS-$(CONFIG_MSVS) += $(ALL_EXAMPLES:.c=.$(VCPROJ_SFX))
249 INSTALL-BINS-$(CONFIG_MSVS) += $(foreach p,$(VS_PLATFORMS),\
250                                $(addprefix bin/$(p)/,$(ALL_EXAMPLES:.c=.exe)))
251 $(foreach proj,$(call enabled,PROJECTS),\
252     $(eval $(call vcproj_template,$(proj))))
253
254
255
256 #
257 # Documentation Rules
258 #
259 %.dox: examples/%.txt
260         @echo "    [DOXY] $@"
261         @$(SRC_PATH_BARE)/examples/gen_example_text.sh $< | \
262          $(SRC_PATH_BARE)/examples/gen_example_doxy.php \
263              example_$(@:.dox=)  $(@:.dox=.c) > $@
264
265 %.dox: %.c
266         @echo "    [DOXY] $@"
267         @echo "/*!\page example_$(@:.dox=) $(@:.dox=)" > $@
268         @echo "   \includelineno $(notdir $<)" >> $@
269         @echo "*/" >> $@
270
271 samples.dox: examples.mk
272         @echo "    [DOXY] $@"
273         @echo "/*!\page samples Sample Code" > $@
274         @echo "    This SDK includes a number of sample applications."\
275               "each sample documents a feature of the SDK in both prose"\
276               "and the associated C code. In general, later samples"\
277               "build upon prior samples, so it is best to work through the"\
278               "list in order. The following samples are included: ">>$@
279         @$(foreach ex,$(GEN_EXAMPLES:.c=),\
280            echo "     - \subpage example_$(ex) $($(ex).DESCRIPTION)" >> $@;)
281         @echo >> $@
282         @echo "    In addition, the SDK contains a number of utilities."\
283               "Since these utilities are built upon the concepts described"\
284               "in the sample code listed above, they are not documented in"\
285               "pieces like the samples are. Thir sourcre is included here"\
286               "for reference. The following utilities are included:" >> $@
287         @$(foreach ex,$(UTILS:.c=),\
288            echo "     - \subpage example_$(ex) $($(ex).DESCRIPTION)" >> $@;)
289         @echo "*/" >> $@
290
291 CLEAN-OBJS += examples.doxy samples.dox $(ALL_EXAMPLES:.c=.dox)
292 DOCS-yes += examples.doxy samples.dox $(ALL_EXAMPLES:.c=.dox)
293 examples.doxy: samples.dox $(ALL_EXAMPLES:.c=.dox)
294         @echo "INPUT += $^" > $@