-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdocs.cmake
More file actions
292 lines (255 loc) · 11.7 KB
/
docs.cmake
File metadata and controls
292 lines (255 loc) · 11.7 KB
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
#
# Copyright (c) 2021, Alliance for Open Media. All rights reserved
#
# This source code is subject to the terms of the BSD 3-Clause Clear License and
# the Alliance for Open Media Patent License 1.0. If the BSD 3-Clause Clear
# License was not distributed with this source code in the LICENSE file, you can
# obtain it at aomedia.org/license/software-license/bsd-3-c-c/. If the Alliance
# for Open Media Patent License 1.0 was not distributed with this source code in
# the PATENTS file, you can obtain it at aomedia.org/license/patent-license/.
#
if(AVM_DOCS_CMAKE_)
return()
endif() # AVM_DOCS_CMAKE_
set(AVM_DOCS_CMAKE_ 1)
cmake_minimum_required(VERSION 3.16)
set(AVM_DOXYFILE "${AVM_CONFIG_DIR}/doxyfile")
set(AVM_DOXYGEN_CONFIG_TEMPLATE "libs.doxy_template")
set(AVM_DOXYGEN_OUTPUT_DIR "${AVM_CONFIG_DIR}/dox")
set(AVM_DOXYGEN_SECTIONS "av2")
set(AVM_DOXYGEN_SOURCES
"${AVM_ROOT}/avm/avm.h"
"${AVM_ROOT}/avm/avm_codec.h"
"${AVM_ROOT}/avm/avm_decoder.h"
"${AVM_ROOT}/avm/avm_encoder.h"
"${AVM_ROOT}/avm/avm_frame_buffer.h"
"${AVM_ROOT}/avm/avm_image.h"
"${AVM_ROOT}/avm/avm_integer.h"
"${AVM_ROOT}/av2/common/av2_common_int.h"
"${AVM_ROOT}/av2/common/av2_loopfilter.h"
"${AVM_ROOT}/av2/common/blockd.h"
"${AVM_ROOT}/av2/common/cdef.h"
"${AVM_ROOT}/av2/common/enums.h"
"${AVM_ROOT}/av2/common/restoration.h"
"${AVM_ROOT}/keywords.dox"
"${AVM_ROOT}/mainpage.dox"
"${AVM_ROOT}/usage.dox")
if(CONFIG_AV2_DECODER)
set(AVM_DOXYGEN_EXAMPLE_SOURCES
${AVM_DOXYGEN_EXAMPLE_SOURCES}
"${AVM_ROOT}/apps/avmdec.c"
"${AVM_ROOT}/examples/decode_to_md5.c"
"${AVM_ROOT}/examples/decode_with_drops.c"
"${AVM_ROOT}/examples/simple_decoder.c")
set(AVM_DOXYGEN_EXAMPLE_DESCRIPTIONS
${AVM_DOXYGEN_EXAMPLE_DESCRIPTIONS} "Full featured decoder."
"Frame by frame MD5 checksum." "Drops frames while decoding."
"Simplified decoder loop.")
set(AVM_DOXYGEN_SECTIONS ${AVM_DOXYGEN_SECTIONS} "av2_decoder decoder")
set(AVM_DOXYGEN_SOURCES
${AVM_DOXYGEN_SOURCES} "${AVM_ROOT}/avm/avmdx.h"
"${AVM_ROOT}/usage_dx.dox" "${AVM_ROOT}/av2/decoder/decoder.h")
if(CONFIG_INSPECTION)
set(AVM_DOXYGEN_EXAMPLE_SOURCES ${AVM_DOXYGEN_EXAMPLE_SOURCES}
"${AVM_ROOT}/examples/inspect.c")
set(AVM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${AVM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
"Bitstream inspector.")
endif()
set(AVM_DOXYGEN_SOURCES ${AVM_DOXYGEN_SOURCES}
"${AVM_ROOT}/doc/dev_guide/av2_decoder.dox")
endif()
if(CONFIG_AV2_ENCODER)
set(AVM_DOXYGEN_EXAMPLE_SOURCES
${AVM_DOXYGEN_EXAMPLE_SOURCES}
"${AVM_ROOT}/apps/avmenc.c"
"${AVM_ROOT}/examples/lossless_encoder.c"
"${AVM_ROOT}/examples/set_maps.c"
"${AVM_ROOT}/examples/simple_encoder.c"
"${AVM_ROOT}/examples/twopass_encoder.c")
set(AVM_DOXYGEN_EXAMPLE_DESCRIPTIONS
${AVM_DOXYGEN_EXAMPLE_DESCRIPTIONS} "Full featured encoder."
"Simplified lossless encoder." "Set active and ROI maps."
"Simplified encoder loop." "Two-pass encoder loop.")
set(AVM_DOXYGEN_EXAMPLE_SOURCES ${AVM_DOXYGEN_EXAMPLE_SOURCES}
"${AVM_ROOT}/examples/scalable_encoder.c")
set(AVM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${AVM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
"Scalable encoder loop.")
set(AVM_DOXYGEN_SECTIONS ${AVM_DOXYGEN_SECTIONS} "av2_encoder encoder")
set(AVM_DOXYGEN_SOURCES ${AVM_DOXYGEN_SOURCES} "${AVM_ROOT}/avm/avmcx.h"
"${AVM_ROOT}/usage_cx.dox")
set(AVM_DOXYGEN_SOURCES ${AVM_DOXYGEN_SOURCES}
"${AVM_ROOT}/doc/dev_guide/av2_encoder.dox")
set(AVM_DOXYGEN_SOURCES
${AVM_DOXYGEN_SOURCES}
"${AVM_ROOT}/avm_scale/yv12config.h"
"${AVM_ROOT}/av2/encoder/bitstream.h"
"${AVM_ROOT}/av2/encoder/block.h"
"${AVM_ROOT}/av2/encoder/aq_cyclicrefresh.h"
"${AVM_ROOT}/av2/encoder/encode_strategy.c"
"${AVM_ROOT}/av2/encoder/encode_strategy.h"
"${AVM_ROOT}/av2/encoder/encodeframe.c"
"${AVM_ROOT}/av2/encoder/encoder.c"
"${AVM_ROOT}/av2/encoder/encoder.h"
"${AVM_ROOT}/av2/encoder/encodetxb.h"
"${AVM_ROOT}/av2/encoder/firstpass.h"
"${AVM_ROOT}/av2/encoder/gop_structure.h"
"${AVM_ROOT}/av2/encoder/interp_search.c"
"${AVM_ROOT}/av2/encoder/intra_mode_search.h"
"${AVM_ROOT}/av2/encoder/intra_mode_search.c"
"${AVM_ROOT}/av2/encoder/intra_mode_search_utils.h"
"${AVM_ROOT}/av2/encoder/lookahead.h"
"${AVM_ROOT}/av2/encoder/palette.h"
"${AVM_ROOT}/av2/encoder/palette.c"
"${AVM_ROOT}/av2/encoder/partition_search.h"
"${AVM_ROOT}/av2/encoder/partition_search.c"
"${AVM_ROOT}/av2/encoder/pass2_strategy.h"
"${AVM_ROOT}/av2/encoder/pass2_strategy.c"
"${AVM_ROOT}/av2/encoder/pickcdef.h"
"${AVM_ROOT}/av2/encoder/picklpf.h"
"${AVM_ROOT}/av2/encoder/pickrst.h"
"${AVM_ROOT}/av2/encoder/ratectrl.c"
"${AVM_ROOT}/av2/encoder/ratectrl.h"
"${AVM_ROOT}/av2/encoder/rc_utils.h"
"${AVM_ROOT}/av2/encoder/rdopt.h"
"${AVM_ROOT}/av2/encoder/rdopt.c"
"${AVM_ROOT}/av2/encoder/speed_features.h"
"${AVM_ROOT}/av2/encoder/temporal_filter.h"
"${AVM_ROOT}/av2/encoder/temporal_filter.c"
"${AVM_ROOT}/av2/encoder/tpl_model.h"
"${AVM_ROOT}/av2/encoder/tx_search.h")
endif()
if(CONFIG_AV2_DECODER AND CONFIG_AV2_ENCODER)
set(AVM_DOXYGEN_EXAMPLE_SOURCES ${AVM_DOXYGEN_EXAMPLE_SOURCES}
"${AVM_ROOT}/examples/avm_cx_set_ref.c")
set(AVM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${AVM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
"Set encoder reference frame.")
endif()
# Iterates over list named by $list_name and appends each item to $AVM_DOXYFILE
# as values assigned to $var_name with no line breaks between list items.
# Appends a new line after the entire config variable is expanded.
function(write_cmake_list_to_doxygen_config_var var_name list_name)
unset(output_string)
foreach(list_item ${${list_name}})
set(output_string "${output_string} ${list_item} ")
endforeach()
string(STRIP "${output_string}" output_string)
file(APPEND "${AVM_DOXYFILE}" "${var_name} += ${output_string}\n")
endfunction()
function(get_name file_path name_var)
get_filename_component(file_basename ${file_path} NAME)
get_filename_component(${name_var} ${file_basename} NAME_WE)
set(${name_var}
${${name_var}}
PARENT_SCOPE)
endfunction()
function(setup_documentation_targets)
# Sanity check: the lengths of these lists must match.
list(LENGTH AVM_DOXYGEN_EXAMPLE_SOURCES num_sources)
list(LENGTH AVM_DOXYGEN_EXAMPLE_DESCRIPTIONS num_descs)
if(NOT ${num_sources} EQUAL ${num_descs})
message(FATAL_ERROR "Unqeual example and description totals.")
endif()
# Take the list of examples and produce example_basename.dox for each file in
# the list.
file(MAKE_DIRECTORY "${AVM_DOXYGEN_OUTPUT_DIR}")
foreach(example_file ${AVM_DOXYGEN_EXAMPLE_SOURCES})
unset(example_basename)
get_name("${example_file}" "example_name")
set(example_dox "${AVM_DOXYGEN_OUTPUT_DIR}/${example_name}.dox")
set(dox_string "/*!\\page example_${example_name} ${example_name}\n")
set(dox_string "${dox_string} \\includelineno ${example_file}\n*/\n")
file(WRITE "${example_dox}" ${dox_string})
set(AVM_DOXYGEN_SOURCES ${AVM_DOXYGEN_SOURCES} "${example_dox}")
endforeach()
# Generate samples.dox, an index page that refers to the example_basename.dox
# files that were just created.
set(samples_header
"
/*!\\page samples Sample Code
This SDK includes a number of sample applications. Each sample documents a
feature of the SDK in both prose and the associated C code. The following
samples are included:
")
set(utils_desc
"
In addition, the SDK contains a number of utilities. Since these utilities are
built upon the concepts described in the sample code listed above, they are not
documented in pieces like the samples are. Their source is included here for
reference. The following utilities are included:
")
# Write the description for the samples section.
set(samples_dox "${AVM_CONFIG_DIR}/samples.dox")
file(WRITE "${samples_dox}" "${samples_header}\n")
# Iterate over $AVM_DOXYGEN_EXAMPLE_SOURCES and
# $AVM_DOXYGEN_EXAMPLE_DESCRIPTIONS and massage example names as required by
# AV2's doxygen setup.
math(EXPR max_example_index "${num_sources} - 1")
foreach(NUM RANGE ${max_example_index})
list(GET AVM_DOXYGEN_EXAMPLE_SOURCES ${NUM} ex_name)
get_name("${ex_name}" "ex_name")
# AV2's doxygen lists avmdec and avmenc as utils apart from the examples.
# Save the indexes for another pass.
if("${ex_name}" MATCHES "avmdec\|avmenc")
set(util_indexes "${util_indexes}" "${NUM}")
continue()
endif()
list(GET AVM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${NUM} ex_desc)
file(APPEND "${samples_dox}" " - \\subpage example_${ex_name} ${ex_desc}\n")
endforeach()
# Write the description and index for the utils.
file(APPEND "${samples_dox}" "${utils_desc}\n")
foreach(util_index ${util_indexes})
list(GET AVM_DOXYGEN_EXAMPLE_SOURCES ${util_index} ex_name)
get_name("${ex_name}" "ex_name")
list(GET AVM_DOXYGEN_EXAMPLE_DESCRIPTIONS ${util_index} ex_desc)
file(APPEND "${samples_dox}" " - \\subpage example_${ex_name} ${ex_desc}\n")
endforeach()
file(APPEND "${samples_dox}" "*/")
# Add $samples_dox to the doxygen inputs.
get_filename_component(samples_dox ${samples_dox} NAME)
set(AVM_DOXYGEN_SOURCES ${AVM_DOXYGEN_SOURCES} ${samples_dox})
# There are issues to show Markdown file for old Doxygen version. Here, only
# enable Markdown support for 1.8.16 or newer.
if(${DOXYGEN_VERSION_VALUE} GREATER_EQUAL 1008016)
set(AVM_DOXYGEN_SECTIONS ${AVM_DOXYGEN_SECTIONS} "av2_md_support")
set(AVM_DOXYGEN_SOURCES ${AVM_DOXYGEN_SOURCES} "${AVM_ROOT}/README.md")
# Uncomment and add AlgorithmDescription.md in result page when it is done.
# set(AVM_DOXYGEN_SOURCES ${AVM_DOXYGEN_SOURCES}
# "${AVM_ROOT}/doc/AlgorithmDescription.md")
endif()
# Generate libavm's doxyfile.
file(WRITE "${AVM_DOXYFILE}" "##\n## GENERATED FILE. DO NOT EDIT\n##\n")
file(READ "${AVM_ROOT}/${AVM_DOXYGEN_CONFIG_TEMPLATE}" doxygen_template_data)
file(APPEND "${AVM_DOXYFILE}" ${doxygen_template_data})
file(APPEND "${AVM_DOXYFILE}"
"EXAMPLE_PATH += ${AVM_ROOT} ${AVM_ROOT}/examples\n")
file(APPEND "${AVM_DOXYFILE}"
"INCLUDE_PATH += ${AVM_CONFIG_DIR} ${AVM_ROOT}\n")
file(APPEND "${AVM_DOXYFILE}"
"STRIP_FROM_PATH += ${AVM_ROOT} ${AVM_CONFIG_DIR}\n")
write_cmake_list_to_doxygen_config_var("INPUT" "AVM_DOXYGEN_SOURCES")
write_cmake_list_to_doxygen_config_var("ENABLED_SECTIONS"
"AVM_DOXYGEN_SECTIONS")
# Add AOMedia logo.
set(avm_logo "aomedia_logo_200.png")
configure_file(${AVM_ROOT}/${avm_logo} ${AVM_CONFIG_DIR}/${avm_logo} COPYONLY)
file(APPEND "${AVM_DOXYFILE}"
"PROJECT_LOGO = ${AVM_CONFIG_DIR}/${avm_logo}\n")
# Only set HAVE_DOT to YES if dot tool is found.
if(DOXYGEN_DOT_FOUND)
file(APPEND "${AVM_DOXYFILE}" "HAVE_DOT = YES\n")
file(APPEND "${AVM_DOXYFILE}" "DOT_GRAPH_MAX_NODES = 10000\n")
endif()
# Add image path.
file(APPEND "${AVM_DOXYFILE}" "IMAGE_PATH += ${AVM_ROOT}/doc/dev_guide\n")
# Allow banner style comments
file(APPEND "${AVM_DOXYFILE}" "JAVADOC_BANNER = YES")
# Add the doxygen generation rule.
add_custom_target(
docs ALL
COMMAND "${DOXYGEN_EXECUTABLE}" "${AVM_DOXYFILE}"
DEPENDS "${AVM_DOXYFILE}" ${AVM_DOXYGEN_SOURCES}
${AVM_DOXYGEN_EXAMPLE_SOURCES} "${AVM_DOXYGEN_CONFIG_TEMPLATE}"
SOURCES "${AVM_DOXYFILE}" ${AVM_DOXYGEN_SOURCES}
${AVM_DOXYGEN_EXAMPLE_SOURCES} "${AVM_DOXYGEN_CONFIG_TEMPLATE}")
endfunction()