aboutsummaryrefslogtreecommitdiff
path: root/Android.bp
blob: 7e8a6e78bb871c9ff60d1384bb4e29be35ee774c (plain)
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
package {
    default_applicable_licenses: ["external_libhevc_license"],
}

// Added automatically by a large-scale-change
// See: http://go/android-license-faq
license {
    name: "external_libhevc_license",
    visibility: [":__subpackages__"],
    license_kinds: [
        "SPDX-license-identifier-Apache-2.0",
    ],
    license_text: [
        "NOTICE",
    ],
}

cc_library_headers {
    name: "libhevcdec_headers",
    export_include_dirs: [
        "common",
        "decoder",
    ],
    min_sdk_version: "29",
}

cc_library_headers {
    name: "libhevcenc_headers",
    export_include_dirs: [
        "common",
        "encoder",
    ],
    min_sdk_version: "29",
}

cc_library_static {
    name: "libhevcdec",
    vendor_available: true,
    host_supported: true,

    cflags: [
        "-D_LIB",
        "-fPIC",

        "-O3",
        "-DANDROID",
        "-Wall",
        "-Werror",
        // common/x86/ihevc_sao_ssse3_intr.c: implicit conversion from
        // 'int' to 'char' changes value from 128 to -128
        "-Wno-error=constant-conversion",
        // #KEEP_THREAD_ACTIVE is experimental
        "-UKEEP_THREADS_ACTIVE",
    ],

    export_include_dirs: [
        "common",
        "decoder",
    ],

    srcs: [
        "common/ihevc_quant_tables.c",
        "common/ihevc_inter_pred_filters.c",
        "common/ihevc_weighted_pred.c",
        "common/ihevc_padding.c",
        "common/ihevc_deblk_edge_filter.c",
        "common/ihevc_deblk_tables.c",
        "common/ihevc_cabac_tables.c",
        "common/ihevc_common_tables.c",
        "common/ihevc_intra_pred_filters.c",
        "common/ihevc_chroma_intra_pred_filters.c",
        "common/ihevc_mem_fns.c",
        "common/ihevc_sao.c",
        "common/ihevc_trans_tables.c",
        "common/ihevc_recon.c",
        "common/ihevc_itrans.c",
        "common/ihevc_itrans_recon.c",
        "common/ihevc_iquant_recon.c",
        "common/ihevc_iquant_itrans_recon.c",
        "common/ihevc_itrans_recon_32x32.c",
        "common/ihevc_itrans_recon_16x16.c",
        "common/ihevc_itrans_recon_8x8.c",
        "common/ihevc_chroma_itrans_recon.c",
        "common/ihevc_chroma_iquant_recon.c",
        "common/ihevc_chroma_iquant_itrans_recon.c",
        "common/ihevc_chroma_recon.c",
        "common/ihevc_chroma_itrans_recon_16x16.c",
        "common/ihevc_chroma_itrans_recon_8x8.c",
        "common/ihevc_buf_mgr.c",
        "common/ihevc_disp_mgr.c",
        "common/ihevc_dpb_mgr.c",
        "common/ithread.c",
        "decoder/ihevcd_version.c",
        "decoder/ihevcd_api.c",
        "decoder/ihevcd_decode.c",
        "decoder/ihevcd_nal.c",
        "decoder/ihevcd_bitstream.c",
        "decoder/ihevcd_parse_headers.c",
        "decoder/ihevcd_parse_slice_header.c",
        "decoder/ihevcd_parse_slice.c",
        "decoder/ihevcd_parse_residual.c",
        "decoder/ihevcd_cabac.c",
        "decoder/ihevcd_intra_pred_mode_prediction.c",
        "decoder/ihevcd_process_slice.c",
        "decoder/ihevcd_utils.c",
        "decoder/ihevcd_job_queue.c",
        "decoder/ihevcd_ref_list.c",
        "decoder/ihevcd_get_mv.c",
        "decoder/ihevcd_mv_pred.c",
        "decoder/ihevcd_mv_merge.c",
        "decoder/ihevcd_iquant_itrans_recon_ctb.c",
        "decoder/ihevcd_itrans_recon_dc.c",
        "decoder/ihevcd_common_tables.c",
        "decoder/ihevcd_boundary_strength.c",
        "decoder/ihevcd_deblk.c",
        "decoder/ihevcd_inter_pred.c",
        "decoder/ihevcd_sao.c",
        "decoder/ihevcd_ilf_padding.c",
        "decoder/ihevcd_fmt_conv.c",
    ],

    arch: {
        arm64: {
            cflags: [
                "-DARMV8",
                "-DDISABLE_NEONINTR",
                "-DARM",
                "-DARMGCC",

                "-DDEFAULT_ARCH=D_ARCH_ARMV8_GENERIC",
            ],
            local_include_dirs: [
                "decoder/arm",
                "common/arm",
                "decoder/arm64",
                "common/arm64",
            ],

            srcs: [
                "decoder/arm/ihevcd_function_selector.c",
                "decoder/arm/ihevcd_function_selector_noneon.c",
                "decoder/arm64/ihevcd_function_selector_av8.c",
                "common/arm/ihevc_intra_pred_filters_neon_intr.c",
                "common/arm/ihevc_weighted_pred_neon_intr.c",
                "common/arm64/ihevc_mem_fns.s",
                "common/arm64/ihevc_itrans_recon_32x32.s",
                "common/arm64/ihevc_weighted_pred_bi_default.s",
                "common/arm64/ihevc_weighted_pred_bi.s",
                "common/arm64/ihevc_weighted_pred_uni.s",
                "common/arm64/ihevc_deblk_luma_horz.s",
                "common/arm64/ihevc_deblk_luma_vert.s",
                "common/arm64/ihevc_deblk_chroma_vert.s",
                "common/arm64/ihevc_deblk_chroma_horz.s",
                "common/arm64/ihevc_sao_band_offset_luma.s",
                "common/arm64/ihevc_sao_band_offset_chroma.s",
                "common/arm64/ihevc_sao_edge_offset_class0.s",
                "common/arm64/ihevc_sao_edge_offset_class0_chroma.s",
                "common/arm64/ihevc_sao_edge_offset_class1.s",
                "common/arm64/ihevc_sao_edge_offset_class1_chroma.s",
                "common/arm64/ihevc_sao_edge_offset_class2.s",
                "common/arm64/ihevc_sao_edge_offset_class2_chroma.s",
                "common/arm64/ihevc_sao_edge_offset_class3.s",
                "common/arm64/ihevc_sao_edge_offset_class3_chroma.s",
                "common/arm64/ihevc_inter_pred_luma_horz_w16out.s",
                "common/arm64/ihevc_inter_pred_filters_luma_horz.s",
                "common/arm64/ihevc_inter_pred_filters_luma_vert.s",
                "common/arm64/ihevc_inter_pred_chroma_horz.s",
                "common/arm64/ihevc_inter_pred_chroma_horz_w16out.s",
                "common/arm64/ihevc_inter_pred_chroma_vert.s",
                "common/arm64/ihevc_inter_pred_chroma_vert_w16out.s",
                "common/arm64/ihevc_inter_pred_chroma_vert_w16inp.s",
                "common/arm64/ihevc_inter_pred_chroma_vert_w16inp_w16out.s",
                "common/arm64/ihevc_inter_pred_filters_luma_vert_w16inp.s",
                "common/arm64/ihevc_inter_pred_filters_luma_vert_w16out.s",
                "common/arm64/ihevc_inter_pred_luma_vert_w16inp_w16out.s",
                "common/arm64/ihevc_inter_pred_luma_copy_w16out.s",
                "common/arm64/ihevc_inter_pred_luma_copy.s",
                "common/arm64/ihevc_inter_pred_chroma_copy.s",
                "common/arm64/ihevc_inter_pred_chroma_copy_w16out.s",
                "common/arm64/ihevc_itrans_recon_4x4_ttype1.s",
                "common/arm64/ihevc_itrans_recon_4x4.s",
                "common/arm64/ihevc_itrans_recon_8x8.s",
                "common/arm64/ihevc_itrans_recon_16x16.s",
                "common/arm64/ihevc_intra_pred_chroma_planar.s",
                "common/arm64/ihevc_intra_pred_chroma_dc.s",
                "common/arm64/ihevc_intra_pred_chroma_horz.s",
                "common/arm64/ihevc_intra_pred_chroma_ver.s",
                "common/arm64/ihevc_intra_pred_chroma_mode2.s",
                "common/arm64/ihevc_intra_pred_chroma_mode_18_34.s",
                "common/arm64/ihevc_intra_pred_filters_chroma_mode_11_to_17.s",
                "common/arm64/ihevc_intra_pred_filters_chroma_mode_19_to_25.s",
                "common/arm64/ihevc_intra_pred_chroma_mode_3_to_9.s",
                "common/arm64/ihevc_intra_pred_chroma_mode_27_to_33.s",
                "common/arm64/ihevc_intra_pred_luma_planar.s",
                "common/arm64/ihevc_intra_pred_luma_horz.s",
                "common/arm64/ihevc_intra_pred_luma_mode2.s",
                "common/arm64/ihevc_intra_pred_luma_mode_27_to_33.s",
                "common/arm64/ihevc_intra_pred_luma_mode_18_34.s",
                "common/arm64/ihevc_intra_pred_luma_vert.s",
                "common/arm64/ihevc_intra_pred_luma_dc.s",
                "common/arm64/ihevc_intra_pred_filters_luma_mode_11_to_17.s",
                "common/arm64/ihevc_intra_pred_filters_luma_mode_19_to_25.s",
                "common/arm64/ihevc_intra_pred_luma_mode_3_to_9.s",
                "common/arm64/ihevc_padding.s",
                "decoder/arm64/ihevcd_itrans_recon_dc_luma.s",
                "decoder/arm64/ihevcd_itrans_recon_dc_chroma.s",
                "decoder/arm64/ihevcd_fmt_conv_420sp_to_420p.s",
                "decoder/arm64/ihevcd_fmt_conv_420sp_to_420sp.s",
                "decoder/arm64/ihevcd_fmt_conv_420sp_to_rgba8888.s",
            ],
        },

        arm: {
            local_include_dirs: [
                "decoder/arm",
                "common/arm",
            ],

            srcs: [
                "decoder/arm/ihevcd_function_selector.c",
                "decoder/arm/ihevcd_function_selector_noneon.c",
            ],

            cflags: [
                "-DDISABLE_NEONINTR",
                "-DARM",
                "-DARMGCC",
                "-fno-tree-vectorize",

                // These will be overriden by armv7_a_neon
                "-DDISABLE_NEON",
                "-DDEFAULT_ARCH=D_ARCH_ARM_NONEON",
            ],

            instruction_set: "arm",

            neon: {
                srcs: [
                    "decoder/arm/ihevcd_function_selector_a9q.c",
                    "common/arm/ihevc_intra_ref_substitution_a9q.c",
                    "common/arm/ihevc_intra_pred_filters_neon_intr.c",
                    "common/arm/ihevc_weighted_pred_neon_intr.c",
                    "common/arm/ihevc_mem_fns.s",
                    "common/arm/ihevc_itrans_recon_32x32.s",
                    "common/arm/ihevc_weighted_pred_bi_default.s",
                    "common/arm/ihevc_weighted_pred_bi.s",
                    "common/arm/ihevc_weighted_pred_uni.s",
                    "common/arm/ihevc_deblk_luma_horz.s",
                    "common/arm/ihevc_deblk_luma_vert.s",
                    "common/arm/ihevc_deblk_chroma_vert.s",
                    "common/arm/ihevc_deblk_chroma_horz.s",
                    "common/arm/ihevc_sao_band_offset_luma.s",
                    "common/arm/ihevc_sao_band_offset_chroma.s",
                    "common/arm/ihevc_sao_edge_offset_class0.s",
                    "common/arm/ihevc_sao_edge_offset_class0_chroma.s",
                    "common/arm/ihevc_sao_edge_offset_class1.s",
                    "common/arm/ihevc_sao_edge_offset_class1_chroma.s",
                    "common/arm/ihevc_sao_edge_offset_class2.s",
                    "common/arm/ihevc_sao_edge_offset_class2_chroma.s",
                    "common/arm/ihevc_sao_edge_offset_class3.s",
                    "common/arm/ihevc_sao_edge_offset_class3_chroma.s",
                    "common/arm/ihevc_inter_pred_luma_horz_w16out.s",
                    "common/arm/ihevc_inter_pred_filters_luma_horz.s",
                    "common/arm/ihevc_inter_pred_filters_luma_vert.s",
                    "common/arm/ihevc_inter_pred_chroma_horz.s",
                    "common/arm/ihevc_inter_pred_chroma_horz_w16out.s",
                    "common/arm/ihevc_inter_pred_chroma_vert.s",
                    "common/arm/ihevc_inter_pred_chroma_vert_w16out.s",
                    "common/arm/ihevc_inter_pred_chroma_vert_w16inp.s",
                    "common/arm/ihevc_inter_pred_chroma_vert_w16inp_w16out.s",
                    "common/arm/ihevc_inter_pred_filters_luma_vert_w16inp.s",
                    "common/arm/ihevc_inter_pred_luma_vert_w16inp_w16out.s",
                    "common/arm/ihevc_inter_pred_luma_copy_w16out.s",
                    "common/arm/ihevc_inter_pred_luma_copy.s",
                    "common/arm/ihevc_inter_pred_chroma_copy.s",
                    "common/arm/ihevc_inter_pred_chroma_copy_w16out.s",
                    "common/arm/ihevc_itrans_recon_4x4_ttype1.s",
                    "common/arm/ihevc_itrans_recon_4x4.s",
                    "common/arm/ihevc_itrans_recon_8x8.s",
                    "common/arm/ihevc_itrans_recon_16x16.s",
                    "common/arm/ihevc_intra_pred_chroma_planar.s",
                    "common/arm/ihevc_intra_pred_chroma_dc.s",
                    "common/arm/ihevc_intra_pred_chroma_horz.s",
                    "common/arm/ihevc_intra_pred_chroma_ver.s",
                    "common/arm/ihevc_intra_pred_chroma_mode2.s",
                    "common/arm/ihevc_intra_pred_chroma_mode_18_34.s",
                    "common/arm/ihevc_intra_pred_filters_chroma_mode_11_to_17.s",
                    "common/arm/ihevc_intra_pred_filters_chroma_mode_19_to_25.s",
                    "common/arm/ihevc_intra_pred_chroma_mode_3_to_9.s",
                    "common/arm/ihevc_intra_pred_chroma_mode_27_to_33.s",
                    "common/arm/ihevc_intra_pred_luma_planar.s",
                    "common/arm/ihevc_intra_pred_luma_horz.s",
                    "common/arm/ihevc_intra_pred_luma_mode2.s",
                    "common/arm/ihevc_intra_pred_luma_mode_27_to_33.s",
                    "common/arm/ihevc_intra_pred_luma_mode_18_34.s",
                    "common/arm/ihevc_intra_pred_luma_vert.s",
                    "common/arm/ihevc_intra_pred_luma_dc.s",
                    "common/arm/ihevc_intra_pred_filters_luma_mode_11_to_17.s",
                    "common/arm/ihevc_intra_pred_filters_luma_mode_19_to_25.s",
                    "common/arm/ihevc_intra_pred_luma_mode_3_to_9.s",
                    "common/arm/ihevc_padding.s",
                    "decoder/arm/ihevcd_itrans_recon_dc_luma.s",
                    "decoder/arm/ihevcd_itrans_recon_dc_chroma.s",
                    "decoder/arm/ihevcd_fmt_conv_420sp_to_420p.s",
                    "decoder/arm/ihevcd_fmt_conv_420sp_to_420sp.s",
                    "decoder/arm/ihevcd_fmt_conv_420sp_to_rgba8888.s",
                ],
                cflags: [
                    "-UDISABLE_NEON",
                    "-UDEFAULT_ARCH",
                    "-DDEFAULT_ARCH=D_ARCH_ARM_A9Q",
                ],
            },
        },

        x86_64: {
            cflags: [
                "-DX86",
                "-DDISABLE_AVX2",
                "-msse4.2",
                "-mno-avx",
                "-DDEFAULT_ARCH=D_ARCH_X86_SSE42",
            ],

            local_include_dirs: [
                "decoder/x86",
                "common/x86",
            ],

            srcs: [
                "decoder/x86/ihevcd_function_selector.c",
                "decoder/x86/ihevcd_function_selector_generic.c",
                "decoder/x86/ihevcd_function_selector_ssse3.c",
                "decoder/x86/ihevcd_function_selector_sse42.c",
                "common/x86/ihevc_inter_pred_filters_ssse3_intr.c",
                "common/x86/ihevc_weighted_pred_ssse3_intr.c",
                "common/x86/ihevc_intra_pred_filters_ssse3_intr.c",
                "common/x86/ihevc_chroma_intra_pred_filters_ssse3_intr.c",
                "common/x86/ihevc_itrans_recon_ssse3_intr.c",
                "common/x86/ihevc_itrans_recon_16x16_ssse3_intr.c",
                "common/x86/ihevc_itrans_recon_32x32_ssse3_intr.c",
                "common/x86/ihevc_sao_ssse3_intr.c",
                "common/x86/ihevc_deblk_ssse3_intr.c",
                "common/x86/ihevc_padding_ssse3_intr.c",
                "common/x86/ihevc_mem_fns_ssse3_intr.c",
                "decoder/x86/ihevcd_fmt_conv_ssse3_intr.c",
                "decoder/x86/ihevcd_it_rec_dc_ssse3_intr.c",
                "common/x86/ihevc_inter_pred_filters_sse42_intr.c",
                "common/x86/ihevc_weighted_pred_sse42_intr.c",
                "common/x86/ihevc_intra_pred_filters_sse42_intr.c",
                "common/x86/ihevc_chroma_intra_pred_filters_sse42_intr.c",
                "common/x86/ihevc_itrans_recon_sse42_intr.c",
                "common/x86/ihevc_16x16_itrans_recon_sse42_intr.c",
                "common/x86/ihevc_32x32_itrans_recon_sse42_intr.c",
                "decoder/x86/ihevcd_it_rec_dc_sse42_intr.c",
                "common/x86/ihevc_tables_x86_intr.c",
            ],
        },

        x86: {
            cflags: [
                "-DX86",
                "-DDISABLE_AVX2",
                "-msse4.2",
                "-mno-avx",
                "-DDEFAULT_ARCH=D_ARCH_X86_SSE42",
            ],

            local_include_dirs: [
                "decoder/x86",
                "common/x86",
            ],

            srcs: [
                "decoder/x86/ihevcd_function_selector.c",
                "decoder/x86/ihevcd_function_selector_generic.c",
                "decoder/x86/ihevcd_function_selector_ssse3.c",
                "decoder/x86/ihevcd_function_selector_sse42.c",
                "common/x86/ihevc_inter_pred_filters_ssse3_intr.c",
                "common/x86/ihevc_weighted_pred_ssse3_intr.c",
                "common/x86/ihevc_intra_pred_filters_ssse3_intr.c",
                "common/x86/ihevc_chroma_intra_pred_filters_ssse3_intr.c",
                "common/x86/ihevc_itrans_recon_ssse3_intr.c",
                "common/x86/ihevc_itrans_recon_16x16_ssse3_intr.c",
                "common/x86/ihevc_itrans_recon_32x32_ssse3_intr.c",
                "common/x86/ihevc_sao_ssse3_intr.c",
                "common/x86/ihevc_deblk_ssse3_intr.c",
                "common/x86/ihevc_padding_ssse3_intr.c",
                "common/x86/ihevc_mem_fns_ssse3_intr.c",
                "decoder/x86/ihevcd_fmt_conv_ssse3_intr.c",
                "decoder/x86/ihevcd_it_rec_dc_ssse3_intr.c",
                "common/x86/ihevc_inter_pred_filters_sse42_intr.c",
                "common/x86/ihevc_weighted_pred_sse42_intr.c",
                "common/x86/ihevc_intra_pred_filters_sse42_intr.c",
                "common/x86/ihevc_chroma_intra_pred_filters_sse42_intr.c",
                "common/x86/ihevc_itrans_recon_sse42_intr.c",
                "common/x86/ihevc_16x16_itrans_recon_sse42_intr.c",
                "common/x86/ihevc_32x32_itrans_recon_sse42_intr.c",
                "decoder/x86/ihevcd_it_rec_dc_sse42_intr.c",
                "common/x86/ihevc_tables_x86_intr.c",
            ],
        },
        riscv64: {
            local_include_dirs: [
                "common/riscv64",
            ],

            srcs: [
                "decoder/riscv64/ihevcd_function_selector.c",
                "decoder/riscv64/ihevcd_function_selector_generic.c",
            ],
        },
    },

    sanitize: {
        integer_overflow: true,
        misc_undefined: ["bounds"],
        // Enable CFI if this becomes a shared library.
        cfi: true,
	config: {
            cfi_assembly_support: true,
        },
        blocklist: "libhevc_blocklist.txt",
    },

    apex_available: [
        "//apex_available:platform",
        "com.android.media.swcodec",
    ],
    min_sdk_version: "29",
}

cc_test {
    name: "hevcdec",
    host_supported: true,
    cflags: [
        "-DPROFILE_ENABLE",
        "-DARM",
        "-fPIC",
        "-DMD5_DISABLE",
        "-Wall",
        "-Werror",
    ],
    gtest: false,
    srcs: ["test/decoder/main.c"],
    static_libs: ["libhevcdec"],
    target: {
        darwin: {
            enabled: false,
        },
    },
}

cc_library_static {
    name: "libhevcenc",
    vendor_available: true,
    host_supported: true,
    cflags: [
        "-DENABLE_MAIN_REXT_PROFILE",
        "-fPIC",
        "-O3",
        "-Wall",
        "-Wno-unused-variable",
        "-Wno-unused-parameter",
        "-Wno-switch",
    ],

    export_include_dirs: [
        "common",
        "encoder",
    ],

    srcs: [
        "common/ihevc_cabac_tables.c",
        "common/ihevc_chroma_intra_pred_filters.c",
        "common/ihevc_chroma_itrans_recon.c",
        "common/ihevc_chroma_itrans_recon_16x16.c",
        "common/ihevc_chroma_itrans_recon_8x8.c",
        "common/ihevc_common_tables.c",
        "common/ihevc_deblk_edge_filter.c",
        "common/ihevc_deblk_tables.c",
        "common/ihevc_hbd_deblk_edge_filter.c",
        "common/ihevc_inter_pred_filters.c",
        "common/ihevc_intra_pred_filters.c",
        "common/ihevc_iquant_recon.c",
        "common/ihevc_itrans_recon.c",
        "common/ihevc_itrans_recon_16x16.c",
        "common/ihevc_itrans_recon_32x32.c",
        "common/ihevc_itrans_recon_8x8.c",
        "common/ihevc_mem_fns.c",
        "common/ihevc_padding.c",
        "common/ihevc_quant_iquant_ssd.c",
        "common/ihevc_quant_tables.c",
        "common/ihevc_resi_trans.c",
        "common/ihevc_sao.c",
        "common/ihevc_trans_tables.c",
        "common/ihevc_weighted_pred.c",
        "encoder/bit_allocation.c",
        "encoder/cbr_buffer_control.c",
        "encoder/common_rom.c",
        "encoder/convert_float_to_fix.c",
        "encoder/est_sad.c",
        "encoder/fixed_point_error_bits.c",
        "encoder/frame_info_collector.c",
        "encoder/hme_coarse.c",
        "encoder/hme_common_utils.c",
        "encoder/hme_err_compute.c",
        "encoder/hme_fullpel.c",
        "encoder/hme_function_selector.c",
        "encoder/hme_globals.c",
        "encoder/hme_interface.c",
        "encoder/hme_refine.c",
        "encoder/hme_search_algo.c",
        "encoder/hme_subpel.c",
        "encoder/hme_utils.c",
        "encoder/ihevce_bitstream.c",
        "encoder/ihevce_bs_compute_ctb.c",
        "encoder/ihevce_buffer_que.c",
        "encoder/ihevce_cabac.c",
        "encoder/ihevce_cabac_cu_pu.c",
        "encoder/ihevce_cabac_rdo.c",
        "encoder/ihevce_cabac_tu.c",
        "encoder/ihevce_chroma_had_satd.c",
        "encoder/ihevce_cmn_utils_instr_set_router.c",
        "encoder/ihevce_coarse_me_pass.c",
        "encoder/ihevce_common_utils.c",
        "encoder/ihevce_deblk.c",
        "encoder/ihevce_decomp_pre_intra_pass.c",
        "encoder/ihevce_dep_mngr.c",
        "encoder/ihevce_enc_cu_recursion.c",
        "encoder/ihevce_enc_loop_inter_mode_sifter.c",
        "encoder/ihevce_enc_loop_pass.c",
        "encoder/ihevce_enc_loop_utils.c",
        "encoder/ihevce_enc_sbh_funcs.c",
        "encoder/ihevce_enc_subpel_gen.c",
        "encoder/ihevce_encode_header.c",
        "encoder/ihevce_encode_header_sei_vui.c",
        "encoder/ihevce_entropy_cod.c",
        "encoder/ihevce_entropy_interface.c",
        "encoder/ihevce_error_check.c",
        "encoder/ihevce_frame_process.c",
        "encoder/ihevce_frame_process_utils.c",
        "encoder/ihevce_function_selector.c",
        "encoder/ihevce_global_tables.c",
        "encoder/ihevce_had_satd.c",
        "encoder/ihevce_hle_interface.c",
        "encoder/ihevce_hle_q_func.c",
        "encoder/ihevce_inter_pred.c",
        "encoder/ihevce_ipe_instr_set_router.c",
        "encoder/ihevce_ipe_pass.c",
        "encoder/ihevce_lap_interface.c",
        "encoder/ihevce_me_instr_set_router.c",
        "encoder/ihevce_me_pass.c",
        "encoder/ihevce_memory_init.c",
        "encoder/ihevce_multi_thrd_funcs.c",
        "encoder/ihevce_mv_pred.c",
        "encoder/ihevce_mv_pred_merge.c",
        "encoder/ihevce_nbr_avail.c",
        "encoder/ihevce_plugin.c",
        "encoder/ihevce_profile.c",
        "encoder/ihevce_rc_interface.c",
        "encoder/ihevce_recur_bracketing.c",
        "encoder/ihevce_sao.c",
        "encoder/ihevce_stasino_helpers.c",
        "encoder/ihevce_sub_pic_rc.c",
        "encoder/ihevce_sys_api.c",
        "encoder/ihevce_tile_interface.c",
        "encoder/ihevce_trace.c",
        "encoder/ihevce_tu_tree_selector.c",
        "encoder/init_qp.c",
        "encoder/mb_model_based.c",
        "encoder/osal.c",
        "encoder/osal_cond_var.c",
        "encoder/osal_error.c",
        "encoder/osal_mutex.c",
        "encoder/osal_semaphore.c",
        "encoder/osal_thread.c",
        "encoder/picture_type.c",
        "encoder/rate_control_api.c",
        "encoder/rc_rd_model.c",
        "encoder/rc_rd_model_fix.c",
        "encoder/rc_sad_acc.c",
        "encoder/sqrt_interp.c",
        "encoder/var_q_operator.c",
        "encoder/vbr_storage_vbv.c",
        "encoder/vbr_str_prms.c",
    ],

    arch: {
        arm64: {

            local_include_dirs: [
                "encoder/arm",
                "common/arm",
                "common/arm64",
            ],

            srcs: [
                "encoder/arm/ihevce_coarse_layer_sad_neon.c",
                "encoder/arm/ihevce_common_utils_neon.c",
                "encoder/arm/ihevce_copy_neon.c",
                "encoder/arm/ihevce_had_compute_neon.c",
                "encoder/arm/ihevce_hme_utils_neon.c",
                "encoder/arm/ihevce_itrans_recon_neon.c",
                "encoder/arm/ihevce_me_neon.c",
                "encoder/arm/ihevce_sad_compute_neon.c",
                "encoder/arm/ihevce_scale_by_2_neon.c",
                "encoder/arm/ihevce_scan_coeffs_neon.c",
                "encoder/arm/ihevce_ssd_and_sad_calculator_neon.c",
                "encoder/arm/ihevce_ssd_calculator_neon.c",
                "encoder/arm/ihevce_subpel_neon.c",
                "common/arm/ihevc_resi_trans_neon.c",
                "common/arm/ihevc_resi_trans_neon_32x32.c",
                "common/arm/ihevc_quant_iquant_ssd_neon_intr.c",
                "common/arm/ihevc_intra_pred_filters_neon_intr.c",
                "common/arm/ihevc_weighted_pred_neon_intr.c",
                "common/arm/ihevc_intra_ref_substitution_a9q.c",
                "common/arm64/ihevc_deblk_chroma_horz.s",
                "common/arm64/ihevc_deblk_chroma_vert.s",
                "common/arm64/ihevc_deblk_luma_horz.s",
                "common/arm64/ihevc_deblk_luma_vert.s",
                "common/arm64/ihevc_inter_pred_chroma_copy.s",
                "common/arm64/ihevc_inter_pred_chroma_copy_w16out.s",
                "common/arm64/ihevc_inter_pred_chroma_horz.s",
                "common/arm64/ihevc_inter_pred_chroma_horz_w16out.s",
                "common/arm64/ihevc_inter_pred_chroma_vert.s",
                "common/arm64/ihevc_inter_pred_chroma_vert_w16inp.s",
                "common/arm64/ihevc_inter_pred_chroma_vert_w16inp_w16out.s",
                "common/arm64/ihevc_inter_pred_chroma_vert_w16out.s",
                "common/arm64/ihevc_inter_pred_filters_luma_horz.s",
                "common/arm64/ihevc_inter_pred_filters_luma_vert.s",
                "common/arm64/ihevc_inter_pred_filters_luma_vert_w16inp.s",
                "common/arm64/ihevc_inter_pred_filters_luma_vert_w16out.s",
                "common/arm64/ihevc_inter_pred_luma_copy.s",
                "common/arm64/ihevc_inter_pred_luma_copy_w16out.s",
                "common/arm64/ihevc_inter_pred_luma_horz_w16out.s",
                "common/arm64/ihevc_inter_pred_luma_vert_w16inp_w16out.s",
                "common/arm64/ihevc_intra_pred_chroma_dc.s",
                "common/arm64/ihevc_intra_pred_chroma_horz.s",
                "common/arm64/ihevc_intra_pred_chroma_mode2.s",
                "common/arm64/ihevc_intra_pred_chroma_mode_18_34.s",
                "common/arm64/ihevc_intra_pred_chroma_mode_27_to_33.s",
                "common/arm64/ihevc_intra_pred_chroma_mode_3_to_9.s",
                "common/arm64/ihevc_intra_pred_chroma_planar.s",
                "common/arm64/ihevc_intra_pred_chroma_ver.s",
                "common/arm64/ihevc_intra_pred_filters_chroma_mode_11_to_17.s",
                "common/arm64/ihevc_intra_pred_filters_chroma_mode_19_to_25.s",
                "common/arm64/ihevc_intra_pred_filters_luma_mode_11_to_17.s",
                "common/arm64/ihevc_intra_pred_filters_luma_mode_19_to_25.s",
                "common/arm64/ihevc_intra_pred_luma_dc.s",
                "common/arm64/ihevc_intra_pred_luma_horz.s",
                "common/arm64/ihevc_intra_pred_luma_mode2.s",
                "common/arm64/ihevc_intra_pred_luma_mode_18_34.s",
                "common/arm64/ihevc_intra_pred_luma_mode_27_to_33.s",
                "common/arm64/ihevc_intra_pred_luma_mode_3_to_9.s",
                "common/arm64/ihevc_intra_pred_luma_planar.s",
                "common/arm64/ihevc_intra_pred_luma_vert.s",
                "common/arm64/ihevc_itrans_recon_16x16.s",
                "common/arm64/ihevc_itrans_recon_32x32.s",
                "common/arm64/ihevc_itrans_recon_4x4.s",
                "common/arm64/ihevc_itrans_recon_4x4_ttype1.s",
                "common/arm64/ihevc_itrans_recon_8x8.s",
                "common/arm64/ihevc_mem_fns.s",
                "common/arm64/ihevc_padding.s",
                "common/arm64/ihevc_sao_band_offset_chroma.s",
                "common/arm64/ihevc_sao_band_offset_luma.s",
                "common/arm64/ihevc_sao_edge_offset_class0.s",
                "common/arm64/ihevc_sao_edge_offset_class0_chroma.s",
                "common/arm64/ihevc_sao_edge_offset_class1.s",
                "common/arm64/ihevc_sao_edge_offset_class1_chroma.s",
                "common/arm64/ihevc_sao_edge_offset_class2.s",
                "common/arm64/ihevc_sao_edge_offset_class2_chroma.s",
                "common/arm64/ihevc_sao_edge_offset_class3.s",
                "common/arm64/ihevc_sao_edge_offset_class3_chroma.s",
                "common/arm64/ihevc_weighted_pred_bi.s",
                "common/arm64/ihevc_weighted_pred_bi_default.s",
                "common/arm64/ihevc_weighted_pred_uni.s",
            ],

            cflags: [
                "-DENABLE_NEON",
                "-DARMV8",
                "-DARM",
            ],
        },

        arm: {
            local_include_dirs: [
                "encoder/arm",
                "common/arm",
            ],

            instruction_set: "arm",

            neon: {
                srcs: [
                    "encoder/arm/ihevce_coarse_layer_sad_neon.c",
                    "encoder/arm/ihevce_common_utils_neon.c",
                    "encoder/arm/ihevce_copy_neon.c",
                    "encoder/arm/ihevce_had_compute_neon.c",
                    "encoder/arm/ihevce_hme_utils_neon.c",
                    "encoder/arm/ihevce_itrans_recon_neon.c",
                    "encoder/arm/ihevce_me_neon.c",
                    "encoder/arm/ihevce_sad_compute_neon.c",
                    "encoder/arm/ihevce_scale_by_2_neon.c",
                    "encoder/arm/ihevce_scan_coeffs_neon.c",
                    "encoder/arm/ihevce_ssd_and_sad_calculator_neon.c",
                    "encoder/arm/ihevce_ssd_calculator_neon.c",
                    "encoder/arm/ihevce_subpel_neon.c",
                    "common/arm/ihevc_resi_trans_neon.c",
                    "common/arm/ihevc_resi_trans_neon_32x32.c",
                    "common/arm/ihevc_quant_iquant_ssd_neon_intr.c",
                    "common/arm/ihevc_intra_pred_filters_neon_intr.c",
                    "common/arm/ihevc_weighted_pred_neon_intr.c",
                    "common/arm/ihevc_intra_ref_substitution_a9q.c",
                    "common/arm/ihevc_deblk_chroma_horz.s",
                    "common/arm/ihevc_deblk_chroma_vert.s",
                    "common/arm/ihevc_deblk_luma_horz.s",
                    "common/arm/ihevc_deblk_luma_vert.s",
                    "common/arm/ihevc_inter_pred_chroma_copy.s",
                    "common/arm/ihevc_inter_pred_chroma_copy_w16out.s",
                    "common/arm/ihevc_inter_pred_chroma_horz.s",
                    "common/arm/ihevc_inter_pred_chroma_horz_w16out.s",
                    "common/arm/ihevc_inter_pred_chroma_vert.s",
                    "common/arm/ihevc_inter_pred_chroma_vert_w16inp.s",
                    "common/arm/ihevc_inter_pred_chroma_vert_w16inp_w16out.s",
                    "common/arm/ihevc_inter_pred_chroma_vert_w16out.s",
                    "common/arm/ihevc_inter_pred_filters_luma_horz.s",
                    "common/arm/ihevc_inter_pred_filters_luma_vert.s",
                    "common/arm/ihevc_inter_pred_filters_luma_vert_w16inp.s",
                    "common/arm/ihevc_inter_pred_luma_copy.s",
                    "common/arm/ihevc_inter_pred_luma_copy_w16out.s",
                    "common/arm/ihevc_inter_pred_luma_horz_w16out.s",
                    "common/arm/ihevc_inter_pred_luma_vert_w16inp_w16out.s",
                    "common/arm/ihevc_intra_pred_chroma_dc.s",
                    "common/arm/ihevc_intra_pred_chroma_horz.s",
                    "common/arm/ihevc_intra_pred_chroma_mode2.s",
                    "common/arm/ihevc_intra_pred_chroma_mode_18_34.s",
                    "common/arm/ihevc_intra_pred_chroma_mode_27_to_33.s",
                    "common/arm/ihevc_intra_pred_chroma_mode_3_to_9.s",
                    "common/arm/ihevc_intra_pred_chroma_planar.s",
                    "common/arm/ihevc_intra_pred_chroma_ver.s",
                    "common/arm/ihevc_intra_pred_filters_chroma_mode_11_to_17.s",
                    "common/arm/ihevc_intra_pred_filters_chroma_mode_19_to_25.s",
                    "common/arm/ihevc_intra_pred_filters_luma_mode_11_to_17.s",
                    "common/arm/ihevc_intra_pred_filters_luma_mode_19_to_25.s",
                    "common/arm/ihevc_intra_pred_luma_dc.s",
                    "common/arm/ihevc_intra_pred_luma_horz.s",
                    "common/arm/ihevc_intra_pred_luma_mode2.s",
                    "common/arm/ihevc_intra_pred_luma_mode_18_34.s",
                    "common/arm/ihevc_intra_pred_luma_mode_27_to_33.s",
                    "common/arm/ihevc_intra_pred_luma_mode_3_to_9.s",
                    "common/arm/ihevc_intra_pred_luma_planar.s",
                    "common/arm/ihevc_intra_pred_luma_vert.s",
                    "common/arm/ihevc_itrans_recon_16x16.s",
                    "common/arm/ihevc_itrans_recon_32x32.s",
                    "common/arm/ihevc_itrans_recon_4x4.s",
                    "common/arm/ihevc_itrans_recon_4x4_ttype1.s",
                    "common/arm/ihevc_itrans_recon_8x8.s",
                    "common/arm/ihevc_resi_trans.s",
                    "common/arm/ihevc_resi_trans_32x32_a9q.s",
                    "common/arm/ihevc_mem_fns.s",
                    "common/arm/ihevc_padding.s",
                    "common/arm/ihevc_sao_band_offset_chroma.s",
                    "common/arm/ihevc_sao_band_offset_luma.s",
                    "common/arm/ihevc_sao_edge_offset_class0.s",
                    "common/arm/ihevc_sao_edge_offset_class0_chroma.s",
                    "common/arm/ihevc_sao_edge_offset_class1.s",
                    "common/arm/ihevc_sao_edge_offset_class1_chroma.s",
                    "common/arm/ihevc_sao_edge_offset_class2.s",
                    "common/arm/ihevc_sao_edge_offset_class2_chroma.s",
                    "common/arm/ihevc_sao_edge_offset_class3.s",
                    "common/arm/ihevc_sao_edge_offset_class3_chroma.s",
                    "common/arm/ihevc_weighted_pred_bi_default.s",
                    "common/arm/ihevc_weighted_pred_bi.s",
                    "common/arm/ihevc_weighted_pred_uni.s",
                ],

                cflags: [
                    "-DENABLE_NEON",
                    "-DARM",
                ],
            },
        },

        x86_64: {
            local_include_dirs: [
                "common/x86",
            ],
        },

        x86: {
            local_include_dirs: [
                "common/x86",
            ],
        },

        riscv64: {
            local_include_dirs: [
                "common/riscv64",
            ],
        },
    },
    sanitize: {
        integer_overflow: true,
        misc_undefined: ["bounds"],
        // Enable CFI if this becomes a shared library.
        cfi: true,
	config: {
            cfi_assembly_support: true,
        },
        blocklist: "libhevc_blocklist.txt",
    },

    apex_available: [
        "//apex_available:platform",
        "com.android.media.swcodec",
    ],
    min_sdk_version: "29",
}

cc_test {
    name: "hevcenc",
    host_supported: true,
    cflags: [
        "-DARM",
        "-fPIC",
        "-Wall",
        "-Werror",
    ],
    gtest: false,
    srcs: ["test/encoder/main.c"],
    static_libs: ["libhevcenc"],
    sanitize: {
        integer_overflow: true,
        misc_undefined: ["bounds"],
    },
}