| # Copyright 2024 The Chromium Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/rust/rust_bindgen_generator.gni") |
| import("//build/rust/rust_static_library.gni") |
| |
| rust_bindgen_generator("crabbyavif_dav1d_bindings") { |
| header = "src/sys/dav1d-sys/wrapper.h" |
| deps = [ "//third_party/dav1d:dav1d_headers" ] |
| configs = [ "//third_party/dav1d:dav1d_config" ] |
| output_name = "dav1d_bindgen" |
| bindgen_flags = [ |
| "no-doc-comments", |
| "generate=functions,types,vars,methods,constructors,destructors", |
| "allowlist-item=DAV1D_MAX_THREADS", |
| "allowlist-item=dav1d_close", |
| "allowlist-item=dav1d_data_unref", |
| "allowlist-item=dav1d_data_wrap", |
| "allowlist-item=dav1d_default_settings", |
| "allowlist-item=dav1d_error", |
| "allowlist-item=dav1d_get_picture", |
| "allowlist-item=dav1d_open", |
| "allowlist-item=dav1d_picture_unref", |
| "allowlist-item=dav1d_send_data", |
| "allowlist-item=dav1d_version", |
| ] |
| } |
| |
| rust_static_library("crabbyavif_dav1d_sys") { |
| crate_root = "src/sys/dav1d-sys/src/lib.rs" |
| |
| # This is a wrapper interface to a C library. So unsafe has to be allowed. |
| allow_unsafe = true |
| crate_name = "dav1d_sys" |
| sources = [ "src/sys/dav1d-sys/src/lib.rs" ] |
| bindgen_deps = [ ":crabbyavif_dav1d_bindings" ] |
| features = [ "dav1d" ] |
| } |
| |
| rust_bindgen_generator("crabbyavif_libyuv_bindings") { |
| header = "src/sys/libyuv-sys/wrapper.h" |
| configs = [ "//third_party/libyuv:libyuv_config" ] |
| output_name = "libyuv_bindgen" |
| bindgen_flags = [ |
| "no-doc-comments", |
| "generate=functions,types,vars,methods,constructors,destructors", |
| "allowlist-item=ABGRToI420", |
| "allowlist-item=ABGRToJ400", |
| "allowlist-item=ABGRToJ420", |
| "allowlist-item=ABGRToJ422", |
| "allowlist-item=AR30ToAB30", |
| "allowlist-item=ARGBAttenuate", |
| "allowlist-item=ARGBToABGR", |
| "allowlist-item=ARGBToI400", |
| "allowlist-item=ARGBToI420", |
| "allowlist-item=ARGBToI422", |
| "allowlist-item=ARGBToI444", |
| "allowlist-item=ARGBToJ400", |
| "allowlist-item=ARGBToJ420", |
| "allowlist-item=ARGBToJ422", |
| "allowlist-item=ARGBUnattenuate", |
| "allowlist-item=BGRAToI420", |
| "allowlist-item=Convert16To8Plane", |
| "allowlist-item=FilterMode", |
| "allowlist-item=FilterMode_kFilterBilinear", |
| "allowlist-item=FilterMode_kFilterBox", |
| "allowlist-item=FilterMode_kFilterNone", |
| "allowlist-item=HalfFloatPlane", |
| "allowlist-item=I010AlphaToARGBMatrix", |
| "allowlist-item=I010AlphaToARGBMatrixFilter", |
| "allowlist-item=I010ToAR30Matrix", |
| "allowlist-item=I010ToARGBMatrix", |
| "allowlist-item=I010ToARGBMatrixFilter", |
| "allowlist-item=I012ToARGBMatrix", |
| "allowlist-item=I210AlphaToARGBMatrix", |
| "allowlist-item=I210AlphaToARGBMatrixFilter", |
| "allowlist-item=I210ToARGBMatrix", |
| "allowlist-item=I210ToARGBMatrixFilter", |
| "allowlist-item=I400ToARGBMatrix", |
| "allowlist-item=I410AlphaToARGBMatrix", |
| "allowlist-item=I410ToARGBMatrix", |
| "allowlist-item=I420AlphaToARGBMatrix", |
| "allowlist-item=I420AlphaToARGBMatrixFilter", |
| "allowlist-item=I420ToARGBMatrix", |
| "allowlist-item=I420ToARGBMatrixFilter", |
| "allowlist-item=I420ToRGB24Matrix", |
| "allowlist-item=I420ToRGB24MatrixFilter", |
| "allowlist-item=I420ToRGB565Matrix", |
| "allowlist-item=I420ToRGBAMatrix", |
| "allowlist-item=I422AlphaToARGBMatrix", |
| "allowlist-item=I422AlphaToARGBMatrixFilter", |
| "allowlist-item=I422ToARGBMatrix", |
| "allowlist-item=I422ToARGBMatrixFilter", |
| "allowlist-item=I422ToRGB24MatrixFilter", |
| "allowlist-item=I422ToRGB565Matrix", |
| "allowlist-item=I422ToRGBAMatrix", |
| "allowlist-item=I444AlphaToARGBMatrix", |
| "allowlist-item=I444ToARGBMatrix", |
| "allowlist-item=I444ToRGB24Matrix", |
| "allowlist-item=LIBYUV_VERSION", |
| "allowlist-item=NV12Scale", |
| "allowlist-item=NV12ToARGBMatrix", |
| "allowlist-item=NV12ToRGB565Matrix", |
| "allowlist-item=NV21ToARGBMatrix", |
| "allowlist-item=P010ToAR30Matrix", |
| "allowlist-item=P010ToARGBMatrix", |
| "allowlist-item=P010ToI010", |
| "allowlist-item=RAWToI420", |
| "allowlist-item=RAWToJ400", |
| "allowlist-item=RAWToJ420", |
| "allowlist-item=RGB24ToI420", |
| "allowlist-item=RGB24ToJ400", |
| "allowlist-item=RGB24ToJ420", |
| "allowlist-item=RGBAToI420", |
| "allowlist-item=RGBAToJ400", |
| "allowlist-item=ScalePlane", |
| "allowlist-item=ScalePlane_12", |
| "allowlist-item=YuvConstants", |
| "allowlist-item=kYuv2020Constants", |
| "allowlist-item=kYuvF709Constants", |
| "allowlist-item=kYuvH709Constants", |
| "allowlist-item=kYuvI601Constants", |
| "allowlist-item=kYuvJPEGConstants", |
| "allowlist-item=kYuvV2020Constants", |
| "allowlist-item=kYvu2020Constants", |
| "allowlist-item=kYvuF709Constants", |
| "allowlist-item=kYvuH709Constants", |
| "allowlist-item=kYvuI601Constants", |
| "allowlist-item=kYvuJPEGConstants", |
| "allowlist-item=kYvuV2020Constants", |
| ] |
| } |
| |
| rust_static_library("crabbyavif_libyuv_sys") { |
| crate_root = "src/sys/libyuv-sys/src/lib.rs" |
| |
| # This is a wrapper interface to a C++ library. So unsafe has to be allowed. |
| allow_unsafe = true |
| crate_name = "libyuv_sys" |
| sources = [ "src/sys/libyuv-sys/src/lib.rs" ] |
| bindgen_deps = [ ":crabbyavif_libyuv_bindings" ] |
| features = [ "libyuv" ] |
| } |
| |
| rust_static_library("crabbyavif") { |
| crate_root = "src/src/lib.rs" |
| edition = "2021" |
| |
| # This library exposes a C API and uses a couple of C/C++ libraries. So unsafe |
| # has to be allowed in order to allow those. The core library itself does not |
| # contain any unsafe Rust. |
| allow_unsafe = true |
| |
| sources = [ |
| "src/src/capi/decoder.rs", |
| "src/src/capi/gainmap.rs", |
| "src/src/capi/image.rs", |
| "src/src/capi/io.rs", |
| "src/src/capi/mod.rs", |
| "src/src/capi/reformat.rs", |
| "src/src/capi/types.rs", |
| "src/src/codecs/dav1d.rs", |
| "src/src/codecs/mod.rs", |
| "src/src/decoder/item.rs", |
| "src/src/decoder/mod.rs", |
| "src/src/decoder/tile.rs", |
| "src/src/decoder/track.rs", |
| "src/src/gainmap.rs", |
| "src/src/image.rs", |
| "src/src/internal_utils/io.rs", |
| "src/src/internal_utils/mod.rs", |
| "src/src/internal_utils/sampletransform.rs", |
| "src/src/internal_utils/stream.rs", |
| "src/src/lib.rs", |
| "src/src/parser/exif.rs", |
| "src/src/parser/mini.rs", |
| "src/src/parser/mod.rs", |
| "src/src/parser/mp4box.rs", |
| "src/src/parser/obu.rs", |
| "src/src/reformat/alpha.rs", |
| "src/src/reformat/coeffs.rs", |
| "src/src/reformat/libyuv.rs", |
| "src/src/reformat/mod.rs", |
| "src/src/reformat/rgb.rs", |
| "src/src/reformat/rgb_impl.rs", |
| "src/src/reformat/scale.rs", |
| "src/src/utils/clap.rs", |
| "src/src/utils/error.rs", |
| "src/src/utils/mod.rs", |
| "src/src/utils/pixels.rs", |
| "src/src/utils/reader/mod.rs", |
| "src/src/utils/reader/y4m.rs", |
| "src/src/utils/writer/mod.rs", |
| "src/src/utils/writer/y4m.rs", |
| ] |
| |
| features = [ |
| "dav1d", |
| "libyuv", |
| "capi", |
| "disable_cfi", |
| ] |
| |
| # Required for disable_cfi feature. |
| configs -= [ "//build/config/compiler:disallow_unstable_features" ] |
| rustflags = [ "-Zallow-features=sanitize" ] |
| |
| public_deps = [ ":header_files" ] |
| deps = [ |
| ":crabbyavif_dav1d_sys", |
| ":crabbyavif_libyuv_sys", |
| "//third_party/dav1d", |
| "//third_party/libyuv", |
| "//third_party/rust/libc/v0_2:lib", |
| ] |
| } |
| |
| source_set("header_files") { |
| visibility = [ ":*" ] |
| sources = [ "src/include/avif/avif.h" ] |
| } |