xref: /aosp_15_r20/external/libhevc/Android.bp (revision c83a76b084498d55f252f48b2e3786804cdf24b7)
1package {
2    default_applicable_licenses: ["external_libhevc_license"],
3}
4
5// Added automatically by a large-scale-change
6// See: http://go/android-license-faq
7license {
8    name: "external_libhevc_license",
9    visibility: [":__subpackages__"],
10    license_kinds: [
11        "SPDX-license-identifier-Apache-2.0",
12    ],
13    license_text: [
14        "NOTICE",
15    ],
16}
17
18cc_library_headers {
19    name: "libhevcdec_headers",
20    export_include_dirs: [
21        "common",
22        "decoder",
23    ],
24    min_sdk_version: "29",
25}
26
27cc_library_headers {
28    name: "libhevcenc_headers",
29    export_include_dirs: [
30        "common",
31        "encoder",
32    ],
33    min_sdk_version: "29",
34}
35
36cc_library_static {
37    name: "libhevcdec",
38    vendor_available: true,
39    host_supported: true,
40
41    cflags: [
42        "-D_LIB",
43        "-fPIC",
44
45        "-O3",
46        "-DANDROID",
47        "-DDISABLE_SEI",
48        "-Wall",
49        "-Werror",
50        // common/x86/ihevc_sao_ssse3_intr.c: implicit conversion from
51        // 'int' to 'char' changes value from 128 to -128
52        "-Wno-error=constant-conversion",
53        // #KEEP_THREAD_ACTIVE is experimental
54        "-UKEEP_THREADS_ACTIVE",
55    ],
56
57    export_include_dirs: [
58        "common",
59        "decoder",
60    ],
61
62    srcs: [
63        "common/ihevc_buf_mgr.c",
64        "common/ihevc_cabac_tables.c",
65        "common/ihevc_chroma_intra_pred_filters.c",
66        "common/ihevc_chroma_iquant_itrans_recon.c",
67        "common/ihevc_chroma_iquant_recon.c",
68        "common/ihevc_chroma_itrans_recon.c",
69        "common/ihevc_chroma_itrans_recon_16x16.c",
70        "common/ihevc_chroma_itrans_recon_8x8.c",
71        "common/ihevc_chroma_recon.c",
72        "common/ihevc_common_tables.c",
73        "common/ihevc_deblk_edge_filter.c",
74        "common/ihevc_deblk_tables.c",
75        "common/ihevc_disp_mgr.c",
76        "common/ihevc_dpb_mgr.c",
77        "common/ihevc_inter_pred_filters.c",
78        "common/ihevc_intra_pred_filters.c",
79        "common/ihevc_iquant_itrans_recon.c",
80        "common/ihevc_iquant_recon.c",
81        "common/ihevc_itrans.c",
82        "common/ihevc_itrans_recon.c",
83        "common/ihevc_itrans_recon_16x16.c",
84        "common/ihevc_itrans_recon_32x32.c",
85        "common/ihevc_itrans_recon_8x8.c",
86        "common/ihevc_mem_fns.c",
87        "common/ihevc_padding.c",
88        "common/ihevc_quant_tables.c",
89        "common/ihevc_recon.c",
90        "common/ihevc_sao.c",
91        "common/ihevc_trans_tables.c",
92        "common/ihevc_weighted_pred.c",
93        "common/ithread.c",
94        "decoder/ihevcd_api.c",
95        "decoder/ihevcd_bitstream.c",
96        "decoder/ihevcd_boundary_strength.c",
97        "decoder/ihevcd_cabac.c",
98        "decoder/ihevcd_common_tables.c",
99        "decoder/ihevcd_deblk.c",
100        "decoder/ihevcd_decode.c",
101        "decoder/ihevcd_fmt_conv.c",
102        "decoder/ihevcd_get_mv.c",
103        "decoder/ihevcd_ilf_padding.c",
104        "decoder/ihevcd_inter_pred.c",
105        "decoder/ihevcd_intra_pred_mode_prediction.c",
106        "decoder/ihevcd_iquant_itrans_recon_ctb.c",
107        "decoder/ihevcd_itrans_recon_dc.c",
108        "decoder/ihevcd_job_queue.c",
109        "decoder/ihevcd_mv_merge.c",
110        "decoder/ihevcd_mv_pred.c",
111        "decoder/ihevcd_nal.c",
112        "decoder/ihevcd_parse_headers.c",
113        "decoder/ihevcd_parse_residual.c",
114        "decoder/ihevcd_parse_slice.c",
115        "decoder/ihevcd_parse_slice_header.c",
116        "decoder/ihevcd_process_slice.c",
117        "decoder/ihevcd_ref_list.c",
118        "decoder/ihevcd_sao.c",
119        "decoder/ihevcd_utils.c",
120        "decoder/ihevcd_version.c",
121    ],
122
123    arch: {
124        arm64: {
125            cflags: [
126                "-DARMV8",
127                "-DDISABLE_NEONINTR",
128                "-DARM",
129                "-DARMGCC",
130
131                "-DDEFAULT_ARCH=D_ARCH_ARMV8_GENERIC",
132            ],
133            local_include_dirs: [
134                "common/arm",
135                "common/arm64",
136                "decoder/arm",
137                "decoder/arm64",
138            ],
139
140            srcs: [
141                "common/arm/ihevc_intra_pred_filters_neon_intr.c",
142                "common/arm/ihevc_weighted_pred_neon_intr.c",
143                "common/arm64/ihevc_deblk_chroma_horz.s",
144                "common/arm64/ihevc_deblk_chroma_vert.s",
145                "common/arm64/ihevc_deblk_luma_horz.s",
146                "common/arm64/ihevc_deblk_luma_vert.s",
147                "common/arm64/ihevc_inter_pred_chroma_copy.s",
148                "common/arm64/ihevc_inter_pred_chroma_copy_w16out.s",
149                "common/arm64/ihevc_inter_pred_chroma_horz.s",
150                "common/arm64/ihevc_inter_pred_chroma_horz_w16out.s",
151                "common/arm64/ihevc_inter_pred_chroma_vert.s",
152                "common/arm64/ihevc_inter_pred_chroma_vert_w16inp.s",
153                "common/arm64/ihevc_inter_pred_chroma_vert_w16inp_w16out.s",
154                "common/arm64/ihevc_inter_pred_chroma_vert_w16out.s",
155                "common/arm64/ihevc_inter_pred_filters_luma_horz.s",
156                "common/arm64/ihevc_inter_pred_filters_luma_vert.s",
157                "common/arm64/ihevc_inter_pred_filters_luma_vert_w16inp.s",
158                "common/arm64/ihevc_inter_pred_filters_luma_vert_w16out.s",
159                "common/arm64/ihevc_inter_pred_luma_copy.s",
160                "common/arm64/ihevc_inter_pred_luma_copy_w16out.s",
161                "common/arm64/ihevc_inter_pred_luma_horz_w16out.s",
162                "common/arm64/ihevc_inter_pred_luma_vert_w16inp_w16out.s",
163                "common/arm64/ihevc_intra_pred_chroma_dc.s",
164                "common/arm64/ihevc_intra_pred_chroma_horz.s",
165                "common/arm64/ihevc_intra_pred_chroma_mode2.s",
166                "common/arm64/ihevc_intra_pred_chroma_mode_18_34.s",
167                "common/arm64/ihevc_intra_pred_chroma_mode_27_to_33.s",
168                "common/arm64/ihevc_intra_pred_chroma_mode_3_to_9.s",
169                "common/arm64/ihevc_intra_pred_chroma_planar.s",
170                "common/arm64/ihevc_intra_pred_chroma_ver.s",
171                "common/arm64/ihevc_intra_pred_filters_chroma_mode_11_to_17.s",
172                "common/arm64/ihevc_intra_pred_filters_chroma_mode_19_to_25.s",
173                "common/arm64/ihevc_intra_pred_filters_luma_mode_11_to_17.s",
174                "common/arm64/ihevc_intra_pred_filters_luma_mode_19_to_25.s",
175                "common/arm64/ihevc_intra_pred_luma_dc.s",
176                "common/arm64/ihevc_intra_pred_luma_horz.s",
177                "common/arm64/ihevc_intra_pred_luma_mode2.s",
178                "common/arm64/ihevc_intra_pred_luma_mode_18_34.s",
179                "common/arm64/ihevc_intra_pred_luma_mode_27_to_33.s",
180                "common/arm64/ihevc_intra_pred_luma_mode_3_to_9.s",
181                "common/arm64/ihevc_intra_pred_luma_planar.s",
182                "common/arm64/ihevc_intra_pred_luma_vert.s",
183                "common/arm64/ihevc_itrans_recon_16x16.s",
184                "common/arm64/ihevc_itrans_recon_32x32.s",
185                "common/arm64/ihevc_itrans_recon_4x4.s",
186                "common/arm64/ihevc_itrans_recon_4x4_ttype1.s",
187                "common/arm64/ihevc_itrans_recon_8x8.s",
188                "common/arm64/ihevc_mem_fns.s",
189                "common/arm64/ihevc_padding.s",
190                "common/arm64/ihevc_sao_band_offset_chroma.s",
191                "common/arm64/ihevc_sao_band_offset_luma.s",
192                "common/arm64/ihevc_sao_edge_offset_class0.s",
193                "common/arm64/ihevc_sao_edge_offset_class0_chroma.s",
194                "common/arm64/ihevc_sao_edge_offset_class1.s",
195                "common/arm64/ihevc_sao_edge_offset_class1_chroma.s",
196                "common/arm64/ihevc_sao_edge_offset_class2.s",
197                "common/arm64/ihevc_sao_edge_offset_class2_chroma.s",
198                "common/arm64/ihevc_sao_edge_offset_class3.s",
199                "common/arm64/ihevc_sao_edge_offset_class3_chroma.s",
200                "common/arm64/ihevc_weighted_pred_bi.s",
201                "common/arm64/ihevc_weighted_pred_bi_default.s",
202                "common/arm64/ihevc_weighted_pred_uni.s",
203                "decoder/arm/ihevcd_function_selector.c",
204                "decoder/arm/ihevcd_function_selector_noneon.c",
205                "decoder/arm64/ihevcd_fmt_conv_420sp_to_420p.s",
206                "decoder/arm64/ihevcd_fmt_conv_420sp_to_420sp.s",
207                "decoder/arm64/ihevcd_fmt_conv_420sp_to_rgba8888.s",
208                "decoder/arm64/ihevcd_function_selector_av8.c",
209                "decoder/arm64/ihevcd_itrans_recon_dc_chroma.s",
210                "decoder/arm64/ihevcd_itrans_recon_dc_luma.s",
211            ],
212        },
213
214        arm: {
215            local_include_dirs: [
216                "common/arm",
217                "decoder/arm",
218            ],
219
220            srcs: [
221                "decoder/arm/ihevcd_function_selector.c",
222                "decoder/arm/ihevcd_function_selector_noneon.c",
223                "common/arm/ihevc_deblk_chroma_horz.s",
224                "common/arm/ihevc_deblk_chroma_vert.s",
225                "common/arm/ihevc_deblk_luma_horz.s",
226                "common/arm/ihevc_deblk_luma_vert.s",
227                "common/arm/ihevc_inter_pred_chroma_copy.s",
228                "common/arm/ihevc_inter_pred_chroma_copy_w16out.s",
229                "common/arm/ihevc_inter_pred_chroma_horz.s",
230                "common/arm/ihevc_inter_pred_chroma_horz_w16out.s",
231                "common/arm/ihevc_inter_pred_chroma_vert.s",
232                "common/arm/ihevc_inter_pred_chroma_vert_w16inp.s",
233                "common/arm/ihevc_inter_pred_chroma_vert_w16inp_w16out.s",
234                "common/arm/ihevc_inter_pred_chroma_vert_w16out.s",
235                "common/arm/ihevc_inter_pred_filters_luma_horz.s",
236                "common/arm/ihevc_inter_pred_filters_luma_vert.s",
237                "common/arm/ihevc_inter_pred_filters_luma_vert_w16inp.s",
238                "common/arm/ihevc_inter_pred_luma_copy.s",
239                "common/arm/ihevc_inter_pred_luma_copy_w16out.s",
240                "common/arm/ihevc_inter_pred_luma_horz_w16out.s",
241                "common/arm/ihevc_inter_pred_luma_vert_w16inp_w16out.s",
242                "common/arm/ihevc_intra_pred_chroma_dc.s",
243                "common/arm/ihevc_intra_pred_chroma_horz.s",
244                "common/arm/ihevc_intra_pred_chroma_mode2.s",
245                "common/arm/ihevc_intra_pred_chroma_mode_18_34.s",
246                "common/arm/ihevc_intra_pred_chroma_mode_27_to_33.s",
247                "common/arm/ihevc_intra_pred_chroma_mode_3_to_9.s",
248                "common/arm/ihevc_intra_pred_chroma_planar.s",
249                "common/arm/ihevc_intra_pred_chroma_ver.s",
250                "common/arm/ihevc_intra_pred_filters_chroma_mode_11_to_17.s",
251                "common/arm/ihevc_intra_pred_filters_chroma_mode_19_to_25.s",
252                "common/arm/ihevc_intra_pred_filters_luma_mode_11_to_17.s",
253                "common/arm/ihevc_intra_pred_filters_luma_mode_19_to_25.s",
254                "common/arm/ihevc_intra_pred_filters_neon_intr.c",
255                "common/arm/ihevc_intra_pred_luma_dc.s",
256                "common/arm/ihevc_intra_pred_luma_horz.s",
257                "common/arm/ihevc_intra_pred_luma_mode2.s",
258                "common/arm/ihevc_intra_pred_luma_mode_18_34.s",
259                "common/arm/ihevc_intra_pred_luma_mode_27_to_33.s",
260                "common/arm/ihevc_intra_pred_luma_mode_3_to_9.s",
261                "common/arm/ihevc_intra_pred_luma_planar.s",
262                "common/arm/ihevc_intra_pred_luma_vert.s",
263                "common/arm/ihevc_intra_ref_substitution_a9q.c",
264                "common/arm/ihevc_itrans_recon_16x16.s",
265                "common/arm/ihevc_itrans_recon_32x32.s",
266                "common/arm/ihevc_itrans_recon_4x4.s",
267                "common/arm/ihevc_itrans_recon_4x4_ttype1.s",
268                "common/arm/ihevc_itrans_recon_8x8.s",
269                "common/arm/ihevc_mem_fns.s",
270                "common/arm/ihevc_padding.s",
271                "common/arm/ihevc_sao_band_offset_chroma.s",
272                "common/arm/ihevc_sao_band_offset_luma.s",
273                "common/arm/ihevc_sao_edge_offset_class0.s",
274                "common/arm/ihevc_sao_edge_offset_class0_chroma.s",
275                "common/arm/ihevc_sao_edge_offset_class1.s",
276                "common/arm/ihevc_sao_edge_offset_class1_chroma.s",
277                "common/arm/ihevc_sao_edge_offset_class2.s",
278                "common/arm/ihevc_sao_edge_offset_class2_chroma.s",
279                "common/arm/ihevc_sao_edge_offset_class3.s",
280                "common/arm/ihevc_sao_edge_offset_class3_chroma.s",
281                "common/arm/ihevc_weighted_pred_bi.s",
282                "common/arm/ihevc_weighted_pred_bi_default.s",
283                "common/arm/ihevc_weighted_pred_neon_intr.c",
284                "common/arm/ihevc_weighted_pred_uni.s",
285                "decoder/arm/ihevcd_fmt_conv_420sp_to_420p.s",
286                "decoder/arm/ihevcd_fmt_conv_420sp_to_420sp.s",
287                "decoder/arm/ihevcd_fmt_conv_420sp_to_rgba8888.s",
288                "decoder/arm/ihevcd_function_selector_a9q.c",
289                "decoder/arm/ihevcd_itrans_recon_dc_chroma.s",
290                "decoder/arm/ihevcd_itrans_recon_dc_luma.s",
291            ],
292
293            cflags: [
294                // Modules coded with neon intrinsics are not not included in Android Build.
295                "-DDISABLE_NEONINTR",
296                "-DARM",
297                "-DARMGCC",
298                "-fno-tree-vectorize",
299                "-DDEFAULT_ARCH=D_ARCH_ARM_A9Q",
300            ],
301
302            instruction_set: "arm",
303        },
304
305        x86_64: {
306            cflags: [
307                "-DX86",
308                "-DDISABLE_AVX2",
309                "-msse4.2",
310                "-mno-avx",
311                "-DDEFAULT_ARCH=D_ARCH_X86_SSE42",
312            ],
313
314            local_include_dirs: [
315                "common/x86",
316                "decoder/x86",
317            ],
318
319            srcs: [
320                "common/x86/ihevc_16x16_itrans_recon_sse42_intr.c",
321                "common/x86/ihevc_32x32_itrans_recon_sse42_intr.c",
322                "common/x86/ihevc_chroma_intra_pred_filters_sse42_intr.c",
323                "common/x86/ihevc_chroma_intra_pred_filters_ssse3_intr.c",
324                "common/x86/ihevc_deblk_ssse3_intr.c",
325                "common/x86/ihevc_inter_pred_filters_sse42_intr.c",
326                "common/x86/ihevc_inter_pred_filters_ssse3_intr.c",
327                "common/x86/ihevc_intra_pred_filters_sse42_intr.c",
328                "common/x86/ihevc_intra_pred_filters_ssse3_intr.c",
329                "common/x86/ihevc_itrans_recon_16x16_ssse3_intr.c",
330                "common/x86/ihevc_itrans_recon_32x32_ssse3_intr.c",
331                "common/x86/ihevc_itrans_recon_sse42_intr.c",
332                "common/x86/ihevc_itrans_recon_ssse3_intr.c",
333                "common/x86/ihevc_mem_fns_ssse3_intr.c",
334                "common/x86/ihevc_padding_ssse3_intr.c",
335                "common/x86/ihevc_sao_ssse3_intr.c",
336                "common/x86/ihevc_tables_x86_intr.c",
337                "common/x86/ihevc_weighted_pred_sse42_intr.c",
338                "common/x86/ihevc_weighted_pred_ssse3_intr.c",
339                "decoder/x86/ihevcd_fmt_conv_ssse3_intr.c",
340                "decoder/x86/ihevcd_function_selector.c",
341                "decoder/x86/ihevcd_function_selector_generic.c",
342                "decoder/x86/ihevcd_function_selector_sse42.c",
343                "decoder/x86/ihevcd_function_selector_ssse3.c",
344                "decoder/x86/ihevcd_it_rec_dc_sse42_intr.c",
345                "decoder/x86/ihevcd_it_rec_dc_ssse3_intr.c",
346            ],
347        },
348
349        x86: {
350            cflags: [
351                "-DX86",
352                "-DDISABLE_AVX2",
353                "-msse4.2",
354                "-mno-avx",
355                "-DDEFAULT_ARCH=D_ARCH_X86_SSE42",
356            ],
357
358            local_include_dirs: [
359                "common/x86",
360                "decoder/x86",
361            ],
362
363            srcs: [
364                "common/x86/ihevc_16x16_itrans_recon_sse42_intr.c",
365                "common/x86/ihevc_32x32_itrans_recon_sse42_intr.c",
366                "common/x86/ihevc_chroma_intra_pred_filters_sse42_intr.c",
367                "common/x86/ihevc_chroma_intra_pred_filters_ssse3_intr.c",
368                "common/x86/ihevc_deblk_ssse3_intr.c",
369                "common/x86/ihevc_inter_pred_filters_sse42_intr.c",
370                "common/x86/ihevc_inter_pred_filters_ssse3_intr.c",
371                "common/x86/ihevc_intra_pred_filters_sse42_intr.c",
372                "common/x86/ihevc_intra_pred_filters_ssse3_intr.c",
373                "common/x86/ihevc_itrans_recon_16x16_ssse3_intr.c",
374                "common/x86/ihevc_itrans_recon_32x32_ssse3_intr.c",
375                "common/x86/ihevc_itrans_recon_sse42_intr.c",
376                "common/x86/ihevc_itrans_recon_ssse3_intr.c",
377                "common/x86/ihevc_mem_fns_ssse3_intr.c",
378                "common/x86/ihevc_padding_ssse3_intr.c",
379                "common/x86/ihevc_sao_ssse3_intr.c",
380                "common/x86/ihevc_tables_x86_intr.c",
381                "common/x86/ihevc_weighted_pred_sse42_intr.c",
382                "common/x86/ihevc_weighted_pred_ssse3_intr.c",
383                "decoder/x86/ihevcd_fmt_conv_ssse3_intr.c",
384                "decoder/x86/ihevcd_function_selector.c",
385                "decoder/x86/ihevcd_function_selector_generic.c",
386                "decoder/x86/ihevcd_function_selector_sse42.c",
387                "decoder/x86/ihevcd_function_selector_ssse3.c",
388                "decoder/x86/ihevcd_it_rec_dc_sse42_intr.c",
389                "decoder/x86/ihevcd_it_rec_dc_ssse3_intr.c",
390            ],
391        },
392        riscv64: {
393            local_include_dirs: [
394                "common/riscv64",
395            ],
396
397            srcs: [
398                "decoder/riscv64/ihevcd_function_selector.c",
399                "decoder/riscv64/ihevcd_function_selector_generic.c",
400            ],
401        },
402    },
403
404    sanitize: {
405        integer_overflow: true,
406        misc_undefined: ["bounds"],
407        // Enable CFI if this becomes a shared library.
408        cfi: true,
409        config: {
410            cfi_assembly_support: true,
411        },
412        blocklist: "libhevc_blocklist.txt",
413    },
414
415    apex_available: [
416        "//apex_available:platform",
417        "com.android.media.swcodec",
418    ],
419    min_sdk_version: "29",
420}
421
422cc_test {
423    name: "hevcdec",
424    host_supported: true,
425    cflags: [
426        "-DPROFILE_ENABLE",
427        "-DARM",
428        "-fPIC",
429        "-DMD5_DISABLE",
430        "-Wall",
431        "-Werror",
432    ],
433    gtest: false,
434    srcs: ["test/decoder/main.c"],
435    static_libs: ["libhevcdec"],
436    target: {
437        darwin: {
438            enabled: false,
439        },
440    },
441}
442
443cc_library_static {
444    name: "libhevcenc",
445    vendor_available: true,
446    host_supported: true,
447    cflags: [
448        "-DENABLE_MAIN_REXT_PROFILE",
449        "-DDISABLE_SEI",
450        "-fPIC",
451        "-O3",
452        "-Wall",
453        "-Wno-unused-variable",
454        "-Wno-unused-parameter",
455    ],
456
457    export_include_dirs: [
458        "common",
459        "encoder",
460    ],
461
462    srcs: [
463        "common/ihevc_cabac_tables.c",
464        "common/ihevc_chroma_intra_pred_filters.c",
465        "common/ihevc_chroma_itrans_recon.c",
466        "common/ihevc_chroma_itrans_recon_16x16.c",
467        "common/ihevc_chroma_itrans_recon_8x8.c",
468        "common/ihevc_common_tables.c",
469        "common/ihevc_deblk_edge_filter.c",
470        "common/ihevc_deblk_tables.c",
471        "common/ihevc_hbd_deblk_edge_filter.c",
472        "common/ihevc_inter_pred_filters.c",
473        "common/ihevc_intra_pred_filters.c",
474        "common/ihevc_iquant_recon.c",
475        "common/ihevc_itrans_recon.c",
476        "common/ihevc_itrans_recon_16x16.c",
477        "common/ihevc_itrans_recon_32x32.c",
478        "common/ihevc_itrans_recon_8x8.c",
479        "common/ihevc_mem_fns.c",
480        "common/ihevc_padding.c",
481        "common/ihevc_quant_iquant_ssd.c",
482        "common/ihevc_quant_tables.c",
483        "common/ihevc_resi_trans.c",
484        "common/ihevc_sao.c",
485        "common/ihevc_trans_tables.c",
486        "common/ihevc_weighted_pred.c",
487        "encoder/bit_allocation.c",
488        "encoder/cbr_buffer_control.c",
489        "encoder/common_rom.c",
490        "encoder/convert_float_to_fix.c",
491        "encoder/est_sad.c",
492        "encoder/fixed_point_error_bits.c",
493        "encoder/frame_info_collector.c",
494        "encoder/hme_coarse.c",
495        "encoder/hme_common_utils.c",
496        "encoder/hme_err_compute.c",
497        "encoder/hme_fullpel.c",
498        "encoder/hme_function_selector.c",
499        "encoder/hme_globals.c",
500        "encoder/hme_interface.c",
501        "encoder/hme_refine.c",
502        "encoder/hme_search_algo.c",
503        "encoder/hme_subpel.c",
504        "encoder/hme_utils.c",
505        "encoder/ihevce_bitstream.c",
506        "encoder/ihevce_bs_compute_ctb.c",
507        "encoder/ihevce_buffer_que.c",
508        "encoder/ihevce_cabac.c",
509        "encoder/ihevce_cabac_cu_pu.c",
510        "encoder/ihevce_cabac_rdo.c",
511        "encoder/ihevce_cabac_tu.c",
512        "encoder/ihevce_chroma_had_satd.c",
513        "encoder/ihevce_cmn_utils_instr_set_router.c",
514        "encoder/ihevce_coarse_me_pass.c",
515        "encoder/ihevce_common_utils.c",
516        "encoder/ihevce_deblk.c",
517        "encoder/ihevce_decomp_pre_intra_pass.c",
518        "encoder/ihevce_dep_mngr.c",
519        "encoder/ihevce_enc_cu_recursion.c",
520        "encoder/ihevce_enc_loop_inter_mode_sifter.c",
521        "encoder/ihevce_enc_loop_pass.c",
522        "encoder/ihevce_enc_loop_utils.c",
523        "encoder/ihevce_enc_sbh_funcs.c",
524        "encoder/ihevce_enc_subpel_gen.c",
525        "encoder/ihevce_encode_header.c",
526        "encoder/ihevce_encode_header_sei_vui.c",
527        "encoder/ihevce_entropy_cod.c",
528        "encoder/ihevce_entropy_interface.c",
529        "encoder/ihevce_error_check.c",
530        "encoder/ihevce_frame_process.c",
531        "encoder/ihevce_frame_process_utils.c",
532        "encoder/ihevce_function_selector.c",
533        "encoder/ihevce_global_tables.c",
534        "encoder/ihevce_had_satd.c",
535        "encoder/ihevce_hle_interface.c",
536        "encoder/ihevce_hle_q_func.c",
537        "encoder/ihevce_inter_pred.c",
538        "encoder/ihevce_ipe_instr_set_router.c",
539        "encoder/ihevce_ipe_pass.c",
540        "encoder/ihevce_lap_interface.c",
541        "encoder/ihevce_me_instr_set_router.c",
542        "encoder/ihevce_me_pass.c",
543        "encoder/ihevce_memory_init.c",
544        "encoder/ihevce_multi_thrd_funcs.c",
545        "encoder/ihevce_mv_pred.c",
546        "encoder/ihevce_mv_pred_merge.c",
547        "encoder/ihevce_nbr_avail.c",
548        "encoder/ihevce_plugin.c",
549        "encoder/ihevce_profile.c",
550        "encoder/ihevce_rc_interface.c",
551        "encoder/ihevce_recur_bracketing.c",
552        "encoder/ihevce_sao.c",
553        "encoder/ihevce_stasino_helpers.c",
554        "encoder/ihevce_sub_pic_rc.c",
555        "encoder/ihevce_sys_api.c",
556        "encoder/ihevce_tile_interface.c",
557        "encoder/ihevce_trace.c",
558        "encoder/ihevce_tu_tree_selector.c",
559        "encoder/init_qp.c",
560        "encoder/mb_model_based.c",
561        "encoder/osal.c",
562        "encoder/osal_cond_var.c",
563        "encoder/osal_error.c",
564        "encoder/osal_mutex.c",
565        "encoder/osal_semaphore.c",
566        "encoder/osal_thread.c",
567        "encoder/picture_type.c",
568        "encoder/rate_control_api.c",
569        "encoder/rc_rd_model.c",
570        "encoder/rc_rd_model_fix.c",
571        "encoder/rc_sad_acc.c",
572        "encoder/sqrt_interp.c",
573        "encoder/var_q_operator.c",
574        "encoder/vbr_storage_vbv.c",
575        "encoder/vbr_str_prms.c",
576    ],
577
578    arch: {
579        arm64: {
580
581            local_include_dirs: [
582                "common/arm",
583                "common/arm64",
584                "encoder/arm",
585            ],
586
587            srcs: [
588                "common/arm/ihevc_intra_pred_filters_neon_intr.c",
589                "common/arm/ihevc_intra_ref_substitution_a9q.c",
590                "common/arm/ihevc_quant_iquant_ssd_neon_intr.c",
591                "common/arm/ihevc_resi_trans_neon.c",
592                "common/arm/ihevc_resi_trans_neon_32x32.c",
593                "common/arm/ihevc_weighted_pred_neon_intr.c",
594                "common/arm64/ihevc_deblk_chroma_horz.s",
595                "common/arm64/ihevc_deblk_chroma_vert.s",
596                "common/arm64/ihevc_deblk_luma_horz.s",
597                "common/arm64/ihevc_deblk_luma_vert.s",
598                "common/arm64/ihevc_inter_pred_chroma_copy.s",
599                "common/arm64/ihevc_inter_pred_chroma_copy_w16out.s",
600                "common/arm64/ihevc_inter_pred_chroma_horz.s",
601                "common/arm64/ihevc_inter_pred_chroma_horz_w16out.s",
602                "common/arm64/ihevc_inter_pred_chroma_vert.s",
603                "common/arm64/ihevc_inter_pred_chroma_vert_w16inp.s",
604                "common/arm64/ihevc_inter_pred_chroma_vert_w16inp_w16out.s",
605                "common/arm64/ihevc_inter_pred_chroma_vert_w16out.s",
606                "common/arm64/ihevc_inter_pred_filters_luma_horz.s",
607                "common/arm64/ihevc_inter_pred_filters_luma_vert.s",
608                "common/arm64/ihevc_inter_pred_filters_luma_vert_w16inp.s",
609                "common/arm64/ihevc_inter_pred_filters_luma_vert_w16out.s",
610                "common/arm64/ihevc_inter_pred_luma_copy.s",
611                "common/arm64/ihevc_inter_pred_luma_copy_w16out.s",
612                "common/arm64/ihevc_inter_pred_luma_horz_w16out.s",
613                "common/arm64/ihevc_inter_pred_luma_vert_w16inp_w16out.s",
614                "common/arm64/ihevc_intra_pred_chroma_dc.s",
615                "common/arm64/ihevc_intra_pred_chroma_horz.s",
616                "common/arm64/ihevc_intra_pred_chroma_mode2.s",
617                "common/arm64/ihevc_intra_pred_chroma_mode_18_34.s",
618                "common/arm64/ihevc_intra_pred_chroma_mode_27_to_33.s",
619                "common/arm64/ihevc_intra_pred_chroma_mode_3_to_9.s",
620                "common/arm64/ihevc_intra_pred_chroma_planar.s",
621                "common/arm64/ihevc_intra_pred_chroma_ver.s",
622                "common/arm64/ihevc_intra_pred_filters_chroma_mode_11_to_17.s",
623                "common/arm64/ihevc_intra_pred_filters_chroma_mode_19_to_25.s",
624                "common/arm64/ihevc_intra_pred_filters_luma_mode_11_to_17.s",
625                "common/arm64/ihevc_intra_pred_filters_luma_mode_19_to_25.s",
626                "common/arm64/ihevc_intra_pred_luma_dc.s",
627                "common/arm64/ihevc_intra_pred_luma_horz.s",
628                "common/arm64/ihevc_intra_pred_luma_mode2.s",
629                "common/arm64/ihevc_intra_pred_luma_mode_18_34.s",
630                "common/arm64/ihevc_intra_pred_luma_mode_27_to_33.s",
631                "common/arm64/ihevc_intra_pred_luma_mode_3_to_9.s",
632                "common/arm64/ihevc_intra_pred_luma_planar.s",
633                "common/arm64/ihevc_intra_pred_luma_vert.s",
634                "common/arm64/ihevc_itrans_recon_16x16.s",
635                "common/arm64/ihevc_itrans_recon_32x32.s",
636                "common/arm64/ihevc_itrans_recon_4x4.s",
637                "common/arm64/ihevc_itrans_recon_4x4_ttype1.s",
638                "common/arm64/ihevc_itrans_recon_8x8.s",
639                "common/arm64/ihevc_mem_fns.s",
640                "common/arm64/ihevc_padding.s",
641                "common/arm64/ihevc_sao_band_offset_chroma.s",
642                "common/arm64/ihevc_sao_band_offset_luma.s",
643                "common/arm64/ihevc_sao_edge_offset_class0.s",
644                "common/arm64/ihevc_sao_edge_offset_class0_chroma.s",
645                "common/arm64/ihevc_sao_edge_offset_class1.s",
646                "common/arm64/ihevc_sao_edge_offset_class1_chroma.s",
647                "common/arm64/ihevc_sao_edge_offset_class2.s",
648                "common/arm64/ihevc_sao_edge_offset_class2_chroma.s",
649                "common/arm64/ihevc_sao_edge_offset_class3.s",
650                "common/arm64/ihevc_sao_edge_offset_class3_chroma.s",
651                "common/arm64/ihevc_weighted_pred_bi.s",
652                "common/arm64/ihevc_weighted_pred_bi_default.s",
653                "common/arm64/ihevc_weighted_pred_uni.s",
654                "encoder/arm/ihevce_coarse_layer_sad_neon.c",
655                "encoder/arm/ihevce_common_utils_neon.c",
656                "encoder/arm/ihevce_copy_neon.c",
657                "encoder/arm/ihevce_had_compute_neon.c",
658                "encoder/arm/ihevce_hme_utils_neon.c",
659                "encoder/arm/ihevce_itrans_recon_neon.c",
660                "encoder/arm/ihevce_me_neon.c",
661                "encoder/arm/ihevce_sad_compute_neon.c",
662                "encoder/arm/ihevce_scale_by_2_neon.c",
663                "encoder/arm/ihevce_scan_coeffs_neon.c",
664                "encoder/arm/ihevce_ssd_and_sad_calculator_neon.c",
665                "encoder/arm/ihevce_ssd_calculator_neon.c",
666                "encoder/arm/ihevce_subpel_neon.c",
667            ],
668
669            cflags: [
670                "-DENABLE_NEON",
671                "-DARMV8",
672                "-DARM",
673            ],
674        },
675
676        arm: {
677            local_include_dirs: [
678                "common/arm",
679                "encoder/arm",
680            ],
681
682            srcs: [
683                "common/arm/ihevc_deblk_chroma_horz.s",
684                "common/arm/ihevc_deblk_chroma_vert.s",
685                "common/arm/ihevc_deblk_luma_horz.s",
686                "common/arm/ihevc_deblk_luma_vert.s",
687                "common/arm/ihevc_inter_pred_chroma_copy.s",
688                "common/arm/ihevc_inter_pred_chroma_copy_w16out.s",
689                "common/arm/ihevc_inter_pred_chroma_horz.s",
690                "common/arm/ihevc_inter_pred_chroma_horz_w16out.s",
691                "common/arm/ihevc_inter_pred_chroma_vert.s",
692                "common/arm/ihevc_inter_pred_chroma_vert_w16inp.s",
693                "common/arm/ihevc_inter_pred_chroma_vert_w16inp_w16out.s",
694                "common/arm/ihevc_inter_pred_chroma_vert_w16out.s",
695                "common/arm/ihevc_inter_pred_filters_luma_horz.s",
696                "common/arm/ihevc_inter_pred_filters_luma_vert.s",
697                "common/arm/ihevc_inter_pred_filters_luma_vert_w16inp.s",
698                "common/arm/ihevc_inter_pred_luma_copy.s",
699                "common/arm/ihevc_inter_pred_luma_copy_w16out.s",
700                "common/arm/ihevc_inter_pred_luma_horz_w16out.s",
701                "common/arm/ihevc_inter_pred_luma_vert_w16inp_w16out.s",
702                "common/arm/ihevc_intra_pred_chroma_dc.s",
703                "common/arm/ihevc_intra_pred_chroma_horz.s",
704                "common/arm/ihevc_intra_pred_chroma_mode2.s",
705                "common/arm/ihevc_intra_pred_chroma_mode_18_34.s",
706                "common/arm/ihevc_intra_pred_chroma_mode_27_to_33.s",
707                "common/arm/ihevc_intra_pred_chroma_mode_3_to_9.s",
708                "common/arm/ihevc_intra_pred_chroma_planar.s",
709                "common/arm/ihevc_intra_pred_chroma_ver.s",
710                "common/arm/ihevc_intra_pred_filters_chroma_mode_11_to_17.s",
711                "common/arm/ihevc_intra_pred_filters_chroma_mode_19_to_25.s",
712                "common/arm/ihevc_intra_pred_filters_luma_mode_11_to_17.s",
713                "common/arm/ihevc_intra_pred_filters_luma_mode_19_to_25.s",
714                "common/arm/ihevc_intra_pred_filters_neon_intr.c",
715                "common/arm/ihevc_intra_pred_luma_dc.s",
716                "common/arm/ihevc_intra_pred_luma_horz.s",
717                "common/arm/ihevc_intra_pred_luma_mode2.s",
718                "common/arm/ihevc_intra_pred_luma_mode_18_34.s",
719                "common/arm/ihevc_intra_pred_luma_mode_27_to_33.s",
720                "common/arm/ihevc_intra_pred_luma_mode_3_to_9.s",
721                "common/arm/ihevc_intra_pred_luma_planar.s",
722                "common/arm/ihevc_intra_pred_luma_vert.s",
723                "common/arm/ihevc_intra_ref_substitution_a9q.c",
724                "common/arm/ihevc_itrans_recon_16x16.s",
725                "common/arm/ihevc_itrans_recon_32x32.s",
726                "common/arm/ihevc_itrans_recon_4x4.s",
727                "common/arm/ihevc_itrans_recon_4x4_ttype1.s",
728                "common/arm/ihevc_itrans_recon_8x8.s",
729                "common/arm/ihevc_mem_fns.s",
730                "common/arm/ihevc_padding.s",
731                "common/arm/ihevc_quant_iquant_ssd_neon_intr.c",
732                "common/arm/ihevc_resi_trans.s",
733                "common/arm/ihevc_resi_trans_32x32_a9q.s",
734                "common/arm/ihevc_resi_trans_neon.c",
735                "common/arm/ihevc_resi_trans_neon_32x32.c",
736                "common/arm/ihevc_sao_band_offset_chroma.s",
737                "common/arm/ihevc_sao_band_offset_luma.s",
738                "common/arm/ihevc_sao_edge_offset_class0.s",
739                "common/arm/ihevc_sao_edge_offset_class0_chroma.s",
740                "common/arm/ihevc_sao_edge_offset_class1.s",
741                "common/arm/ihevc_sao_edge_offset_class1_chroma.s",
742                "common/arm/ihevc_sao_edge_offset_class2.s",
743                "common/arm/ihevc_sao_edge_offset_class2_chroma.s",
744                "common/arm/ihevc_sao_edge_offset_class3.s",
745                "common/arm/ihevc_sao_edge_offset_class3_chroma.s",
746                "common/arm/ihevc_weighted_pred_bi.s",
747                "common/arm/ihevc_weighted_pred_bi_default.s",
748                "common/arm/ihevc_weighted_pred_neon_intr.c",
749                "common/arm/ihevc_weighted_pred_uni.s",
750                "encoder/arm/ihevce_coarse_layer_sad_neon.c",
751                "encoder/arm/ihevce_common_utils_neon.c",
752                "encoder/arm/ihevce_copy_neon.c",
753                "encoder/arm/ihevce_had_compute_neon.c",
754                "encoder/arm/ihevce_hme_utils_neon.c",
755                "encoder/arm/ihevce_itrans_recon_neon.c",
756                "encoder/arm/ihevce_me_neon.c",
757                "encoder/arm/ihevce_sad_compute_neon.c",
758                "encoder/arm/ihevce_scale_by_2_neon.c",
759                "encoder/arm/ihevce_scan_coeffs_neon.c",
760                "encoder/arm/ihevce_ssd_and_sad_calculator_neon.c",
761                "encoder/arm/ihevce_ssd_calculator_neon.c",
762                "encoder/arm/ihevce_subpel_neon.c",
763            ],
764
765            cflags: [
766                "-DENABLE_NEON",
767                "-DARM",
768            ],
769            instruction_set: "arm",
770        },
771
772        x86_64: {
773            local_include_dirs: [
774                "common/x86",
775            ],
776        },
777
778        x86: {
779            local_include_dirs: [
780                "common/x86",
781            ],
782        },
783
784        riscv64: {
785            local_include_dirs: [
786                "common/riscv64",
787            ],
788        },
789    },
790    sanitize: {
791        integer_overflow: true,
792        misc_undefined: ["bounds"],
793        // Enable CFI if this becomes a shared library.
794        cfi: true,
795        config: {
796            cfi_assembly_support: true,
797        },
798        blocklist: "libhevc_blocklist.txt",
799    },
800
801    apex_available: [
802        "//apex_available:platform",
803        "com.android.media.swcodec",
804    ],
805    min_sdk_version: "29",
806}
807
808cc_test {
809    name: "hevcenc",
810    host_supported: true,
811    cflags: [
812        "-DARM",
813        "-fPIC",
814        "-Wall",
815        "-Werror",
816    ],
817    gtest: false,
818    srcs: ["test/encoder/main.c"],
819    static_libs: ["libhevcenc"],
820    sanitize: {
821        integer_overflow: true,
822        misc_undefined: ["bounds"],
823    },
824}
825